From c10dccea0afaf3f129038ce52ebddff147488280 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Thu, 23 May 2024 16:42:10 -0400 Subject: [PATCH 1/4] dmidecode: Handle binary lookup like other utilities The github.com/dselans/dmidecode package has a static list of paths to look for the dmidecode binary when used with dmidecode.New, but we don't really do things like that here. For example maybe we want to pass in a different name/path for the binary via env var like we do for other tools. So this commit avoids dmidecode.New so that it can follow along with the pattern already in-use here. --- utils/dmidecode.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/utils/dmidecode.go b/utils/dmidecode.go index e05eac807..466eaf959 100644 --- a/utils/dmidecode.go +++ b/utils/dmidecode.go @@ -1,8 +1,10 @@ package utils import ( + "cmp" "context" "os" + "os/exec" "strings" "github.com/bmc-toolbox/common" @@ -12,24 +14,33 @@ import ( "github.com/pkg/errors" ) +const EnvDmidecodeUtility = "IRONLIB_UTIL_DMIDECODE" + type Dmidecode struct { dmi *dmidecode.DMI } func NewDmidecode() (d *Dmidecode, err error) { + utility := cmp.Or(os.Getenv(EnvDmidecodeUtility), "dmidecode") + dmi := dmidecode.New() + output, err := dmi.ExecDmidecode(utility) + if err != nil { + return nil, err + } - err = dmi.Run() + err = dmi.ParseDmidecode(output) if err != nil { - return d, err + return nil, err } - return &Dmidecode{dmi: dmi}, err + return &Dmidecode{dmi: dmi}, nil } // Attributes implements the actions.UtilAttributeGetter interface func (d *Dmidecode) Attributes() (utilName model.CollectorUtility, absolutePath string, err error) { - path, err := d.dmi.FindBin("dmidecode") + utility := cmp.Or(os.Getenv(EnvDmidecodeUtility), "dmidecode") + path, err := exec.LookPath(utility) return "dmidecode", path, err } From 32747524b1f027adf942d509a3aab6cf8aca7676 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Fri, 24 May 2024 13:22:26 -0400 Subject: [PATCH 2/4] model: Get rid of OemComponents This seems like the wrong layout for this functionality. Are we going to have to add a new member for every manufacturer that has OEM specific components? It doesn't really sound like a good idea. Instead we can lean on Hardware.Device.Vendor to have dell/$manufacturer and then any OEMComponents are _obviously_ for Dell/$manufacturer. --- fixtures/dell/r6515.go | 442 ++++++++++++++++++------------------ model/component.go | 5 - model/device.go | 2 +- providers/dell/dell.go | 4 +- providers/dell/dell_test.go | 4 +- 5 files changed, 224 insertions(+), 233 deletions(-) diff --git a/fixtures/dell/r6515.go b/fixtures/dell/r6515.go index 4a30a9132..4aebf495b 100644 --- a/fixtures/dell/r6515.go +++ b/fixtures/dell/r6515.go @@ -7,232 +7,228 @@ import ( // nolint:dupl,misspell,revive,stylecheck var ( - R6515_oem_components = &model.OemComponents{ - Dell: []*model.Component{ - { - Vendor: "dell", - Name: "BIOS", - Slug: "BIOS", - FirmwareInstalled: "1.7.4", - FirmwareManaged: true, - Oem: true, - }, - { - Vendor: "dell", - Name: "BOSS", - Slug: "Boss Adapter", - FirmwareInstalled: "2.5.13.3024", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Power Supply", - Slug: "Power-Supply", - FirmwareInstalled: "00.31.50", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Power Supply", - Slug: "Power-Supply", - FirmwareInstalled: "00.31.50", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Intel(R) Ethernet 25G 2P XXV710 Adapter", - Slug: "NIC", - FirmwareInstalled: "20.0.17", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Intel(R) Ethernet Network Adapter XXV710", - Slug: "NIC", - FirmwareInstalled: "20.0.17", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "SEP Firmware, BayID: 1", - Slug: "Non-Expander Storage Backplane (SEP)", - FirmwareInstalled: "4.35", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Firmware for - Disk 0 of BOSS Adapter", - Slug: "Boss Adapter - Disk 0", - FirmwareInstalled: "J004", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Firmware for - Disk 1 of BOSS Adapter", - Slug: "Boss Adapter - Disk 1", - FirmwareInstalled: "J004", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Dell HBA330 Mini Controller 0 Firmware", - Slug: "StorageController", - FirmwareInstalled: "16.17.01.00", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "iDRAC", - Slug: "BMC", - FirmwareInstalled: "4.40.00.00", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "NVMePCISSD Model Number: Micron_9300_MTFDHAL3T8TDP", - Slug: "Drive", - FirmwareInstalled: "11300DN0", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "NVMePCISSD Model Number: Micron_9300_MTFDHAL3T8TDP", - Slug: "Drive", - FirmwareInstalled: "11300DN0", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Lifecycle Controller", - Slug: "Lifecycle Controller", - FirmwareInstalled: "4.40.00.00", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Dell 64 Bit uEFI Diagnostics, version 4301, 4301A50, 4301.51", - Slug: "Dell 64 bit uEFI diagnostics", - FirmwareInstalled: "4301A50", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "OS COLLECTOR, v5.0, A00", - Slug: "OS Collector", - FirmwareInstalled: "5.0", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "Dell EMC iDRAC Service Module Embedded Package v3.5.1, A00", - Slug: "IDrac Service Module", - FirmwareInstalled: "3.5.1", - Oem: true, - FirmwareManaged: true, - }, - { - Vendor: "dell", - Name: "System CPLD", - Slug: "Dell System CPLD", - FirmwareInstalled: "1.0.3", - Oem: true, - FirmwareManaged: true, - }, + R6515_oem_components = []*model.Component{ + { + Vendor: "dell", + Name: "BIOS", + Slug: "BIOS", + FirmwareInstalled: "1.7.4", + FirmwareManaged: true, + Oem: true, + }, + { + Vendor: "dell", + Name: "BOSS", + Slug: "Boss Adapter", + FirmwareInstalled: "2.5.13.3024", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Power Supply", + Slug: "Power-Supply", + FirmwareInstalled: "00.31.50", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Power Supply", + Slug: "Power-Supply", + FirmwareInstalled: "00.31.50", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Intel(R) Ethernet 25G 2P XXV710 Adapter", + Slug: "NIC", + FirmwareInstalled: "20.0.17", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Intel(R) Ethernet Network Adapter XXV710", + Slug: "NIC", + FirmwareInstalled: "20.0.17", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "SEP Firmware, BayID: 1", + Slug: "Non-Expander Storage Backplane (SEP)", + FirmwareInstalled: "4.35", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Firmware for - Disk 0 of BOSS Adapter", + Slug: "Boss Adapter - Disk 0", + FirmwareInstalled: "J004", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Firmware for - Disk 1 of BOSS Adapter", + Slug: "Boss Adapter - Disk 1", + FirmwareInstalled: "J004", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Dell HBA330 Mini Controller 0 Firmware", + Slug: "StorageController", + FirmwareInstalled: "16.17.01.00", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "iDRAC", + Slug: "BMC", + FirmwareInstalled: "4.40.00.00", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "NVMePCISSD Model Number: Micron_9300_MTFDHAL3T8TDP", + Slug: "Drive", + FirmwareInstalled: "11300DN0", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "NVMePCISSD Model Number: Micron_9300_MTFDHAL3T8TDP", + Slug: "Drive", + FirmwareInstalled: "11300DN0", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Lifecycle Controller", + Slug: "Lifecycle Controller", + FirmwareInstalled: "4.40.00.00", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Dell 64 Bit uEFI Diagnostics, version 4301, 4301A50, 4301.51", + Slug: "Dell 64 bit uEFI diagnostics", + FirmwareInstalled: "4301A50", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "OS COLLECTOR, v5.0, A00", + Slug: "OS Collector", + FirmwareInstalled: "5.0", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "Dell EMC iDRAC Service Module Embedded Package v3.5.1, A00", + Slug: "IDrac Service Module", + FirmwareInstalled: "3.5.1", + Oem: true, + FirmwareManaged: true, + }, + { + Vendor: "dell", + Name: "System CPLD", + Slug: "Dell System CPLD", + FirmwareInstalled: "1.0.3", + Oem: true, + FirmwareManaged: true, }, } - R6515_OemComponents = &model.OemComponents{ - Dell: []*model.Component{ - { - Serial: "", - Vendor: "dell", - Type: "", - Model: "", - Name: "Dell HBA330 Mini Controller 0 Firmware", - Slug: "StorageController", - FirmwareInstalled: "", - FirmwareAvailable: "16.17.01.00", - Metadata: map[string]string{ - "firmware_available_filename": "SAS-Non-RAID_Firmware_124X2_LN_16.17.01.00_A08", - }, - Oem: true, - FirmwareManaged: true, - }, - { - Serial: "", - Vendor: "dell", - Type: "", - Model: "", - Name: "BOSS", - Slug: "Boss Adapter", - FirmwareInstalled: "", - FirmwareAvailable: "2.5.13.3024", - Metadata: map[string]string{ - "firmware_available_filename": "SAS-RAID_Firmware_3P39V_LN64_2.5.13.3024_A07", - }, - Oem: true, - FirmwareManaged: true, - }, - { - Serial: "", - Vendor: "dell", - Type: "", - Model: "", - Name: "BIOS", - Slug: "BIOS", - FirmwareInstalled: "", - FirmwareAvailable: "2.8.1", - Metadata: map[string]string{ - "firmware_available_filename": "BIOS_RTWM9_LN_2.8.1", - }, - Oem: true, - FirmwareManaged: true, - }, - { - Serial: "", - Vendor: "dell", - Type: "", - Model: "", - Name: "iDRAC", - Slug: "BMC", - FirmwareInstalled: "", - FirmwareAvailable: "4.22.00.00", - Metadata: map[string]string{ - "firmware_available_filename": "iDRAC-with-Lifecycle-Controller_Firmware_9F2TG_LN_4.22.00.00_A00", - }, - Oem: true, - FirmwareManaged: true, - }, - { - Serial: "", - Vendor: "dell", - Type: "", - Model: "", - Name: "Dell EMC iDRAC Service Module Embedded Package v3.5.0, A00", - Slug: "IDrac Service Module", - FirmwareInstalled: "", - FirmwareAvailable: "3.5.1", - Metadata: map[string]string{ - "firmware_available_filename": "Systems-Management_Application_1K45F_LN64_3.5.1_A00", - }, - Oem: true, - FirmwareManaged: true, - }, + R6515_OemComponents = []*model.Component{ + { + Serial: "", + Vendor: "dell", + Type: "", + Model: "", + Name: "Dell HBA330 Mini Controller 0 Firmware", + Slug: "StorageController", + FirmwareInstalled: "", + FirmwareAvailable: "16.17.01.00", + Metadata: map[string]string{ + "firmware_available_filename": "SAS-Non-RAID_Firmware_124X2_LN_16.17.01.00_A08", + }, + Oem: true, + FirmwareManaged: true, + }, + { + Serial: "", + Vendor: "dell", + Type: "", + Model: "", + Name: "BOSS", + Slug: "Boss Adapter", + FirmwareInstalled: "", + FirmwareAvailable: "2.5.13.3024", + Metadata: map[string]string{ + "firmware_available_filename": "SAS-RAID_Firmware_3P39V_LN64_2.5.13.3024_A07", + }, + Oem: true, + FirmwareManaged: true, + }, + { + Serial: "", + Vendor: "dell", + Type: "", + Model: "", + Name: "BIOS", + Slug: "BIOS", + FirmwareInstalled: "", + FirmwareAvailable: "2.8.1", + Metadata: map[string]string{ + "firmware_available_filename": "BIOS_RTWM9_LN_2.8.1", + }, + Oem: true, + FirmwareManaged: true, + }, + { + Serial: "", + Vendor: "dell", + Type: "", + Model: "", + Name: "iDRAC", + Slug: "BMC", + FirmwareInstalled: "", + FirmwareAvailable: "4.22.00.00", + Metadata: map[string]string{ + "firmware_available_filename": "iDRAC-with-Lifecycle-Controller_Firmware_9F2TG_LN_4.22.00.00_A00", + }, + Oem: true, + FirmwareManaged: true, + }, + { + Serial: "", + Vendor: "dell", + Type: "", + Model: "", + Name: "Dell EMC iDRAC Service Module Embedded Package v3.5.0, A00", + Slug: "IDrac Service Module", + FirmwareInstalled: "", + FirmwareAvailable: "3.5.1", + Metadata: map[string]string{ + "firmware_available_filename": "Systems-Management_Application_1K45F_LN64_3.5.1_A00", + }, + Oem: true, + FirmwareManaged: true, }, } diff --git a/model/component.go b/model/component.go index 5768268ec..1cb1d5b0c 100644 --- a/model/component.go +++ b/model/component.go @@ -31,11 +31,6 @@ type UpdateOptions struct { BaseURL string // The BaseURL for the updates } -// OemComponents are OEM specific device components -type OemComponents struct { - Dell []*Component `json:"dell"` -} - type CreateVirtualDiskOptions struct { RaidMode string PhysicalDiskIDs []uint diff --git a/model/device.go b/model/device.go index e829f64a0..23359da8c 100644 --- a/model/device.go +++ b/model/device.go @@ -8,7 +8,7 @@ type Hardware struct { UpdatesInstalled bool // set when updates were installed on the device UpdatesAvailable int // -1 == no update lookup as yet, 0 == no updates available, 1 == updates available Device *common.Device - OemComponents *OemComponents // OemComponents hold OEM specific components that may not show up in dmidecode/lshw and other collectors. + OEMComponents []*Component // OEMComponents hold OEM specific components that may not show up in dmidecode/lshw and other collectors. } // NewHardware returns the base Hardware struct that various providers inherit diff --git a/providers/dell/dell.go b/providers/dell/dell.go index e8ad82b7d..808665181 100644 --- a/providers/dell/dell.go +++ b/providers/dell/dell.go @@ -131,7 +131,7 @@ func (d *dell) GetInventoryOEM(ctx context.Context, _ *common.Device, options *m return err } - d.hw.OemComponents.Dell = append(d.hw.OemComponents.Dell, oemComponents...) + d.hw.OEMComponents = append(d.hw.OEMComponents, oemComponents...) return nil } @@ -156,7 +156,7 @@ func (d *dell) ListAvailableUpdates(ctx context.Context, options *model.UpdateOp d.logger.WithField("count", count).Info("component updates identified..") - d.hw.OemComponents.Dell = append(d.hw.OemComponents.Dell, oemUpdates...) + d.hw.OEMComponents = append(d.hw.OEMComponents, oemUpdates...) return d.hw.Device, nil } diff --git a/providers/dell/dell_test.go b/providers/dell/dell_test.go index e2442e0cb..e7360a978 100644 --- a/providers/dell/dell_test.go +++ b/providers/dell/dell_test.go @@ -27,7 +27,7 @@ func newFakeDellDevice(logger *logrus.Logger) *dell { device.Vendor = "dell" hardware := model.NewHardware(&device) - hardware.OemComponents = &model.OemComponents{Dell: []*model.Component{}} + hardware.OEMComponents = []*model.Component{} return &dell{ hw: hardware, @@ -96,7 +96,7 @@ func TestGetInventory(t *testing.T) { } assert.Equal(t, dellFixtures.R6515_inventory_lshw_smartctl, device) - assert.Equal(t, expectedOemComponents, dell.hw.OemComponents) + assert.Equal(t, expectedOemComponents, dell.hw.OEMComponents) } // Get inventory, not listing updates available From 1008bb41a8266a1c5c8d466a33e14ed90a410fa9 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Fri, 24 May 2024 14:56:55 -0400 Subject: [PATCH 3/4] Move provider specific stuff out of model/consts.go These do not belong in a generic package. --- model/consts.go | 65 ---------------------------------- model/supermicro/supermicro.go | 22 ------------ providers/dell/dell.go | 9 +++-- utils/dsu.go | 48 ++++++++++++++++++++++++- utils/dsu_test.go | 13 ++++--- utils/smc_sum.go | 24 +++++++++++-- 6 files changed, 80 insertions(+), 101 deletions(-) delete mode 100644 model/supermicro/supermicro.go diff --git a/model/consts.go b/model/consts.go index 94e1b2680..96eabd5ed 100644 --- a/model/consts.go +++ b/model/consts.go @@ -8,33 +8,6 @@ import ( // CollectorUtility is the name of a utility defined in utils/ type CollectorUtility string -const ( - // Dell specific component slugs - SlugDellSystemCPLD = "Dell System CPLD" - SlugDellBossAdapter = "Boss Adapter" - SlugDellIdracServiceModule = "IDrac Service Module" - SlugDellBossAdapterDisk0 = "Boss Adapter - Disk 0" - SlugDellBossAdapterDisk1 = "Boss Adapter - Disk 1" - SlugDellLifeCycleController = "Lifecycle Controller" - SlugDellOSCollector = "OS Collector" - SlugDell64bitUefiDiagnostics = "Dell 64 bit uEFI diagnostics" - SlugDellBackplaneExpander = "Backplane-Expander" - SlugDellNonExpanderStorageBackplane = "Non-Expander Storage Backplane (SEP)" - - // EnvDellDSURelease is the Dell DSU release version - // - // e.g: 21.11.12 from https://linux.dell.com/repo/hardware/DSU_21.11.12/ - EnvDellDSURelease = "DELL_DSU_RELEASE" - // EnvDellDSUVersion is the Dell DSU utility package version - // - // e.g: 1.9.2.0-21.07.00 from https://linux.dell.com/repo/hardware/DSU_21.11.12/os_independent/x86_64/dell-system-update-1.9.2.0-21.07.00.x86_64.rpm - EnvDellDSUVersion = "DELL_DSU_VERSION" - // EnvDNFDisableGPGCheck disables GPG checks in DNF package installs - EnvDNFDellDisableGPGCheck = "DNF_DISABLE_GPG_CHECK" - // EnvUpdateStoreURL defines up the update store base URL prefix - EnvUpdateBaseURL = "UPDATE_BASE_URL" -) - // UpdateReleaseEnvironments is the list of update environments // this is related to the fup tooling func UpdateReleaseEnvironments() []string { @@ -59,44 +32,6 @@ var ( "HGST HUS728T8TALE6L4": common.SlugDriveTypeSATAHDD, } - // OemComponentDell is a lookup table for dell OEM components - // these components are specific to the OEMs - in this case Dell - OemComponentDell = map[string]struct{}{ - SlugDellSystemCPLD: {}, - common.SlugBackplaneExpander: {}, - SlugDellIdracServiceModule: {}, - SlugDellBossAdapterDisk0: {}, - SlugDellBossAdapterDisk1: {}, - SlugDellBossAdapter: {}, - SlugDellLifeCycleController: {}, - SlugDellNonExpanderStorageBackplane: {}, - SlugDellOSCollector: {}, - SlugDell64bitUefiDiagnostics: {}, - } - - // DellComponentSlug is an ordered list of dell component identifiers to component slug - // To identify components correctly, if two components contain a similar string - // e.g: "idrac", "dell emc idrac service module" the latter should be positioned before the former in the list. - DellComponentSlug = [][]string{ - {"bios", common.SlugBIOS}, - {"ethernet", common.SlugNIC}, - {"dell emc idrac service module", SlugDellIdracServiceModule}, - {"idrac", common.SlugBMC}, - {"backplane", common.SlugBackplaneExpander}, - {"power supply", common.SlugPSU}, - {"hba330", common.SlugStorageController}, - {"nvmepcissd", common.SlugDrive}, - {"system cpld", SlugDellSystemCPLD}, - {"sep firmware", SlugDellNonExpanderStorageBackplane}, - {"lifecycle controller", SlugDellLifeCycleController}, - {"os collector", SlugDellOSCollector}, - {"disk 0 of boss adapter", SlugDellBossAdapterDisk0}, - {"disk 1 of boss adapter", SlugDellBossAdapterDisk1}, - {"boss", SlugDellBossAdapter}, - {"dell 64 bit uefi diagnostics", SlugDell64bitUefiDiagnostics}, - {"integrated dell remote access controller", common.SlugBMC}, - } - ErrTypeComponentFirmware = errors.New("ironlib.GetComponentFirmware() was passed an object type which is not handled") ) diff --git a/model/supermicro/supermicro.go b/model/supermicro/supermicro.go deleted file mode 100644 index 3dee97152..000000000 --- a/model/supermicro/supermicro.go +++ /dev/null @@ -1,22 +0,0 @@ -package supermicro - -import "encoding/xml" - -type BiosCfg struct { - XMLName xml.Name `xml:"BiosCfg"` - Text string `xml:",chardata"` - Menu []*Menu `xml:"Menu,omitempty"` -} - -type Menu struct { - Name string `xml:"name,attr"` - Setting []*Setting `xml:"Setting,omitempty"` - Menu []*Menu `xml:"Menu,omitempty"` -} - -type Setting struct { - Name string `xml:"name,attr"` - Type string `xml:"type,attr"` - SelectedOption string `xml:"selectedOption,attr,omitempty"` - CheckedStatus string `xml:"checkedStatus,attr,omitempty"` -} diff --git a/providers/dell/dell.go b/providers/dell/dell.go index 808665181..9f25321a9 100644 --- a/providers/dell/dell.go +++ b/providers/dell/dell.go @@ -13,6 +13,9 @@ import ( "github.com/sirupsen/logrus" ) +// EnvUpdateStoreURL defines up the update store base URL prefix +const EnvUpdateBaseURL = "UPDATE_BASE_URL" + // The dell device provider struct type dell struct { DsuPrequisitesInstalled bool @@ -58,19 +61,19 @@ func New(dmidecode *utils.Dmidecode, l *logrus.Logger) (actions.DeviceManager, e // when default, the repo URL will point to the default repository // this expects a EnvUpdateStoreURL/dell/default/ is made available - dsuReleaseVersion := os.Getenv(model.EnvDellDSURelease) + dsuReleaseVersion := os.Getenv(utils.EnvDellDSURelease) if dsuReleaseVersion == "" { dsuReleaseVersion = "default" } // when default, whichever version of DSU is available will be installed - dsuPackageVersion := os.Getenv(model.EnvDellDSUVersion) + dsuPackageVersion := os.Getenv(utils.EnvDellDSUVersion) if dsuPackageVersion == "" { dsuPackageVersion = "default" } // the base url for updates - updateBaseURL := os.Getenv(model.EnvUpdateBaseURL) + updateBaseURL := os.Getenv(EnvUpdateBaseURL) // set device manager trace := l.Level >= logrus.TraceLevel diff --git a/utils/dsu.go b/utils/dsu.go index 4d0068ecc..16def03b6 100644 --- a/utils/dsu.go +++ b/utils/dsu.go @@ -10,6 +10,7 @@ import ( "regexp" "strings" + "github.com/bmc-toolbox/common" "github.com/metal-toolbox/ironlib/errs" "github.com/metal-toolbox/ironlib/model" "github.com/pkg/errors" @@ -25,11 +26,56 @@ const ( DSUExitCodeRebootRequired = 8 DSUExitCodeNoUpdatesAvailable = 34 + // Dell specific component slugs + slugDellSystemCPLD = "Dell System CPLD" + slugDellBossAdapter = "Boss Adapter" + slugDellBossAdapterDisk0 = "Boss Adapter - Disk 0" + slugDellBossAdapterDisk1 = "Boss Adapter - Disk 1" + slugDellIdracServiceModule = "IDrac Service Module" + slugDellLifeCycleController = "Lifecycle Controller" + slugDellOSCollector = "OS Collector" + slugDell64bitUefiDiagnostics = "Dell 64 bit uEFI diagnostics" + slugDellBackplaneExpander = "Backplane-Expander" + slugDellNonExpanderStorageBackplane = "Non-Expander Storage Backplane (SEP)" + + // EnvDellDSURelease is the Dell DSU release version + // + // e.g: 21.11.12 from https://linux.dell.com/repo/hardware/DSU_21.11.12/ + EnvDellDSURelease = "DELL_DSU_RELEASE" + + // EnvDellDSUVersion is the Dell DSU utility package version + // + // e.g: 1.9.2.0-21.07.00 from https://linux.dell.com/repo/hardware/DSU_21.11.12/os_independent/x86_64/dell-system-update-1.9.2.0-21.07.00.x86_64.rpm + EnvDellDSUVersion = "DELL_DSU_VERSION" + LocalUpdatesDirectory = "/root/dsu" EnvDsuUtility = "IRONLIB_UTIL_DSU" ) +// DellComponentSlug is an ordered list of dell component identifiers to component slug +// To identify components correctly, if two components contain a similar string +// e.g: "idrac", "dell emc idrac service module" the latter should be positioned before the former in the list. +var dellComponentSlug = [][]string{ + {"bios", common.SlugBIOS}, + {"ethernet", common.SlugNIC}, + {"dell emc idrac service module", slugDellIdracServiceModule}, + {"idrac", common.SlugBMC}, + {"backplane", common.SlugBackplaneExpander}, + {"power supply", common.SlugPSU}, + {"hba330", common.SlugStorageController}, + {"nvmepcissd", common.SlugDrive}, + {"system cpld", slugDellSystemCPLD}, + {"sep firmware", slugDellNonExpanderStorageBackplane}, + {"lifecycle controller", slugDellLifeCycleController}, + {"os collector", slugDellOSCollector}, + {"disk 0 of boss adapter", slugDellBossAdapterDisk0}, + {"disk 1 of boss adapter", slugDellBossAdapterDisk1}, + {"boss", slugDellBossAdapter}, + {"dell 64 bit uefi diagnostics", slugDell64bitUefiDiagnostics}, + {"integrated dell remote access controller", common.SlugBMC}, +} + var ( ErrDsuInventoryCollectorBinMissing = errors.New("dsu inventory collector executable missing 'invcol_*_*.BIN'") ErrMultipleDsuInventoryCollectorBins = errors.New("multiple inventory collector bins found") @@ -282,7 +328,7 @@ func findDSUInventoryCollector(path string) []string { func dsuComponentNameToSlug(n string) string { componentName := strings.ToLower(n) - for _, componentSlug := range model.DellComponentSlug { + for _, componentSlug := range dellComponentSlug { identifier, slug := componentSlug[0], componentSlug[1] if strings.EqualFold(componentName, identifier) { return slug diff --git a/utils/dsu_test.go b/utils/dsu_test.go index f3e5e0195..c6c879165 100644 --- a/utils/dsu_test.go +++ b/utils/dsu_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/bmc-toolbox/common" - "github.com/metal-toolbox/ironlib/model" "github.com/stretchr/testify/assert" ) @@ -15,18 +14,18 @@ func Test_dsuComponentNameToSlug(t *testing.T) { kv := map[string]string{ "BIOS": common.SlugBIOS, "Power Supply": common.SlugPSU, - "Disk 0 of BOSS Adapter ": model.SlugDellBossAdapterDisk0, - "BOSS": model.SlugDellBossAdapter, + "Disk 0 of BOSS Adapter ": slugDellBossAdapterDisk0, + "BOSS": slugDellBossAdapter, "Dell HBA330 Mini Controller 0 Firmware ": common.SlugStorageController, - "Backplane Expander FW ": model.SlugDellBackplaneExpander, + "Backplane Expander FW ": slugDellBackplaneExpander, "Intel(R) Ethernet 10G 4P X710 SFP+ rNDC": common.SlugNIC, "Intel(R) Ethernet 10G X710 rNDC ": common.SlugNIC, "Intel(R) Ethernet 10G X710 rNDC": common.SlugNIC, "iDRAC": common.SlugBMC, "NVMePCISSD Model Number: Micron_9200_MTFDHAL3T8TCT": common.SlugDrive, - "Lifecycle Controller": model.SlugDellLifeCycleController, - "System CPLD": model.SlugDellSystemCPLD, - "Dell EMC iDRAC Service Module Embedded Package v3.5.0, A00": model.SlugDellIdracServiceModule, + "Lifecycle Controller": slugDellLifeCycleController, + "System CPLD": slugDellSystemCPLD, + "Dell EMC iDRAC Service Module Embedded Package v3.5.0, A00": slugDellIdracServiceModule, } for componentName, expectedSlug := range kv { diff --git a/utils/smc_sum.go b/utils/smc_sum.go index d13b1ce64..1f1e53557 100644 --- a/utils/smc_sum.go +++ b/utils/smc_sum.go @@ -10,12 +10,30 @@ import ( "github.com/bmc-toolbox/common" "github.com/metal-toolbox/ironlib/model" - "github.com/metal-toolbox/ironlib/model/supermicro" "golang.org/x/net/html/charset" ) const EnvVarSumPath = "IRONLIB_UTIL_SUM" +type biosCfg struct { + XMLName xml.Name `xml:"BiosCfg"` + Text string `xml:",chardata"` + Menu []*menu `xml:"Menu,omitempty"` +} + +type menu struct { + Name string `xml:"name,attr"` + Setting []*setting `xml:"Setting,omitempty"` + Menu []*menu `xml:"Menu,omitempty"` +} + +type setting struct { + Name string `xml:"name,attr"` + Type string `xml:"type,attr"` + SelectedOption string `xml:"selectedOption,attr,omitempty"` + CheckedStatus string `xml:"checkedStatus,attr,omitempty"` +} + type SupermicroSUM struct { Executor Executor } @@ -134,7 +152,7 @@ func (s *SupermicroSUM) parseBIOSConfig(ctx context.Context) (map[string]string, return nil, newExecError(s.Executor.GetCmd(), result) } - cfg := &supermicro.BiosCfg{} + cfg := &biosCfg{} // the xml exported by sum is ISO-8859-1 encoded decoder := xml.NewDecoder(bytes.NewReader(result.Stdout)) @@ -153,7 +171,7 @@ func (s *SupermicroSUM) parseBIOSConfig(ctx context.Context) (map[string]string, } // recurseMenus recurses through SMC BIOS menu options and gathers all settings with a selected option -func (s *SupermicroSUM) recurseMenus(menus []*supermicro.Menu, kv map[string]string) { +func (s *SupermicroSUM) recurseMenus(menus []*menu, kv map[string]string) { for _, menu := range menus { for _, s := range menu.Setting { s.Name = strings.TrimSpace(s.Name) From db22bd9e346c5013df06e627735d115bf2cc1c2f Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Fri, 24 May 2024 15:02:40 -0400 Subject: [PATCH 4/4] Delete unused UpdateReleaseEnvironments Not used in this code base nor any I could find in GitHub and also fup is no longer actively used. --- model/consts.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/model/consts.go b/model/consts.go index 96eabd5ed..429bfa35d 100644 --- a/model/consts.go +++ b/model/consts.go @@ -8,12 +8,6 @@ import ( // CollectorUtility is the name of a utility defined in utils/ type CollectorUtility string -// UpdateReleaseEnvironments is the list of update environments -// this is related to the fup tooling -func UpdateReleaseEnvironments() []string { - return []string{"production", "canary", "vanguard"} -} - var ( // ModelDriveTypeSlug is a map of drive models number to slug