From 499447f1e281df2404dbdc1af5579f6e83c3727a Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Fri, 24 Nov 2023 12:19:34 +0100 Subject: [PATCH] WIP --- internal/redfishwrapper/power.go | 1 + providers/supermicro/supermicro.go | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/internal/redfishwrapper/power.go b/internal/redfishwrapper/power.go index 53d412c80..7e91b8e73 100644 --- a/internal/redfishwrapper/power.go +++ b/internal/redfishwrapper/power.go @@ -212,6 +212,7 @@ func (c *Client) SystemForceOff(ctx context.Context) (ok bool, err error) { system.DisableEtagMatch(c.disableEtagMatch) + err = system.Reset(rf.ForceOffResetType) if err != nil { return false, err diff --git a/providers/supermicro/supermicro.go b/providers/supermicro/supermicro.go index 6824fd731..016202215 100644 --- a/providers/supermicro/supermicro.go +++ b/providers/supermicro/supermicro.go @@ -115,7 +115,6 @@ type bmcQueryor interface { deviceModel() (model string) supportsInstall(component string) error inventory(ctx context.Context) (*common.Device, error) - powerSet(ctx context.Context, state string) (ok bool, err error) } // New returns connection with a Supermicro client initialized @@ -201,6 +200,10 @@ func (c *Client) PowerStateGet(ctx context.Context) (state string, err error) { // PowerSet sets the power state of a server func (c *Client) PowerSet(ctx context.Context, state string) (ok bool, err error) { + if c.serviceClient == nil || c.serviceClient.redfish == nil { + return false, errors.Wrap(bmclibErrs.ErrLoginFailed, "client not initialized") + } + return c.serviceClient.redfish.PowerSet(ctx, state) } @@ -359,16 +362,6 @@ func (c *Client) initScreenPreview(ctx context.Context) error { return nil } -// PowerSet sets the power state of a server -func (c *Client) PowerSet(ctx context.Context, state string) (ok bool, err error) { - switch strings.ToLower(state) { - case "cycle": - return c.powerCycle(ctx) - default: - return false, errors.New("action not implemented for provider") - } -} - type serviceClient struct { host string port string