From a6ac6b61f13af4bb4fd00fb6bc05858aba2830b7 Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Thu, 2 May 2024 11:24:44 +0200 Subject: [PATCH] supermicro/x12: use maps for OEM parameters and add X12SPO-NTF BIOS params --- providers/supermicro/x12.go | 81 +++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/providers/supermicro/x12.go b/providers/supermicro/x12.go index a48c0006..bcac7859 100644 --- a/providers/supermicro/x12.go +++ b/providers/supermicro/x12.go @@ -189,31 +189,50 @@ 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: + // 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) + } } -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, + } } func (c *x12) redfishParameters(component, targetODataID string) (*rfw.RedfishUpdateServiceParameters, error) { @@ -221,24 +240,16 @@ func (c *x12) redfishParameters(component, targetODataID string) (*rfw.RedfishUp oem := OEM{} + biosInstallParams, err := c.biosFwInstallParams() + if err != nil { + return nil, err + } + 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 case common.SlugBMC: - oem.Supermicro.BMC = &BMC{ - PreserveCfg: true, - PreserveSdr: true, - PreserveSsl: true, - } + oem.Supermicro.BMC = c.bmcFwInstallParams() default: return nil, errUnsupported } @@ -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,