Skip to content

Commit

Permalink
supermicro/x12: use maps for OEM parameters and add X12SPO-NTF BIOS p…
Browse files Browse the repository at this point in the history
…arams
  • Loading branch information
joelrebel committed May 2, 2024
1 parent 5b1e472 commit a6ac6b6
Showing 1 changed file with 47 additions and 34 deletions.
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 @@ func stateFinalized(s redfish.TaskState) bool {
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 @@ func (c *x12) redfishParameters(component, targetODataID string) (*rfw.RedfishUp
}

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

0 comments on commit a6ac6b6

Please sign in to comment.