Merge pull request #81 from paulscherrerinstitute/nodeCleanup

Node cleanup
This commit is contained in:
Gregory M. Kurtzer
2021-06-30 13:13:19 -07:00
committed by GitHub
3 changed files with 17 additions and 13 deletions

View File

@@ -24,6 +24,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
fmt.Printf("Added node: %s\n", a)
if SetClusterName != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting cluster name to: %s\n", n.Id.Get(), SetClusterName)
n.ClusterName.Set(SetClusterName)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
if SetIpaddr != "" {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -35,7 +45,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
n.NetDevs[SetNetDev] = &netdev
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id, SetNetDev, SetIpaddr)
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, SetIpaddr)
n.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
n.NetDevs[SetNetDev].Default.SetB(true)
@@ -55,7 +65,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
os.Exit(1)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id, SetNetDev, SetNetmask)
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask)
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
err := nodeDB.NodeUpdate(n)
@@ -74,7 +84,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
os.Exit(1)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id, SetNetDev, SetGateway)
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway)
n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
err := nodeDB.NodeUpdate(n)
@@ -93,7 +103,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
os.Exit(1)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id, SetNetDev, SetHwaddr)
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr)
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
err := nodeDB.NodeUpdate(n)
@@ -113,7 +123,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
os.Exit(1)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type to: %s\n", n.Id, SetNetDev, SetType)
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Type to: %s\n", n.Id.Get(), SetNetDev, SetType)
n.NetDevs[SetNetDev].Type.Set(SetType)
err := nodeDB.NodeUpdate(n)

View File

@@ -10,8 +10,7 @@ var (
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
SetGroup string
SetController string
SetClusterName string
SetNetDev string
SetIpaddr string
SetNetmask string
@@ -22,8 +21,7 @@ var (
)
func init() {
baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Group to add nodes to")
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add nodes to")
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(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")

View File

@@ -13,14 +13,10 @@ var (
}
SetYes bool
SetForce string
SetGroup string
SetController string
)
func init() {
baseCmd.PersistentFlags().StringVarP(&SetForce, "force", "f", "", "Force node delete")
baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Set group to delete nodes from")
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "default", "Controller to add nodes to")
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
}