diff --git a/internal/app/wwctl/node/console/power.go b/internal/app/wwctl/node/console/power.go index e3be80cb..1f984934 100644 --- a/internal/app/wwctl/node/console/power.go +++ b/internal/app/wwctl/node/console/power.go @@ -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() diff --git a/internal/pkg/api/node/list.go b/internal/pkg/api/node/list.go index 7f79f10c..4f8b27a0 100644 --- a/internal/pkg/api/node/list.go +++ b/internal/pkg/api/node/list.go @@ -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, diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 3b4109a4..3512154a 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -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) diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index 6eb674a8..9e5faec7 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -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 { diff --git a/internal/pkg/power/ipmitool.go b/internal/pkg/power/ipmitool.go index ae647d50..73a5b913 100644 --- a/internal/pkg/power/ipmitool.go +++ b/internal/pkg/power/ipmitool.go @@ -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