Simplify bmc templates

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-11-07 22:20:45 -07:00
parent 8189390e03
commit d1697ef83d
2 changed files with 23 additions and 28 deletions

View File

@@ -1,19 +1,15 @@
{{/* used command to access the ipmi interface of the nodes */}}
{{- $escapechar := "~" }}
{{- $port := "623" }}
{{- $interface := "lan" }}
{{- $escapechar := "~" }}{{ if .EscapeChar }}{{ $escapechar = .EscapeChar }}{{ end }}
{{- $port := "623" }}{{ if .Port }}{{ $port = .Port }}{{ end }}
{{- $interface := "lan" }}{{- if .Interface }}{{ $interface = .Interface }}{{ end }}
{{- $args := "" }}
{{- if .EscapeChar }} $escapechar = .EscapeChar {{ end }}
{{- if .Port }} {{ $port = .Port }} {{ end }}
{{- if .Interface }} {{ $interface = .Interface }} {{ end }}
{{- if eq .Cmd "PowerOn" }} {{ $args = "chassis power on" }} {{ end }}
{{- if eq .Cmd "PowerOff" }} {{ $args = "chassis power off" }} {{ end }}
{{- if eq .Cmd "PowerCycle" }} {{ $args = "chassis power cycle" }} {{ end }}
{{- if eq .Cmd "PowerReset" }} {{ $args = "chassis power reset" }} {{ end }}
{{- if eq .Cmd "PowerSoft" }} {{ $args = "chassis power soft" }} {{ end }}
{{- if eq .Cmd "PowerStatus" }} {{ $args = "chassis power status" }} {{ end }}
{{- if eq .Cmd "SDRList" }} {{ $args = "sdr list" }} {{ end }}
{{- if eq .Cmd "SensorList" }} {{ $args = "sensor list" }} {{ end }}
{{- if eq .Cmd "Console" }} {{ $args = "sol activate" }} {{ end }}
{{- $cmd := printf "ipmitool -I %s -H %s -p %s -U %s -P %s -e %s %s" $interface .Ipaddr $port .UserName .Password $escapechar $args }}
{{ $cmd }}
{{- if eq .Cmd "PowerOn" }}{{ $args = "chassis power on" }}
{{- else if eq .Cmd "PowerOff" }}{{ $args = "chassis power off" }}
{{- else if eq .Cmd "PowerCycle" }}{{ $args = "chassis power cycle" }}
{{- else if eq .Cmd "PowerReset" }}{{ $args = "chassis power reset" }}
{{- else if eq .Cmd "PowerSoft" }}{{ $args = "chassis power soft" }}
{{- else if eq .Cmd "PowerStatus" }}{{ $args = "chassis power status" }}
{{- else if eq .Cmd "SDRList" }}{{ $args = "sdr list" }}
{{- else if eq .Cmd "SensorList" }}{{ $args = "sensor list" }}
{{- else if eq .Cmd "Console" }}{{ $args = "sol activate" }}{{ end }}
ipmitool -I {{ $interface }} -H {{ .Ipaddr }} -p {{ $port }} -U {{ .UserName }} -P {{ .Password }} -e {{ $escapechar }} {{ $args }}

View File

@@ -1,12 +1,11 @@
{{/* used command to access nodes without bmc*/}}
{{- $cmd := "echo command not found" }}
{{- if eq .Cmd "PowerOn" }} {{ $cmd = printf "wol %s" .Interface }} {{ end }}
{{- if eq .Cmd "PowerOff" }} {{ $cmd = printf "ssh %s echo o > /proc/sysrq-trigger" .Ipaddr }} {{ end }}
{{- if eq .Cmd "PowerCycle" }} {{ $cmd = printf "ssh %s echo r > /proc/sysrq-trigger" .Ipaddr }} {{ end }}
{{- if eq .Cmd "PowerRest" }} {{ $cmd = printf "ssh %s echo r > /proc/sysrq-trigger" .Ipaddr }} {{ end }}
{{- if eq .Cmd "PowerSoft" }} {{ $cmd = print "ssh %s reboot" .Ipaddr }} {{ end }}
{{- if eq .Cmd "PowerStatus" }} {{ $args = "ping -c 1 %s &> /dev/null %s && echo ON || echo OFF" .Ipaddr }} {{ end }}
{{- if eq .Cmd "SDRList" }} {{ $cmd = print "ssh %s sensors" .Ipaddr }} {{ end }}
{{- if eq .Cmd "SensorList" }} {{ $cmd = print "ssh %s sensors" .Ipaddr }} {{ end }}
{{- if eq .Cmd "Console" }} {{ $args = "echo node sol" }} {{ end }}
{{ $cmd }}
{{- if eq .Cmd "PowerOn" }}wol {{ .Interface }}
{{- else if eq .Cmd "PowerOff" }}ssh {{ .Ipaddr }} echo o > /proc/sysrq-trigger
{{- else if eq .Cmd "PowerCycle" }}ssh {{ .Ipaddr }} echo r > /proc/sysrq-trigger
{{- else if eq .Cmd "PowerReset" }}ssh {{ .Ipaddr }} echo r > /proc/sysrq-trigger
{{- else if eq .Cmd "PowerSoft" }}ssh {{ .Ipaddr }} reboot
{{- else if eq .Cmd "PowerStatus" }}ping -c 1 {{ .Ipaddr }} &> /dev/null && echo ON || echo OFF
{{- else if eq .Cmd "SDRList" }}ssh {{ .Ipaddr }} sensors
{{- else if eq .Cmd "SensorList" }}ssh {{ .Ipaddr }} sensors
{{- else if eq .Cmd "Console" }}echo node sol
{{- else }}echo "command not found"{{ end }}