Skip to content

Commit 1219bee

Browse files
authored
Merge pull request #47 from OpenCHAMI/rainest/power-action
feat: add fake power actions
2 parents 1133f3e + 980850b commit 1219bee

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

pkg/client/smd/smd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type System struct {
9797
UUID string `json:"uuid" yaml:"uuid"`
9898
Name string `json:"name" yaml:"name"`
9999
EthernetInterfaces []schemas.EthernetInterface `json:"ethernet_interfaces" yaml:"ethernet_interfaces"`
100+
Actions []string `json:"actions" yaml:"actions"`
100101
}
101102

102103
// Manager represents data that would be retrieved from BMC Manager data, except

pkg/discover/discover.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ func DiscoveryInfoV2(baseURI string, nl NodeList) (smd.ComponentSlice, smd.Redfi
172172
s.UUID = sysUUID.String()
173173
}
174174

175+
// Fake discovery as of v0.5.1 does not have a field to indicate supported power actions, and PCS requires
176+
// them. We don't have direct configuration for the System struct that contains this either, so in lieu of
177+
// that, simply add every possible action from from the Redfish Reference 6.5.5.1 ResetType:
178+
// https://www.dmtf.org/sites/default/files/standards/documents/DSP2046_2023.3.html#aggregate-102
179+
s.Actions = []string{"On", "ForceOff", "GracefulShutdown", "GracefulRestart", "ForceRestart", "Nmi",
180+
"ForceOn", "PushPowerButton", "PowerCycle", "Suspend", "Pause", "Resume"}
181+
175182
// Node interfaces
176183
for idx, iface := range node.Ifaces {
177184
newIface := schemas.EthernetInterface{

pkg/discover/discover_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/google/uuid"
9+
910
"github.com/openchami/schemas/schemas"
1011

1112
"github.com/OpenCHAMI/ochami/pkg/client/smd"
@@ -194,6 +195,13 @@ func TestDiscoveryInfoV2_Success(t *testing.T) {
194195
}); !reflect.DeepEqual(e, want) {
195196
t.Errorf("System.EthernetInterface = %+v, want %+v", e, want)
196197
}
198+
if !reflect.DeepEqual(
199+
sys.Actions,
200+
[]string{"On", "ForceOff", "GracefulShutdown", "GracefulRestart", "ForceRestart", "Nmi", "ForceOn",
201+
"PushPowerButton", "PowerCycle", "Suspend", "Pause", "Resume"},
202+
) {
203+
t.Error("System.Actions does not match the expected value")
204+
}
197205

198206
// Managers
199207
if len(r.Managers) != 1 {

0 commit comments

Comments
 (0)