Various fixes found in testing

This commit is contained in:
Gregory Kurtzer
2021-12-29 17:16:53 -08:00
parent 00d8d42e9d
commit 9f53bca1bf
9 changed files with 84 additions and 24 deletions

View File

@@ -168,10 +168,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetNetName != "" {
if _, ok := n.NetDevs[SetNetName]; !ok {
var nd node.NetDevEntry
n.NetDevs[SetNetName] = &nd
SetNetOnBoot = "yes"
if len(n.NetDevs) == 0 {
SetNetDefault = "yes"
}
n.NetDevs[SetNetName] = &nd
if SetNetDev == "" {
n.NetDevs[SetNetName].Device.Set(SetNetName)
}
@@ -255,6 +260,27 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetNetDefault != "" {
if SetNetName == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
os.Exit(1)
}
if SetNetDefault == "yes" || SetNetDefault == "y" || SetNetDefault == "1" || SetNetDefault == "true" {
// Set all other devices to non-default
for _, n := range n.NetDevs {
n.Default.SetB(false)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting DEFAULT\n", n.Id.Get(), SetNetName)
n.NetDevs[SetNetName].Default.SetB(true)
} else {
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Unsetting DEFAULT\n", n.Id.Get(), SetNetName)
n.NetDevs[SetNetName].Default.SetB(false)
}
}
if SetNetDevDel {
if SetNetName == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")

View File

@@ -44,6 +44,7 @@ var (
SetHwaddr string
SetType string
SetNetOnBoot string
SetNetDefault string
SetNetDevDel bool
SetClusterName string
SetIpxe string
@@ -138,6 +139,7 @@ func init() {
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", "", "Enable/disable device (yes/no)")
baseCmd.PersistentFlags().StringVar(&SetNetDefault, "default", "", "Enable/disable device as default (yes/no)")
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")