From 16db64f9dce3af61f221377f96c8378833be5a07 Mon Sep 17 00:00:00 2001 From: Niko Kivel Date: Fri, 14 May 2021 15:08:58 +0200 Subject: [PATCH 1/3] removed group and controller, added ClusterName --- internal/app/wwctl/node/add/main.go | 10 ++++++++++ internal/app/wwctl/node/add/root.go | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/app/wwctl/node/add/main.go b/internal/app/wwctl/node/add/main.go index 807b33ac..4f043077 100644 --- a/internal/app/wwctl/node/add/main.go +++ b/internal/app/wwctl/node/add/main.go @@ -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") diff --git a/internal/app/wwctl/node/add/root.go b/internal/app/wwctl/node/add/root.go index e7ba130a..c4c716b3 100644 --- a/internal/app/wwctl/node/add/root.go +++ b/internal/app/wwctl/node/add/root.go @@ -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") From cba1e926f99b9688fa8407180e7e49c4209ff034 Mon Sep 17 00:00:00 2001 From: Niko Kivel Date: Fri, 14 May 2021 15:12:38 +0200 Subject: [PATCH 2/3] fixed n.Id.Get() in wwlog.VERBOSE --- internal/app/wwctl/node/add/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/app/wwctl/node/add/main.go b/internal/app/wwctl/node/add/main.go index 4f043077..ab76b24a 100644 --- a/internal/app/wwctl/node/add/main.go +++ b/internal/app/wwctl/node/add/main.go @@ -45,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) @@ -65,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) @@ -84,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) @@ -103,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) @@ -123,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) From 5ffda2da3fb429db51d52a30974675f930d1140f Mon Sep 17 00:00:00 2001 From: Niko Kivel Date: Fri, 14 May 2021 15:17:32 +0200 Subject: [PATCH 3/3] removed group and controller --- internal/app/wwctl/node/delete/root.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/app/wwctl/node/delete/root.go b/internal/app/wwctl/node/delete/root.go index 3bdf8f46..868ad862 100644 --- a/internal/app/wwctl/node/delete/root.go +++ b/internal/app/wwctl/node/delete/root.go @@ -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") }