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
This commit is contained in:
Michael L. Young
2021-12-06 14:25:45 -05:00
parent 04f0a25fbc
commit 3957ffb2c9
3 changed files with 19 additions and 10 deletions

View File

@@ -49,11 +49,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
ipmiCmd := power.IPMI{ ipmiCmd := power.IPMI{
NodeName: node.Id.Get(), NodeName: node.Id.Get(),
HostName: node.IpmiIpaddr.Get(), HostName: node.IpmiIpaddr.Get(),
User: node.IpmiUserName.Get(), Port: node.IpmiPort.Get(),
Password: node.IpmiPassword.Get(), User: node.IpmiUserName.Get(),
AuthType: "MD5", Password: node.IpmiPassword.Get(),
AuthType: "MD5",
Interface: node.IpmiInterface.Get(),
} }
err := ipmiCmd.Console() err := ipmiCmd.Console()

View File

@@ -96,12 +96,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
if SetIpmiNetmask != "" { 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) 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 != "" { 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) p.IpmiGateway.Set(SetIpmiGateway)
} }
@@ -111,12 +116,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
if SetIpmiPassword != "" { 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) p.IpmiPassword.Set(SetIpmiPassword)
} }
if SetIpmiInterface != "" { 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) p.IpmiInterface.Set(SetIpmiInterface)
} }

View File

@@ -44,6 +44,7 @@ var (
SetRuntimeOverlay string SetRuntimeOverlay string
SetSystemOverlay string SetSystemOverlay string
SetIpmiNetmask string SetIpmiNetmask string
SetIpmiPort string
SetIpmiGateway string SetIpmiGateway string
SetIpmiUsername string SetIpmiUsername string
SetIpmiPassword string SetIpmiPassword string
@@ -103,10 +104,11 @@ func init() {
log.Println(err) log.Println(err)
} }
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask") 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(&SetIpmiGateway, "ipmigateway", "", "Set the node's IPMI gateway")
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username") 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(&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(&SetNetDev, "netdev", "N", "", "Define the network device to configure")
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address") baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")