Add IPMI escape char functionality
This commit is contained in:
@@ -56,6 +56,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
Password: node.Ipmi.Password.Get(),
|
||||
AuthType: "MD5",
|
||||
Interface: node.Ipmi.Interface.Get(),
|
||||
EscapeChar: node.Ipmi.EscapeChar.Get(),
|
||||
}
|
||||
|
||||
err := ipmiCmd.Console()
|
||||
|
||||
@@ -64,7 +64,8 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
|
||||
n.Ipmi.Ipaddr.Print(),
|
||||
n.Ipmi.Port.Print(),
|
||||
n.Ipmi.UserName.Print(),
|
||||
n.Ipmi.Interface.Print()))
|
||||
n.Ipmi.Interface.Print(),
|
||||
n.Ipmi.EscapeChar.Print()))
|
||||
}
|
||||
} else if nodeGet.Type == wwapiv1.GetNodeList_Long {
|
||||
nodeList.Output = append(nodeList.Output,
|
||||
|
||||
@@ -263,6 +263,7 @@ func (config *NodeYaml) FindAllProfiles() ([]NodeInfo, error) {
|
||||
p.Ipmi.Password.Set(profile.IpmiPassword)
|
||||
p.Ipmi.Interface.Set(profile.IpmiInterface)
|
||||
p.Ipmi.Write.Set(profile.IpmiWrite)
|
||||
p.Ipmi.EscapeChar.Set(profile.IpmiEscapeChar)
|
||||
p.Kernel.Args.Set(profile.KernelArgs)
|
||||
p.Kernel.Override.Set(profile.KernelOverride)
|
||||
p.Kernel.Override.Set(profile.KernelVersion)
|
||||
|
||||
@@ -54,16 +54,17 @@ type NodeConf struct {
|
||||
}
|
||||
|
||||
type IpmiConf struct {
|
||||
UserName string `yaml:"username,omitempty" lopt:"ipmiuser" comment:"Set the IPMI username"`
|
||||
Password string `yaml:"password,omitempty" lopt:"ipmipass" comment:"Set the IPMI password"`
|
||||
Ipaddr string `yaml:"ipaddr,omitempty" lopt:"ipmiaddr" comment:"Set the IPMI IP address" type:"IP"`
|
||||
Netmask string `yaml:"netmask,omitempty" lopt:"ipminetmask" comment:"Set the IPMI netmask" type:"IP"`
|
||||
Port string `yaml:"port,omitempty" lopt:"ipmiport" comment:"Set the IPMI port"`
|
||||
Gateway string `yaml:"gateway,omitempty" lopt:"ipmigateway" comment:"Set the IPMI gateway" type:"IP"`
|
||||
Interface string `yaml:"interface,omitempty" lopt:"ipmiinterface" comment:"Set the node's IPMI interface (defaults: 'lan')"`
|
||||
Write string `yaml:"write,omitempty" lopt:"ipmiwrite" comment:"Enable the write of impi configuration (true/false)" type:"bool"`
|
||||
Tags map[string]string `yaml:"tags,omitempty" lopt:"ipmitagadd" comment:"add ipmitags"`
|
||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"ipmitagdel" comment:"remove ipmitags"` // should not go to disk only to wire
|
||||
UserName string `yaml:"username,omitempty" lopt:"ipmiuser" comment:"Set the IPMI username"`
|
||||
Password string `yaml:"password,omitempty" lopt:"ipmipass" comment:"Set the IPMI password"`
|
||||
Ipaddr string `yaml:"ipaddr,omitempty" lopt:"ipmiaddr" comment:"Set the IPMI IP address" type:"IP"`
|
||||
Netmask string `yaml:"netmask,omitempty" lopt:"ipminetmask" comment:"Set the IPMI netmask" type:"IP"`
|
||||
Port string `yaml:"port,omitempty" lopt:"ipmiport" comment:"Set the IPMI port"`
|
||||
Gateway string `yaml:"gateway,omitempty" lopt:"ipmigateway" comment:"Set the IPMI gateway" type:"IP"`
|
||||
Interface string `yaml:"interface,omitempty" lopt:"ipmiinterface" comment:"Set the node's IPMI interface (defaults: 'lan')"`
|
||||
EscapeChar string `yaml:"escapechar,omitempty" lopt:"ipmiescapechar" comment:"Set the IPMI escape character (defaults: '~')"`
|
||||
Write string `yaml:"write,omitempty" lopt:"ipmiwrite" comment:"Enable the write of impi configuration (true/false)" type:"bool"`
|
||||
Tags map[string]string `yaml:"tags,omitempty" lopt:"ipmitagadd" comment:"add ipmitags"`
|
||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"ipmitagdel" comment:"remove ipmitags"` // should not go to disk only to wire
|
||||
}
|
||||
type KernelConf struct {
|
||||
Version string `yaml:"version,omitempty"`
|
||||
@@ -169,15 +170,16 @@ type NodeInfo struct {
|
||||
}
|
||||
|
||||
type IpmiEntry struct {
|
||||
Ipaddr Entry
|
||||
Netmask Entry
|
||||
Port Entry
|
||||
Gateway Entry
|
||||
UserName Entry
|
||||
Password Entry
|
||||
Interface Entry
|
||||
Write Entry
|
||||
Tags map[string]*Entry
|
||||
Ipaddr Entry
|
||||
Netmask Entry
|
||||
Port Entry
|
||||
Gateway Entry
|
||||
UserName Entry
|
||||
Password Entry
|
||||
Interface Entry
|
||||
EscapeChar Entry
|
||||
Write Entry
|
||||
Tags map[string]*Entry
|
||||
}
|
||||
|
||||
type KernelEntry struct {
|
||||
|
||||
@@ -12,14 +12,15 @@ type IPMIResult struct {
|
||||
}
|
||||
|
||||
type IPMI struct {
|
||||
NodeName string
|
||||
HostName string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
AuthType string
|
||||
Interface string
|
||||
result IPMIResult
|
||||
NodeName string
|
||||
HostName string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
AuthType string
|
||||
Interface string
|
||||
EscapeChar string
|
||||
result IPMIResult
|
||||
}
|
||||
|
||||
func (ipmi *IPMI) Result() (string, error) {
|
||||
@@ -36,7 +37,10 @@ func (ipmi *IPMI) Command(ipmiArgs []string) ([]byte, error) {
|
||||
if ipmi.Port == "" {
|
||||
ipmi.Port = "623"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
if ipmi.EscapeChar == "" {
|
||||
ipmi.EscapeChar = "~"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password, "-e", ipmi.EscapeChar)
|
||||
args = append(args, ipmiArgs...)
|
||||
ipmiCmd := exec.Command("ipmitool", args...)
|
||||
return ipmiCmd.CombinedOutput()
|
||||
@@ -52,7 +56,10 @@ func (ipmi *IPMI) InteractiveCommand(ipmiArgs []string) error {
|
||||
if ipmi.Port == "" {
|
||||
ipmi.Port = "623"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password)
|
||||
if ipmi.EscapeChar == "" {
|
||||
ipmi.EscapeChar = "~"
|
||||
}
|
||||
args = append(args, "-I", ipmi.Interface, "-H", ipmi.HostName, "-p", ipmi.Port, "-U", ipmi.User, "-P", ipmi.Password, "-e", ipmi.EscapeChar)
|
||||
args = append(args, ipmiArgs...)
|
||||
ipmiCmd := exec.Command("ipmitool", args...)
|
||||
ipmiCmd.Stdout = os.Stdout
|
||||
|
||||
Reference in New Issue
Block a user