From 16db64f9dce3af61f221377f96c8378833be5a07 Mon Sep 17 00:00:00 2001 From: Niko Kivel Date: Fri, 14 May 2021 15:08:58 +0200 Subject: [PATCH] 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")