Skip to content

Commit

Permalink
openbmc, supermicro: implement BMCResetter interface
Browse files Browse the repository at this point in the history
This makes sure when the provider is pinned/filtered* the BmcReset method is
available.

* https://github.com/bmc-toolbox/bmclib#one-time-filtering
  • Loading branch information
joelrebel committed Dec 6, 2023
1 parent 4d960aa commit 91cfd91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions providers/openbmc/openbmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
Features = registrar.Features{
providers.FeaturePowerState,
providers.FeaturePowerSet,
providers.FeatureBmcReset,
providers.FeatureFirmwareInstallSteps,
providers.FeatureFirmwareUploadInitiateInstall,
providers.FeatureFirmwareTaskStatus,
Expand Down Expand Up @@ -178,3 +179,8 @@ func (c *Conn) PowerSet(ctx context.Context, state string) (ok bool, err error)
func (c *Conn) Inventory(ctx context.Context) (device *common.Device, err error) {
return c.redfishwrapper.Inventory(ctx, false)
}

// BmcReset power cycles the BMC
func (c *Conn) BmcReset(ctx context.Context, resetType string) (ok bool, err error) {
return c.redfishwrapper.BMCReset(ctx, resetType)
}
10 changes: 10 additions & 0 deletions providers/supermicro/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
providers.FeatureInventoryRead,
providers.FeaturePowerSet,
providers.FeaturePowerState,
providers.FeatureBmcReset,
}
)

Expand Down Expand Up @@ -210,6 +211,15 @@ func (c *Client) PowerSet(ctx context.Context, state string) (ok bool, err error
return c.serviceClient.redfish.PowerSet(ctx, state)
}

// BmcReset power cycles the BMC
func (c *Client) BmcReset(ctx context.Context, resetType string) (ok bool, err error) {
if c.serviceClient == nil || c.serviceClient.redfish == nil {
return false, errors.Wrap(bmclibErrs.ErrLoginFailed, "client not initialized")

Check warning on line 217 in providers/supermicro/supermicro.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/supermicro.go#L215-L217

Added lines #L215 - L217 were not covered by tests
}

return c.serviceClient.redfish.BMCReset(ctx, resetType)

Check warning on line 220 in providers/supermicro/supermicro.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/supermicro.go#L220

Added line #L220 was not covered by tests
}

// Inventory collects hardware inventory and install firmware information
func (c *Client) Inventory(ctx context.Context) (device *common.Device, err error) {
if c.serviceClient == nil || c.serviceClient.redfish == nil {
Expand Down

0 comments on commit 91cfd91

Please sign in to comment.