From 3957ffb2c9e685708e478660d7d07f144b02afeb Mon Sep 17 00:00:00 2001 From: "Michael L. Young" Date: Mon, 6 Dec 2021 14:25:45 -0500 Subject: [PATCH] ipmi: Fix log output, set IMPI port on profile and settings for console - Fix the logs to reference the correct IPMI setting that is being set. - Add setting the IPMI port at a profile level. - Apply all IPMI settings when preparing to us the console. Closes #225 --- internal/app/wwctl/node/console/power.go | 12 +++++++----- internal/app/wwctl/profile/set/main.go | 13 +++++++++---- internal/app/wwctl/profile/set/root.go | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/internal/app/wwctl/node/console/power.go b/internal/app/wwctl/node/console/power.go index 9332edb7..aa9fcfa7 100644 --- a/internal/app/wwctl/node/console/power.go +++ b/internal/app/wwctl/node/console/power.go @@ -49,11 +49,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } ipmiCmd := power.IPMI{ - NodeName: node.Id.Get(), - HostName: node.IpmiIpaddr.Get(), - User: node.IpmiUserName.Get(), - Password: node.IpmiPassword.Get(), - AuthType: "MD5", + NodeName: node.Id.Get(), + HostName: node.IpmiIpaddr.Get(), + Port: node.IpmiPort.Get(), + User: node.IpmiUserName.Get(), + Password: node.IpmiPassword.Get(), + AuthType: "MD5", + Interface: node.IpmiInterface.Get(), } err := ipmiCmd.Console() diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 667111f7..74d128bd 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -96,12 +96,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } if SetIpmiNetmask != "" { - wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id.Get(), SetIpmiNetmask) + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI netmask to: %s\n", p.Id.Get(), SetIpmiNetmask) p.IpmiNetmask.Set(SetIpmiNetmask) } + if SetIpmiPort != "" { + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI port to: %s\n", p.Id.Get(), SetIpmiPort) + p.IpmiPort.Set(SetIpmiPort) + } + if SetIpmiGateway != "" { - wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id.Get(), SetIpmiGateway) + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI gateway to: %s\n", p.Id.Get(), SetIpmiGateway) p.IpmiGateway.Set(SetIpmiGateway) } @@ -111,12 +116,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } if SetIpmiPassword != "" { - wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id.Get(), SetIpmiPassword) + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI password to: %s\n", p.Id.Get(), SetIpmiPassword) p.IpmiPassword.Set(SetIpmiPassword) } if SetIpmiInterface != "" { - wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id.Get(), SetIpmiInterface) + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI interface to: %s\n", p.Id.Get(), SetIpmiInterface) p.IpmiInterface.Set(SetIpmiInterface) } diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 3bbccf73..392c1476 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -44,6 +44,7 @@ var ( SetRuntimeOverlay string SetSystemOverlay string SetIpmiNetmask string + SetIpmiPort string SetIpmiGateway string SetIpmiUsername string SetIpmiPassword string @@ -103,10 +104,11 @@ func init() { log.Println(err) } baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask") + baseCmd.PersistentFlags().StringVar(&SetIpmiPort, "ipmiport", "", "Set the node's IPMI port") baseCmd.PersistentFlags().StringVar(&SetIpmiGateway, "ipmigateway", "", "Set the node's IPMI gateway") baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username") baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password") - baseCmd.PersistentFlags().StringVar(&SetIpmiInterface, "ipmiinterface", "", "Set the node's IPMI interface (defaults to 'lan' if empty)") + baseCmd.PersistentFlags().StringVar(&SetIpmiInterface, "ipmiinterface", "", "Set the node's IPMI interface (defaults to 'lan')") baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure") baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")