From 89a6e9dc6f85513c6ca13a6aa06e96c36f695731 Mon Sep 17 00:00:00 2001 From: Niko Kivel Date: Fri, 26 Mar 2021 10:38:55 +0100 Subject: [PATCH] NIC type for profile-->set --- internal/app/wwctl/profile/set/main.go | 15 +++++++++++++++ internal/app/wwctl/profile/set/root.go | 2 ++ 2 files changed, 17 insertions(+) diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 11547f42..c80bed74 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -215,6 +215,21 @@ func CobraRunE(cmd *cobra.Command, args []string) error { 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 == true { if SetNetDev == "" { wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 5562ccb3..9eadcb8f 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -29,6 +29,7 @@ var ( SetNetmask string SetGateway string SetHwaddr string + SetType string SetNetDevDel bool SetNetDevDefault bool SetInit string @@ -57,6 +58,7 @@ func init() { 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(&SetNetDevDel, "netdel", false, "Delete the node's network device") baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")