Merge pull request #177 from gmkurtzer/netdev_refactor
Refactor netdev interfaces
This commit is contained in:
@@ -34,102 +34,106 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDev != "" {
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
var netdev node.NetDevEntry
|
||||
n.NetDevs[SetNetName] = &netdev
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Device to: %s\n", n.Id.Get(), SetNetName, SetNetDev)
|
||||
|
||||
n.NetDevs[SetNetName].Device.Set(SetNetDev)
|
||||
n.NetDevs[SetNetName].OnBoot.SetB(true)
|
||||
|
||||
}
|
||||
|
||||
if SetIpaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
return errors.New("you must include the '--netdev' option")
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
NewIpaddr := util.IncrementIPv4(SetIpaddr, count)
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
var netdev node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &netdev
|
||||
n.NetDevs[SetNetName] = &netdev
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, NewIpaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetName, NewIpaddr)
|
||||
|
||||
n.NetDevs[SetNetName].Ipaddr.Set(NewIpaddr)
|
||||
n.NetDevs[SetNetName].OnBoot.SetB(true)
|
||||
|
||||
n.NetDevs[SetNetDev].Ipaddr.Set(NewIpaddr)
|
||||
n.NetDevs[SetNetDev].Default.SetB(true)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetmask != "" {
|
||||
if SetNetDev == "" {
|
||||
return errors.New("you must include the '--netdev' option")
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetDev)
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetName)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetName, SetNetmask)
|
||||
|
||||
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
n.NetDevs[SetNetName].Netmask.Set(SetNetmask)
|
||||
}
|
||||
|
||||
if SetGateway != "" {
|
||||
if SetNetDev == "" {
|
||||
return errors.New("you must include the '--netdev' option")
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetDev)
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetName)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetName, SetGateway)
|
||||
|
||||
n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
n.NetDevs[SetNetName].Gateway.Set(SetGateway)
|
||||
}
|
||||
|
||||
if SetHwaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
return errors.New("you must include the '--netdev' option")
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetDev)
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetName)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetName, SetHwaddr)
|
||||
|
||||
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
n.NetDevs[SetNetName].Hwaddr.Set(SetHwaddr)
|
||||
n.NetDevs[SetNetName].OnBoot.SetB(true)
|
||||
}
|
||||
|
||||
if SetType != "" {
|
||||
if SetNetDev == "" {
|
||||
return errors.New("you must include the '--netdev' option")
|
||||
if SetNetName == "" {
|
||||
return errors.New("you must include the '--netname' option")
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetDev)
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
return errors.New("network device does not exist: " + SetNetName)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type to: %s\n", n.Id.Get(), SetNetDev, SetType)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type to: %s\n", n.Id.Get(), SetNetName, SetType)
|
||||
|
||||
n.NetDevs[SetNetDev].Type.Set(SetType)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
n.NetDevs[SetNetName].Type.Set(SetType)
|
||||
}
|
||||
|
||||
if SetDiscoverable {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get())
|
||||
|
||||
n.Discoverable.SetB(true)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
}
|
||||
|
||||
err = nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update nodedb")
|
||||
}
|
||||
|
||||
count++
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ var (
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
SetClusterName string
|
||||
SetNetName string
|
||||
SetNetDev string
|
||||
SetIpaddr string
|
||||
SetNetmask string
|
||||
@@ -23,14 +24,14 @@ var (
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "c", "", "Set the node's cluster name")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "eth0", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetName, "netname", "n", "default", "Define the network name to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetDiscoverable, "discoverable", false, "Make this node discoverable")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -56,12 +56,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiInterface", node.IpmiInterface.Source(), node.IpmiInterface.Print())
|
||||
|
||||
for name, netdev := range node.NetDevs {
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":DEVICE", netdev.Device.Source(), netdev.Device.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":HWADDR", netdev.Hwaddr.Source(), netdev.Hwaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":IPADDR", netdev.Ipaddr.Source(), netdev.Ipaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Source(), netdev.Netmask.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Source(), netdev.Gateway.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TYPE", netdev.Type.Source(), netdev.Type.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB())
|
||||
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":ONBOOT", netdev.OnBoot.Source(), netdev.OnBoot.PrintB())
|
||||
}
|
||||
|
||||
for keyname, key := range node.Keys {
|
||||
|
||||
@@ -165,112 +165,109 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDevDel {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
if SetNetName != "" {
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetName] = &nd
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
SetNetOnBoot = "yes"
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Id.Get(), SetNetDev)
|
||||
delete(n.NetDevs, SetNetDev)
|
||||
if SetNetDev == "" {
|
||||
n.NetDevs[SetNetName].Device.Set(SetNetName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDev != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting net Device to: %s\n", n.Id.Get(), SetNetName, SetNetDev)
|
||||
n.NetDevs[SetNetName].Device.Set(SetNetDev)
|
||||
}
|
||||
|
||||
if SetIpaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
NewIpaddr := util.IncrementIPv4(SetIpaddr, count)
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, NewIpaddr)
|
||||
n.NetDevs[SetNetDev].Ipaddr.Set(NewIpaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetName, NewIpaddr)
|
||||
n.NetDevs[SetNetName].Ipaddr.Set(NewIpaddr)
|
||||
}
|
||||
|
||||
if SetNetmask != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask)
|
||||
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetName, SetNetmask)
|
||||
n.NetDevs[SetNetName].Netmask.Set(SetNetmask)
|
||||
}
|
||||
|
||||
if SetGateway != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway)
|
||||
n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetName, SetGateway)
|
||||
n.NetDevs[SetNetName].Gateway.Set(SetGateway)
|
||||
}
|
||||
|
||||
if SetHwaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr)
|
||||
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetName, SetHwaddr)
|
||||
n.NetDevs[SetNetName].Hwaddr.Set(SetHwaddr)
|
||||
}
|
||||
|
||||
if SetType != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type %s\n", n.Id.Get(), SetNetDev, SetType)
|
||||
n.NetDevs[SetNetDev].Type.Set(SetType)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type %s\n", n.Id.Get(), SetNetName, SetType)
|
||||
n.NetDevs[SetNetName].Type.Set(SetType)
|
||||
}
|
||||
|
||||
if SetNetDevDefault {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
if SetNetOnBoot != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &nd
|
||||
if SetNetOnBoot == "yes" || SetNetOnBoot == "y" || SetNetOnBoot == "1" || SetNetOnBoot == "true" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting ONBOOT\n", n.Id.Get(), SetNetName)
|
||||
n.NetDevs[SetNetName].OnBoot.SetB(true)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Unsetting ONBOOT\n", n.Id.Get(), SetNetName)
|
||||
n.NetDevs[SetNetName].OnBoot.SetB(false)
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDevDel {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting device as default\n", n.Id.Get(), SetNetDev)
|
||||
for _, dev := range n.NetDevs {
|
||||
// First clear all other devices that might be configured as default
|
||||
dev.Default.SetB(false)
|
||||
if _, ok := n.NetDevs[SetNetName]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network device name doesn't exist: %s\n", SetNetName)
|
||||
os.Exit(1)
|
||||
}
|
||||
n.NetDevs[SetNetDev].Default.SetB(true)
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Id.Get(), SetNetName)
|
||||
delete(n.NetDevs, SetNetName)
|
||||
}
|
||||
|
||||
if SetValue != "" {
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "set [OPTIONS] PATTERN [PATTERN ...]",
|
||||
Short: "Configure node properties",
|
||||
Use: "set [OPTIONS] PATTERN [PATTERN ...]",
|
||||
Short: "Configure node properties",
|
||||
Long: "This command sets configuration properties for nodes matching PATTERN.\n\n" +
|
||||
"Note: use the string 'UNSET' to remove a configuration",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
@@ -37,14 +37,15 @@ var (
|
||||
SetContainer string
|
||||
SetKernel string
|
||||
SetKernelArgs string
|
||||
SetNetName string
|
||||
SetNetDev string
|
||||
SetIpaddr string
|
||||
SetNetmask string
|
||||
SetGateway string
|
||||
SetHwaddr string
|
||||
SetType string
|
||||
SetNetOnBoot string
|
||||
SetNetDevDel bool
|
||||
SetNetDevDefault bool
|
||||
SetClusterName string
|
||||
SetIpxe string
|
||||
SetRuntimeOverlay string
|
||||
@@ -127,14 +128,17 @@ func init() {
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetName, "netname", "n", "", "Define the network name to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetName, "netdev", "N", "", "Alias to --netname")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdevice", "D", "", "Define the network device")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
|
||||
baseCmd.PersistentFlags().StringVar(&SetNetOnBoot, "onboot", "yes", "Enable/disable device (yes/no)")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
||||
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKey, "key", "k", "", "Define custom key")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetKeyDel, "keydel", false, "Delete custom key")
|
||||
|
||||
@@ -53,7 +53,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":GATEWAY", netdev.Gateway.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":HWADDR", netdev.Hwaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":TYPE", netdev.Hwaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB())
|
||||
}
|
||||
|
||||
for keyname, key := range profile.Keys {
|
||||
|
||||
@@ -135,9 +135,97 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
p.Discoverable.SetB(false)
|
||||
}
|
||||
|
||||
if SetNetName != "" {
|
||||
if _, ok := p.NetDevs[SetNetName]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetName] = &nd
|
||||
|
||||
SetNetOnBoot = "yes"
|
||||
|
||||
if SetNetDev == "" {
|
||||
p.NetDevs[SetNetName].Device.Set(SetNetName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDev != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting net Device to: %s\n", p.Id.Get(), SetNetName, SetNetDev)
|
||||
p.NetDevs[SetNetName].Device.Set(SetNetDev)
|
||||
}
|
||||
|
||||
if SetIpaddr != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting IP address to: %s:%s\n", p.Id.Get(), SetNetName, SetHwaddr)
|
||||
p.NetDevs[SetNetName].Ipaddr.Set(SetIpaddr)
|
||||
}
|
||||
|
||||
if SetNetmask != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting netmask to: %s:%s\n", p.Id.Get(), SetNetName, SetHwaddr)
|
||||
p.NetDevs[SetNetName].Netmask.Set(SetNetmask)
|
||||
}
|
||||
|
||||
if SetGateway != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting gateway to: %s:%s\n", p.Id.Get(), SetNetName, SetHwaddr)
|
||||
p.NetDevs[SetNetName].Gateway.Set(SetGateway)
|
||||
}
|
||||
|
||||
if SetHwaddr != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetName, SetHwaddr)
|
||||
p.NetDevs[SetNetName].Hwaddr.Set(SetHwaddr)
|
||||
}
|
||||
|
||||
if SetType != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetName, SetType)
|
||||
p.NetDevs[SetNetName].Type.Set(SetType)
|
||||
}
|
||||
|
||||
if SetNetOnBoot != "" {
|
||||
if SetNetName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if SetNetOnBoot == "yes" || SetNetOnBoot == "y" || SetNetOnBoot == "1" || SetNetOnBoot == "true" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting ONBOOT\n", p.Id.Get(), SetNetName)
|
||||
p.NetDevs[SetNetName].OnBoot.SetB(true)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Unsetting ONBOOT\n", p.Id.Get(), SetNetName)
|
||||
p.NetDevs[SetNetName].OnBoot.SetB(false)
|
||||
}
|
||||
}
|
||||
|
||||
if SetNetDevDel {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -150,100 +238,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
delete(p.NetDevs, SetNetDev)
|
||||
}
|
||||
|
||||
if SetIpaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting IP address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
|
||||
p.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
|
||||
}
|
||||
|
||||
if SetNetmask != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting netmask to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
|
||||
p.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
|
||||
}
|
||||
|
||||
if SetGateway != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting gateway to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
|
||||
p.NetDevs[SetNetDev].Gateway.Set(SetGateway)
|
||||
}
|
||||
|
||||
if SetHwaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
|
||||
p.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
|
||||
}
|
||||
|
||||
if SetType != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetDev, SetType)
|
||||
p.NetDevs[SetNetDev].Type.Set(SetType)
|
||||
}
|
||||
|
||||
if SetNetDevDefault {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := p.NetDevs[SetNetDev]; !ok {
|
||||
var nd node.NetDevEntry
|
||||
p.NetDevs[SetNetDev] = &nd
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Setting device as default\n", p.Id.Get(), SetNetDev)
|
||||
for _, dev := range p.NetDevs {
|
||||
// First clear all other devices that might be configured as default
|
||||
dev.Default.SetB(false)
|
||||
}
|
||||
p.NetDevs[SetNetDev].Default.SetB(true)
|
||||
}
|
||||
|
||||
if SetValue != "" {
|
||||
if SetKey == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
|
||||
|
||||
@@ -49,14 +49,15 @@ var (
|
||||
SetIpmiUsername string
|
||||
SetIpmiPassword string
|
||||
SetIpmiInterface string
|
||||
SetNetName string
|
||||
SetNetDev string
|
||||
SetIpaddr string
|
||||
SetNetmask string
|
||||
SetGateway string
|
||||
SetHwaddr string
|
||||
SetType string
|
||||
SetNetOnBoot string
|
||||
SetNetDevDel bool
|
||||
SetNetDevDefault bool
|
||||
SetDiscoverable bool
|
||||
SetUndiscoverable bool
|
||||
SetInit string
|
||||
@@ -110,14 +111,17 @@ func init() {
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiInterface, "ipmiinterface", "", "Set the node's IPMI interface (defaults to 'lan')")
|
||||
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetName, "netname", "n", "", "Define the network name to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetName, "netdev", "N", "", "Alias to --netname")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdevice", "D", "", "Define the network device")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
|
||||
baseCmd.PersistentFlags().StringVar(&SetNetOnBoot, "onboot", "yes", "Enable/disable device (yes/no)")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
||||
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKey, "key", "k", "", "Define custom key")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetKeyDel, "keydel", false, "Delete custom key")
|
||||
|
||||
@@ -87,12 +87,14 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
n.NetDevs[devname] = &netdev
|
||||
}
|
||||
|
||||
n.NetDevs[devname].Name.Set(devname)
|
||||
n.NetDevs[devname].Device.Set(netdev.Device)
|
||||
n.NetDevs[devname].Ipaddr.Set(netdev.Ipaddr)
|
||||
n.NetDevs[devname].Netmask.Set(netdev.Netmask)
|
||||
n.NetDevs[devname].Hwaddr.Set(netdev.Hwaddr)
|
||||
n.NetDevs[devname].Gateway.Set(netdev.Gateway)
|
||||
n.NetDevs[devname].Type.Set(netdev.Type)
|
||||
n.NetDevs[devname].Default.SetB(netdev.Default)
|
||||
n.NetDevs[devname].OnBoot.SetB(netdev.OnBoot)
|
||||
}
|
||||
|
||||
for keyname, key := range node.Keys {
|
||||
@@ -139,12 +141,13 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
}
|
||||
wwlog.Printf(wwlog.DEBUG, "Updating profile (%s) netdev: %s\n", p, devname)
|
||||
|
||||
n.NetDevs[devname].Device.SetAlt(netdev.Device, p)
|
||||
n.NetDevs[devname].Ipaddr.SetAlt(netdev.Ipaddr, p)
|
||||
n.NetDevs[devname].Netmask.SetAlt(netdev.Netmask, p)
|
||||
n.NetDevs[devname].Hwaddr.SetAlt(netdev.Hwaddr, p)
|
||||
n.NetDevs[devname].Gateway.SetAlt(netdev.Gateway, p)
|
||||
n.NetDevs[devname].Type.SetAlt(netdev.Type, p)
|
||||
n.NetDevs[devname].Default.SetAltB(netdev.Default, p)
|
||||
n.NetDevs[devname].OnBoot.SetAltB(netdev.OnBoot, p)
|
||||
}
|
||||
|
||||
for keyname, key := range config.NodeProfiles[p].Keys {
|
||||
@@ -210,12 +213,14 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Updating profile netdev: %s\n", devname)
|
||||
|
||||
p.NetDevs[devname].Name.Set(devname)
|
||||
p.NetDevs[devname].Device.Set(netdev.Device)
|
||||
p.NetDevs[devname].Ipaddr.Set(netdev.Ipaddr)
|
||||
p.NetDevs[devname].Netmask.Set(netdev.Netmask)
|
||||
p.NetDevs[devname].Hwaddr.Set(netdev.Hwaddr)
|
||||
p.NetDevs[devname].Gateway.Set(netdev.Gateway)
|
||||
p.NetDevs[devname].Type.Set(netdev.Type)
|
||||
p.NetDevs[devname].Default.SetB(netdev.Default)
|
||||
p.NetDevs[devname].OnBoot.SetB(netdev.OnBoot)
|
||||
}
|
||||
|
||||
for keyname, key := range profile.Keys {
|
||||
|
||||
@@ -39,8 +39,10 @@ type NodeConf struct {
|
||||
}
|
||||
|
||||
type NetDevs struct {
|
||||
Name string
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Default bool `yaml:"default"`
|
||||
OnBoot bool `yaml:"onboot"`
|
||||
Device string `yaml:"device"`
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
IpCIDR string
|
||||
@@ -90,8 +92,10 @@ type NodeInfo struct {
|
||||
}
|
||||
|
||||
type NetDevEntry struct {
|
||||
Name Entry
|
||||
Type Entry `yaml:"type,omitempty"`
|
||||
Default Entry `yaml:"default"`
|
||||
OnBoot Entry `yaml:"onboot"`
|
||||
Device Entry `yaml:"device"`
|
||||
Hwaddr Entry
|
||||
Ipaddr Entry
|
||||
IpCIDR Entry
|
||||
|
||||
@@ -84,12 +84,13 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
|
||||
var newdev NetDevs
|
||||
config.Nodes[nodeID].NetDevs[devname] = &newdev
|
||||
|
||||
config.Nodes[nodeID].NetDevs[devname].Device = netdev.Device.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Ipaddr = netdev.Ipaddr.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Netmask = netdev.Netmask.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Hwaddr = netdev.Hwaddr.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Gateway = netdev.Gateway.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Type = netdev.Type.GetReal()
|
||||
config.Nodes[nodeID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
||||
config.Nodes[nodeID].NetDevs[devname].OnBoot = netdev.OnBoot.GetRealB()
|
||||
}
|
||||
|
||||
for keyname, key := range node.Keys {
|
||||
@@ -169,12 +170,13 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
|
||||
var newdev NetDevs
|
||||
config.NodeProfiles[profileID].NetDevs[devname] = &newdev
|
||||
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Device = netdev.Device.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Ipaddr = netdev.Ipaddr.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Netmask = netdev.Netmask.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Hwaddr = netdev.Hwaddr.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Gateway = netdev.Gateway.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Type = netdev.Type.GetReal()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
||||
config.NodeProfiles[profileID].NetDevs[devname].OnBoot = netdev.OnBoot.GetRealB()
|
||||
}
|
||||
|
||||
for keyname, key := range profile.Keys {
|
||||
|
||||
@@ -160,12 +160,15 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
|
||||
for devname, netdev := range n.NetDevs {
|
||||
var nd node.NetDevs
|
||||
t.NetDevs[devname] = &nd
|
||||
t.NetDevs[devname].Name = devname
|
||||
t.NetDevs[devname].Device = netdev.Device.Get()
|
||||
t.NetDevs[devname].Hwaddr = netdev.Hwaddr.Get()
|
||||
t.NetDevs[devname].Ipaddr = netdev.Ipaddr.Get()
|
||||
t.NetDevs[devname].Netmask = netdev.Netmask.Get()
|
||||
t.NetDevs[devname].Gateway = netdev.Gateway.Get()
|
||||
t.NetDevs[devname].Type = netdev.Type.Get()
|
||||
t.NetDevs[devname].Default = netdev.Default.GetB()
|
||||
t.NetDevs[devname].OnBoot = netdev.OnBoot.GetB()
|
||||
|
||||
mask := net.IPMask(net.ParseIP(netdev.Netmask.Get()).To4())
|
||||
ipaddr := net.ParseIP(netdev.Ipaddr.Get()).To4()
|
||||
netaddr := net.IPNet{IP: ipaddr, Mask: mask}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{{range $node := $.AllNodes}}
|
||||
# Entry for {{$node.Id.Get}}
|
||||
{{- range $devname, $netdev := $node.NetDevs}}
|
||||
{{- if $netdev.Default}}
|
||||
{{- if eq $netdev.Name.Get "default"}}
|
||||
{{$netdev.Ipaddr.Get}} {{$node.Id.Get}}
|
||||
{{- else}}
|
||||
{{$netdev.Ipaddr.Get}} {{$node.Id.Get}}-{{$devname}}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
auto {{.NetDevs.default.Device}}
|
||||
allow-hotplug {{.NetDevs.default.Device}}
|
||||
iface {{.NetDevs.default.Device}} inet static
|
||||
address {{.NetDevs.default.Ipaddr}}
|
||||
netmask {{.NetDevs.default.Netmask}}
|
||||
gateway {{.NetDevs.default.Gateway}}
|
||||
up ifmetric {{.NetDevs.default.Device}} 30
|
||||
@@ -1,10 +0,0 @@
|
||||
auto eth0
|
||||
allow-hotplug eth0
|
||||
iface eth0 inet static
|
||||
address {{.NetDevs.eth0.Ipaddr}}
|
||||
netmask {{.NetDevs.eth0.Netmask}}
|
||||
gateway {{.NetDevs.eth0.Gateway}}
|
||||
up ifmetric eth0 30
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
DEVICE={{$.NetDevs.default.Device}}
|
||||
NAME=default
|
||||
BOOTPROTO=static
|
||||
DEVTIMEOUT=10
|
||||
IPADDR={{$.NetDevs.default.Ipaddr}}
|
||||
NETMASK={{$.NetDevs.default.Netmask}}
|
||||
GATEWAY={{$.NetDevs.default.Gateway}}
|
||||
HWADDR={{$.NetDevs.default.Hwaddr}}
|
||||
{{- if $.NetDevs.default.OnBoot}}
|
||||
ONBOOT=yes
|
||||
{{- else}}
|
||||
ONBOOT=no
|
||||
{{- end}}
|
||||
@@ -1,10 +0,0 @@
|
||||
DEVICE=eth0
|
||||
NAME=eth0
|
||||
IPADDR={{$.NetDevs.eth0.Ipaddr}}
|
||||
NETMASK={{$.NetDevs.eth0.Netmask}}
|
||||
GATEWAY={{$.NetDevs.eth0.Gateway}}
|
||||
HWADDR={{$.NetDevs.eth0.Hwaddr}}
|
||||
BOOTPROTO=static
|
||||
ONBOOT=yes
|
||||
DEVTIMEOUT=10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# /etc/systemd/network/10-persistent-net.link
|
||||
|
||||
{{range $devname, $netdev := .NetDevs}}
|
||||
{{- if $netdev.Default}}
|
||||
{{- if eq $netdev.Name "default"}}
|
||||
[Match]
|
||||
MACAddress={{$netdev.Hwaddr}}
|
||||
[Link]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<interface origin="static generated warewulf config">
|
||||
<name>eth0</name>
|
||||
<name>{{.NetDevs.default.Device}}</name>
|
||||
<control>
|
||||
<mode>boot</mode>
|
||||
</control>
|
||||
@@ -11,11 +11,11 @@
|
||||
</ipv4>
|
||||
<ipv4:static>
|
||||
<address>
|
||||
<local>{{$.NetDevs.eth0.IpCIDR}}</local>
|
||||
<local>{{$.NetDevs.default.IpCIDR}}</local>
|
||||
</address>
|
||||
<route>
|
||||
<nexthop>
|
||||
<gateway>{{$.NetDevs.eth0.Gateway}}</gateway>
|
||||
<gateway>{{$.NetDevs.default.Gateway}}</gateway>
|
||||
</nexthop>
|
||||
</route>
|
||||
</ipv4:static>
|
||||
Reference in New Issue
Block a user