Skip to content

Commit

Permalink
Move provider specific stuff out of model/consts.go
Browse files Browse the repository at this point in the history
These do not belong in a generic package.
  • Loading branch information
mmlb committed May 24, 2024
1 parent 3274752 commit 1008bb4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 101 deletions.
65 changes: 0 additions & 65 deletions model/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
)

Expand Down
22 changes: 0 additions & 22 deletions model/supermicro/supermicro.go

This file was deleted.

9 changes: 6 additions & 3 deletions providers/dell/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
48 changes: 47 additions & 1 deletion utils/dsu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions utils/dsu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ import (
"testing"

"github.com/bmc-toolbox/common"
"github.com/metal-toolbox/ironlib/model"
"github.com/stretchr/testify/assert"
)

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 {
Expand Down
24 changes: 21 additions & 3 deletions utils/smc_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down

0 comments on commit 1008bb4

Please sign in to comment.