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

supermicro/x12: support BIOS firmware updates on X12SPO-NTF #389

Merged
merged 1 commit into from
May 2, 2024
Merged
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
81 changes: 47 additions & 34 deletions providers/supermicro/x12.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,56 +189,67 @@
return slices.Contains(finalized, s)
}

// redfish OEM parameter structs
type BIOS struct {
PreserveME bool `json:"PreserveME"`
PreserveNVRAM bool `json:"PreserveNVRAM"`
PreserveSMBIOS bool `json:"PreserveSMBIOS"`
PreserveOA bool `json:"PreserveOA"`
PreserveSETUPCONF bool `json:"PreserveSETUPCONF"`
PreserveSETUPPWD bool `json:"PreserveSETUPPWD"`
PreserveSECBOOTKEY bool `json:"PreserveSECBOOTKEY"`
PreserveBOOTCONF bool `json:"PreserveBOOTCONF"`
type Supermicro struct {
BIOS map[string]bool `json:"BIOS,omitempty"`
BMC map[string]bool `json:"BMC,omitempty"`
}

type BMC struct {
PreserveCfg bool `json:"PreserveCfg"`
PreserveSdr bool `json:"PreserveSdr"`
PreserveSsl bool `json:"PreserveSsl"`
type OEM struct {
Supermicro `json:"Supermicro"`
}

type Supermicro struct {
*BIOS `json:"BIOS,omitempty"`
*BMC `json:"BMC,omitempty"`
// redfish OEM fw install parameters
func (c *x12) biosFwInstallParams() (map[string]bool, error) {
switch c.model {
case "x12spo-ntf":
return map[string]bool{
"PreserveME": false,
"PreserveNVRAM": false,
"PreserveSMBIOS": true,
"BackupBIOS": false,
"PreserveBOOTCONF": true,
}, nil
case "x12sth-sys":
return map[string]bool{
"PreserveME": false,
"PreserveNVRAM": false,
"PreserveSMBIOS": true,
"PreserveOA": true,
"PreserveSETUPCONF": true,
"PreserveSETUPPWD": true,
"PreserveSECBOOTKEY": true,
"PreserveBOOTCONF": true,
}, nil
default:

Check warning on line 223 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L202-L223

Added lines #L202 - L223 were not covered by tests
// ideally we never get in this position, since theres model number validation in parent callers.
return nil, errors.New("unsupported model for BIOS fw install: " + c.model)

Check warning on line 225 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L225

Added line #L225 was not covered by tests
}
}

type OEM struct {
Supermicro `json:"Supermicro"`
// redfish OEM fw install parameters
func (c *x12) bmcFwInstallParams() map[string]bool {
return map[string]bool{
"PreserveCfg": true,
"PreserveSdr": true,
"PreserveSsl": true,

Check warning on line 234 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L230-L234

Added lines #L230 - L234 were not covered by tests
}
}

func (c *x12) redfishParameters(component, targetODataID string) (*rfw.RedfishUpdateServiceParameters, error) {
errUnsupported := errors.New("redfish parameters for x12 hardware component not supported: " + component)

oem := OEM{}

biosInstallParams, err := c.biosFwInstallParams()
if err != nil {
return nil, err

Check warning on line 245 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L243-L245

Added lines #L243 - L245 were not covered by tests
}

switch strings.ToUpper(component) {
case common.SlugBIOS:
oem.Supermicro.BIOS = &BIOS{
PreserveME: false,
PreserveNVRAM: false,
PreserveSMBIOS: true,
PreserveOA: true,
PreserveSETUPCONF: true,
PreserveSETUPPWD: true,
PreserveSECBOOTKEY: true,
PreserveBOOTCONF: true,
}
oem.Supermicro.BIOS = biosInstallParams

Check warning on line 250 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L250

Added line #L250 was not covered by tests
case common.SlugBMC:
oem.Supermicro.BMC = &BMC{
PreserveCfg: true,
PreserveSdr: true,
PreserveSsl: true,
}
oem.Supermicro.BMC = c.bmcFwInstallParams()

Check warning on line 252 in providers/supermicro/x12.go

View check run for this annotation

Codecov / codecov/patch

providers/supermicro/x12.go#L252

Added line #L252 was not covered by tests
default:
return nil, errUnsupported
}
Expand All @@ -249,6 +260,8 @@
}

return &rfw.RedfishUpdateServiceParameters{
// NOTE:
// X12s support the OnReset Apply time for BIOS updates if we want to implement that in the future.
OperationApplyTime: constants.OnStartUpdateRequest,
Targets: []string{targetODataID},
Oem: b,
Expand Down
Loading