Add IPMI Port Configuration
This commit adds the ability to configure the default IPMI port for a profile or per node. If the port is not set, we default to 623. Updated some areas to default to 'lan' for IPMI interface if it has not been set.
This commit is contained in:
@@ -47,6 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Root", node.Root.Source(), node.Root.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiPort", node.IpmiPort.Source(), node.IpmiPort.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiGateway", node.IpmiGateway.Source(), node.IpmiGateway.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiInterface", node.IpmiInterface.Source(), node.IpmiInterface.Print())
|
||||
@@ -80,11 +81,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
} else if ShowIpmi {
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s %-20s\n", "NODE NAME", "IPMI IPADDR", "IPMI USERNAME", "IPMI PASSWORD", "IPMI INTERFACE")
|
||||
fmt.Printf("%-22s %-16s %-5s %-20s %-20s %-20s\n", "NODE NAME", "IPMI IPADDR", "IPMI PORT", "IPMI USERNAME", "IPMI PASSWORD", "IPMI INTERFACE")
|
||||
fmt.Println(strings.Repeat("=", 80))
|
||||
|
||||
for _, node := range node.FilterByName(nodes, args) {
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s %-20s\n", node.Id.Get(), node.IpmiIpaddr.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print(), node.IpmiInterface.Print())
|
||||
fmt.Printf("%-22s %-16s %-5s %-20s %-20s %-20s\n", node.Id.Get(), node.IpmiIpaddr.Print(), node.IpmiPort.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print(), node.IpmiInterface.Print())
|
||||
}
|
||||
|
||||
} else if ShowLong {
|
||||
|
||||
@@ -52,9 +52,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if node.IpmiInterface.Get() != "" {
|
||||
ipmiInterface = node.IpmiInterface.Get()
|
||||
}
|
||||
var ipmiPort = "623"
|
||||
if node.IpmiPort.Get() != "" {
|
||||
ipmiPort = node.IpmiPort.Get()
|
||||
}
|
||||
ipmiCmd := power.IPMI{
|
||||
NodeName: node.Id.Get(),
|
||||
HostName: node.IpmiIpaddr.Get(),
|
||||
Port: ipmiPort,
|
||||
User: node.IpmiUserName.Get(),
|
||||
Password: node.IpmiPassword.Get(),
|
||||
Interface: ipmiInterface,
|
||||
|
||||
@@ -160,6 +160,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
n.IpmiNetmask.Set(SetIpmiNetmask)
|
||||
}
|
||||
|
||||
if SetIpmiPort != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI port to: %s\n", n.Id.Get(), SetIpmiPort)
|
||||
n.IpmiPort.Set(SetIpmiPort)
|
||||
}
|
||||
|
||||
if SetIpmiGateway != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI gateway to: %s\n", n.Id.Get(), SetIpmiGateway)
|
||||
n.IpmiGateway.Set(SetIpmiGateway)
|
||||
|
||||
@@ -29,6 +29,7 @@ var (
|
||||
SetSystemOverlay string
|
||||
SetIpmiIpaddr string
|
||||
SetIpmiNetmask string
|
||||
SetIpmiPort string
|
||||
SetIpmiGateway string
|
||||
SetIpmiUsername string
|
||||
SetIpmiPassword string
|
||||
@@ -62,10 +63,11 @@ func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI IP address")
|
||||
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' if empty)")
|
||||
|
||||
baseCmd.PersistentFlags().StringSliceVar(&SetAddProfile, "addprofile", []string{}, "Add Profile(s) to node")
|
||||
baseCmd.PersistentFlags().StringSliceVar(&SetDelProfile, "delprofile", []string{}, "Remove Profile(s) to node")
|
||||
|
||||
@@ -52,9 +52,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if node.IpmiInterface.Get() != "" {
|
||||
ipmiInterface = node.IpmiInterface.Get()
|
||||
}
|
||||
var ipmiPort = "623"
|
||||
if node.IpmiPort.Get() != "" {
|
||||
ipmiPort = node.IpmiPort.Get()
|
||||
}
|
||||
ipmiCmd := power.IPMI{
|
||||
NodeName: node.Id.Get(),
|
||||
HostName: node.IpmiIpaddr.Get(),
|
||||
Port: ipmiPort,
|
||||
User: node.IpmiUserName.Get(),
|
||||
Password: node.IpmiPassword.Get(),
|
||||
Interface: ipmiInterface,
|
||||
|
||||
@@ -48,12 +48,21 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())
|
||||
continue
|
||||
}
|
||||
|
||||
var ipmiInterface = "lan"
|
||||
if node.IpmiInterface.Get() != "" {
|
||||
ipmiInterface = node.IpmiInterface.Get()
|
||||
}
|
||||
var ipmiPort = "623"
|
||||
if node.IpmiPort.Get() != "" {
|
||||
ipmiPort = node.IpmiPort.Get()
|
||||
}
|
||||
ipmiCmd := power.IPMI{
|
||||
NodeName: node.Id.Get(),
|
||||
HostName: node.IpmiIpaddr.Get(),
|
||||
Port: ipmiPort,
|
||||
User: node.IpmiUserName.Get(),
|
||||
Password: node.IpmiPassword.Get(),
|
||||
Interface: ipmiInterface,
|
||||
AuthType: "MD5",
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if node.IpmiInterface.Get() != "" {
|
||||
ipmiInterface = node.IpmiInterface.Get()
|
||||
}
|
||||
var ipmiPort = "623"
|
||||
if node.IpmiPort.Get() != "" {
|
||||
ipmiPort = node.IpmiPort.Get()
|
||||
}
|
||||
ipmiCmd := power.IPMI{
|
||||
NodeName: node.Id.Get(),
|
||||
HostName: node.IpmiIpaddr.Get(),
|
||||
Port: ipmiPort,
|
||||
User: node.IpmiUserName.Get(),
|
||||
Password: node.IpmiPassword.Get(),
|
||||
Interface: ipmiInterface,
|
||||
|
||||
@@ -52,9 +52,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if node.IpmiInterface.Get() != "" {
|
||||
ipmiInterface = node.IpmiInterface.Get()
|
||||
}
|
||||
var ipmiPort = "623"
|
||||
if node.IpmiPort.Get() != "" {
|
||||
ipmiPort = node.IpmiPort.Get()
|
||||
}
|
||||
ipmiCmd := power.IPMI{
|
||||
NodeName: node.Id.Get(),
|
||||
HostName: node.IpmiIpaddr.Get(),
|
||||
Port: ipmiPort,
|
||||
User: node.IpmiUserName.Get(),
|
||||
Password: node.IpmiPassword.Get(),
|
||||
Interface: ipmiInterface,
|
||||
|
||||
@@ -43,6 +43,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Ipxe", profile.Ipxe.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiIpaddr", profile.IpmiIpaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiNetmask", profile.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiPort", profile.IpmiPort.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiGateway", profile.IpmiGateway.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiUserName", profile.IpmiUserName.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiInterface", profile.IpmiInterface.Print())
|
||||
|
||||
@@ -58,7 +58,7 @@ func init() {
|
||||
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' if empty)")
|
||||
|
||||
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")
|
||||
|
||||
@@ -72,6 +72,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
n.Init.Set(node.Init)
|
||||
n.IpmiIpaddr.Set(node.IpmiIpaddr)
|
||||
n.IpmiNetmask.Set(node.IpmiNetmask)
|
||||
n.IpmiPort.Set(node.IpmiPort)
|
||||
n.IpmiGateway.Set(node.IpmiGateway)
|
||||
n.IpmiUserName.Set(node.IpmiUserName)
|
||||
n.IpmiPassword.Set(node.IpmiPassword)
|
||||
@@ -121,6 +122,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
n.Init.SetAlt(config.NodeProfiles[p].Init, p)
|
||||
n.IpmiIpaddr.SetAlt(config.NodeProfiles[p].IpmiIpaddr, p)
|
||||
n.IpmiNetmask.SetAlt(config.NodeProfiles[p].IpmiNetmask, p)
|
||||
n.IpmiPort.SetAlt(config.NodeProfiles[p].IpmiPort, p)
|
||||
n.IpmiGateway.SetAlt(config.NodeProfiles[p].IpmiGateway, p)
|
||||
n.IpmiUserName.SetAlt(config.NodeProfiles[p].IpmiUserName, p)
|
||||
n.IpmiPassword.SetAlt(config.NodeProfiles[p].IpmiPassword, p)
|
||||
@@ -187,6 +189,7 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
|
||||
p.KernelVersion.Set(profile.KernelVersion)
|
||||
p.KernelArgs.Set(profile.KernelArgs)
|
||||
p.IpmiNetmask.Set(profile.IpmiNetmask)
|
||||
p.IpmiPort.Set(profile.IpmiPort)
|
||||
p.IpmiGateway.Set(profile.IpmiGateway)
|
||||
p.IpmiUserName.Set(profile.IpmiUserName)
|
||||
p.IpmiPassword.Set(profile.IpmiPassword)
|
||||
|
||||
@@ -28,6 +28,7 @@ type NodeConf struct {
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
|
||||
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
|
||||
IpmiPort string `yaml:"ipmi port,omitempty"`
|
||||
IpmiGateway string `yaml:"ipmi gateway,omitempty"`
|
||||
IpmiInterface string `yaml:"ipmi interface,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay,omitempty"`
|
||||
@@ -75,6 +76,7 @@ type NodeInfo struct {
|
||||
KernelArgs Entry
|
||||
IpmiIpaddr Entry
|
||||
IpmiNetmask Entry
|
||||
IpmiPort Entry
|
||||
IpmiGateway Entry
|
||||
IpmiUserName Entry
|
||||
IpmiPassword Entry
|
||||
|
||||
@@ -63,6 +63,7 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
|
||||
config.Nodes[nodeID].KernelArgs = node.KernelArgs.GetReal()
|
||||
config.Nodes[nodeID].IpmiIpaddr = node.IpmiIpaddr.GetReal()
|
||||
config.Nodes[nodeID].IpmiNetmask = node.IpmiNetmask.GetReal()
|
||||
config.Nodes[nodeID].IpmiPort = node.IpmiPort.GetReal()
|
||||
config.Nodes[nodeID].IpmiGateway = node.IpmiGateway.GetReal()
|
||||
config.Nodes[nodeID].IpmiUserName = node.IpmiUserName.GetReal()
|
||||
config.Nodes[nodeID].IpmiPassword = node.IpmiPassword.GetReal()
|
||||
@@ -147,6 +148,7 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
|
||||
config.NodeProfiles[profileID].KernelArgs = profile.KernelArgs.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiIpaddr = profile.IpmiIpaddr.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiNetmask = profile.IpmiNetmask.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiPort = profile.IpmiPort.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiGateway = profile.IpmiGateway.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiUserName = profile.IpmiUserName.GetReal()
|
||||
config.NodeProfiles[profileID].IpmiPassword = profile.IpmiPassword.GetReal()
|
||||
|
||||
@@ -29,6 +29,7 @@ type TemplateStruct struct {
|
||||
Root string
|
||||
IpmiIpaddr string
|
||||
IpmiNetmask string
|
||||
IpmiPort string
|
||||
IpmiGateway string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
@@ -149,6 +150,7 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
|
||||
t.Root = n.Root.Get()
|
||||
t.IpmiIpaddr = n.IpmiIpaddr.Get()
|
||||
t.IpmiNetmask = n.IpmiNetmask.Get()
|
||||
t.IpmiPort = n.IpmiPort.Get()
|
||||
t.IpmiGateway = n.IpmiGateway.Get()
|
||||
t.IpmiUserName = n.IpmiUserName.Get()
|
||||
t.IpmiPassword = n.IpmiPassword.Get()
|
||||
|
||||
@@ -13,6 +13,7 @@ type IPMIResult struct {
|
||||
type IPMI struct {
|
||||
NodeName string
|
||||
HostName string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
AuthType string
|
||||
@@ -29,9 +30,12 @@ func (ipmi *IPMI) Command(ipmiArgs []string) ([]byte, error) {
|
||||
var args []string
|
||||
|
||||
if ipmi.Interface == "" {
|
||||
ipmi.Interface = "lanplus"
|
||||
ipmi.Interface = "lan"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
if ipmi.Port == "" {
|
||||
ipmi.Port = "623"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
args = append(args, ipmiArgs...)
|
||||
ipmiCmd := exec.Command("ipmitool", args...)
|
||||
return ipmiCmd.CombinedOutput()
|
||||
@@ -44,8 +48,10 @@ func (ipmi *IPMI) InteractiveCommand(ipmiArgs []string) error {
|
||||
if ipmi.Interface == "" {
|
||||
ipmi.Interface = "lan"
|
||||
}
|
||||
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
if ipmi.Port == "" {
|
||||
ipmi.Port = "623"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
args = append(args, ipmiArgs...)
|
||||
ipmiCmd := exec.Command("ipmitool", args...)
|
||||
ipmiCmd.Stdout = os.Stdout
|
||||
|
||||
Reference in New Issue
Block a user