Skip to content

Commit

Permalink
Merge pull request #999 from buzh/development
Browse files Browse the repository at this point in the history
Add option to change ipmitool escape char
  • Loading branch information
mslacken committed Dec 5, 2023
2 parents dd4c14e + c635fec commit 2196417
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Option to change the `ipmitool` escape character
- New documentation for the hostlist syntax. #611
- New documentation for development environment (Vagrant)
- Ability to duplicate an image with `wwctl container copy` or the API
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
* Matt Jolly <Kangie@footclan.ninja> @Kangie
* Arnaud LECOMTE <contact@arnaud-lcm.com>
* Ryan Novosielski <novosirj@rutgers.edu>
* Andreas Skau <andreas@scheen.no> @buzh
1 change: 1 addition & 0 deletions internal/app/wwctl/node/console/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/api/node/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s", "NODE NAME", "IPMI IPADDR", "IPMI PORT", "IPMI USERNAME", "IPMI INTERFACE"))
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s", n.Id.Print(),
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s:=:%s", n.Id.Print(),
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,
Expand Down
57 changes: 30 additions & 27 deletions internal/pkg/node/datastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ type NodeConf struct {
KernelOverride string `yaml:"kernel override,omitempty"`
KernelArgs string `yaml:"kernel args,omitempty"`
// Ipmi settings herer are deprecated and here for backward compatibility
IpmiUserName string `yaml:"ipmi username,omitempty"`
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"`
IpmiWrite string `yaml:"ipmi write,omitempty"`
IpmiUserName string `yaml:"ipmi username,omitempty"`
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"`
IpmiEscapeChar string `yaml:"ipmi escapechar,omitempty"`
IpmiWrite string `yaml:"ipmi write,omitempty"`
// Deprecated end
RuntimeOverlay []string `yaml:"runtime overlay,omitempty" lopt:"runtime" sopt:"R" comment:"Set the runtime overlay"`
SystemOverlay []string `yaml:"system overlay,omitempty" lopt:"wwinit" sopt:"O" comment:"Set the system overlay"`
Expand All @@ -54,16 +55,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"`
Expand Down Expand Up @@ -169,15 +171,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 {
Expand Down
27 changes: 17 additions & 10 deletions internal/pkg/power/ipmitool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions userdocs/contents/ipmi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ profile set`` or ``wwctl node set``.
+--------------------+---------+------+--------------------+---------------+
| ``--ipmiwrite`` | true | true | true or false | false |
+--------------------+---------+------+--------------------+---------------+
| ``--ipmiescapechar | true | true | single character | ~ |
+--------------------+---------+------+--------------------+---------------+


Reviewing Settings
Expand Down Expand Up @@ -113,6 +115,7 @@ Node View
n001 ipmipass -- --
n001 ipmiinterface -- --
n001 ipmiwrite -- --
n001 ipmiescapechar -- --
n001 profile -- default
n001 default:type -- (ethernet)
n001 default:onboot -- --
Expand Down

0 comments on commit 2196417

Please sign in to comment.