From 980850b5a79f1a932929a449328a8fbed7b82af4 Mon Sep 17 00:00:00 2001 From: Travis Raines <571832+rainest@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:53:14 -0700 Subject: [PATCH] feat: add fake power actions Add the System.Actions field and populate it with all possible actions during fake discovery. PCS rejects transitions if SMD doesn't recognize the action for a given system, so this provides a permissive default. Signed-off-by: Travis Raines <571832+rainest@users.noreply.github.com> --- pkg/client/smd/smd.go | 1 + pkg/discover/discover.go | 7 +++++++ pkg/discover/discover_test.go | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/pkg/client/smd/smd.go b/pkg/client/smd/smd.go index 873be6f9..abf1c67a 100644 --- a/pkg/client/smd/smd.go +++ b/pkg/client/smd/smd.go @@ -97,6 +97,7 @@ type System struct { UUID string `json:"uuid" yaml:"uuid"` Name string `json:"name" yaml:"name"` EthernetInterfaces []schemas.EthernetInterface `json:"ethernet_interfaces" yaml:"ethernet_interfaces"` + Actions []string `json:"actions" yaml:"actions"` } // Manager represents data that would be retrieved from BMC Manager data, except diff --git a/pkg/discover/discover.go b/pkg/discover/discover.go index c26bf147..2f33ca6a 100644 --- a/pkg/discover/discover.go +++ b/pkg/discover/discover.go @@ -172,6 +172,13 @@ func DiscoveryInfoV2(baseURI string, nl NodeList) (smd.ComponentSlice, smd.Redfi s.UUID = sysUUID.String() } + // Fake discovery as of v0.5.1 does not have a field to indicate supported power actions, and PCS requires + // them. We don't have direct configuration for the System struct that contains this either, so in lieu of + // that, simply add every possible action from from the Redfish Reference 6.5.5.1 ResetType: + // https://www.dmtf.org/sites/default/files/standards/documents/DSP2046_2023.3.html#aggregate-102 + s.Actions = []string{"On", "ForceOff", "GracefulShutdown", "GracefulRestart", "ForceRestart", "Nmi", + "ForceOn", "PushPowerButton", "PowerCycle", "Suspend", "Pause", "Resume"} + // Node interfaces for idx, iface := range node.Ifaces { newIface := schemas.EthernetInterface{ diff --git a/pkg/discover/discover_test.go b/pkg/discover/discover_test.go index a4e22665..9d32a9f3 100644 --- a/pkg/discover/discover_test.go +++ b/pkg/discover/discover_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/google/uuid" + "github.com/openchami/schemas/schemas" "github.com/OpenCHAMI/ochami/pkg/client/smd" @@ -194,6 +195,13 @@ func TestDiscoveryInfoV2_Success(t *testing.T) { }); !reflect.DeepEqual(e, want) { t.Errorf("System.EthernetInterface = %+v, want %+v", e, want) } + if !reflect.DeepEqual( + sys.Actions, + []string{"On", "ForceOff", "GracefulShutdown", "GracefulRestart", "ForceRestart", "Nmi", "ForceOn", + "PushPowerButton", "PowerCycle", "Suspend", "Pause", "Resume"}, + ) { + t.Error("System.Actions does not match the expected value") + } // Managers if len(r.Managers) != 1 {