Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMS-1259; Add basic FeatureSetBiosConfigurationFromFile support for Dell #14

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/redfishwrapper/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (c *Client) SetBiosConfiguration(ctx context.Context, biosConfig map[string

// TODO(jwb) We should handle passing different apply times here
err = bios.UpdateBiosAttributesApplyAt(settingsAttributes, common.OnResetApplyTime)

if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions providers/dell/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// bmc client interface implementations methods
func (c *Conn) FirmwareInstallSteps(ctx context.Context, component string) ([]constants.FirmwareInstallStep, error) {
if err := c.deviceSupported(ctx); err != nil {
if err := c.deviceSupported(); err != nil {
return nil, bmcliberrs.NewErrUnsupportedHardware(err.Error())
}

Expand All @@ -30,7 +30,7 @@ func (c *Conn) FirmwareInstallSteps(ctx context.Context, component string) ([]co
}

func (c *Conn) FirmwareInstallUploadAndInitiate(ctx context.Context, component string, file *os.File) (taskID string, err error) {
if err := c.deviceSupported(ctx); err != nil {
if err := c.deviceSupported(); err != nil {
return "", bmcliberrs.NewErrUnsupportedHardware(err.Error())
}

Expand Down Expand Up @@ -97,7 +97,7 @@ func (c *Conn) checkQueueability(component string, tasks []*redfish.Task) error

// FirmwareTaskStatus returns the status of a firmware related task queued on the BMC.
func (c *Conn) FirmwareTaskStatus(ctx context.Context, kind constants.FirmwareInstallStep, component, taskID, installVersion string) (state constants.TaskState, status string, err error) {
if err := c.deviceSupported(ctx); err != nil {
if err := c.deviceSupported(); err != nil {
return "", "", bmcliberrs.NewErrUnsupportedHardware(err.Error())
}

Expand Down
20 changes: 16 additions & 4 deletions providers/dell/idrac.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
providers.FeatureBmcReset,
providers.FeatureGetBiosConfiguration,
providers.FeatureSetBiosConfiguration,
providers.FeatureSetBiosConfigurationFromFile,
providers.FeatureResetBiosConfiguration,
}

Expand Down Expand Up @@ -134,7 +135,7 @@ func (c *Conn) Open(ctx context.Context) (err error) {

// because this uses the redfish interface and the redfish interface
// is available across various BMC vendors, we verify the device we're connected to is dell.
if err := c.deviceSupported(ctx); err != nil {
if err := c.deviceSupported(); err != nil {
if er := c.redfishwrapper.Close(ctx); er != nil {
return fmt.Errorf("%v: %w", err, er)
}
Expand All @@ -145,8 +146,8 @@ func (c *Conn) Open(ctx context.Context) (err error) {
return nil
}

func (c *Conn) deviceSupported(ctx context.Context) error {
manufacturer, err := c.deviceManufacturer(ctx)
func (c *Conn) deviceSupported() error {
manufacturer, err := c.deviceManufacturer()
if err != nil {
return err
}
Expand Down Expand Up @@ -232,6 +233,17 @@ func (c *Conn) SetBiosConfiguration(ctx context.Context, biosConfig map[string]s
return c.redfishwrapper.SetBiosConfiguration(ctx, biosConfig)
}

// SetBiosConfigurationFromFile sets the bios configuration from a raw vendor config file
func (c *Conn) SetBiosConfigurationFromFile(ctx context.Context, biosConfg string) (err error) {
configMap := make(map[string]string)
err = json.Unmarshal([]byte(biosConfg), &configMap)
if err != nil {
return errors.Wrap(err, "failed to unmarshal config file")
}

return c.redfishwrapper.SetBiosConfiguration(ctx, configMap)
}

// ResetBiosConfiguration resets the BIOS configuration settings back to 'factory defaults' via the BMC
func (c *Conn) ResetBiosConfiguration(ctx context.Context) (err error) {
return c.redfishwrapper.ResetBiosConfiguration(ctx)
Expand All @@ -243,7 +255,7 @@ func (c *Conn) SendNMI(ctx context.Context) error {
}

// deviceManufacturer returns the device manufacturer and model attributes
func (c *Conn) deviceManufacturer(ctx context.Context) (vendor string, err error) {
func (c *Conn) deviceManufacturer() (vendor string, err error) {
systems, err := c.redfishwrapper.Systems()
if err != nil {
return "", errors.Wrap(errManufacturerUnknown, err.Error())
Expand Down