From 8f4600993dc3ad5a3f3da6daf607ebce922502f4 Mon Sep 17 00:00:00 2001 From: Manuel Mendez <708570+mmlb@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:38:03 -0400 Subject: [PATCH] House/spring cleaning (#128) * Use go-version-file in setup-go This way we do not need to keep these files sync'd. * Update go version Latest == greatest! * Use go run to run expected golangci-lint version Easier to just do what we want. * Update to golangci-lint v1.57 * Run through gofumpt and gci These are going to be enabled in the next commit when we switch to the .golangci.yml from metal-toolbox/golangci-lint-config. Better to do it before since it'll make the diff in that commit more meaningful. * Update .golangci.yml from metal-toolbox/golangci-lint-config And fix the errors of course, gotta keep CI green! Most of the class of changes are pretty small. The big one here is from contextcheck which definitely is correct that we should pass context.Context from calling functions down to called functions when the called function is using a context.Context. The question is are we *sure* we want to tie those function calls deep down with the top level context.Context? These all seem like the answer is yes which is why I did them, but will need to make sure reviewers are aware and take a good look. * Update codeql workflow Straight copy/paste from mctl. --- .github/workflows/codeql-analysis.yml | 11 +- .github/workflows/push-pr-lint.yaml | 10 +- .golangci.yml | 172 ++--- Dockerfile | 2 +- Makefile | 5 +- actions/inventory.go | 42 +- actions/storage_controller.go | 4 +- examples/firmware-install/firmware-install.go | 1 - firmware/bios_checksum.go | 27 +- fixtures/asrr/e3c246d4i-nl.go | 302 ++++---- fixtures/dell/r6515.go | 656 ++++++++--------- fixtures/supermicro/x11dph-t.go | 658 +++++++++--------- go.mod | 2 +- model/consts.go | 2 +- providers/asrockrack/asrockrack.go | 8 +- providers/asrockrack/bios.go | 2 +- providers/dell/bios.go | 6 +- providers/dell/dell.go | 10 +- providers/dell/dell_test.go | 19 +- providers/dell/helpers.go | 30 +- providers/supermicro/bios.go | 2 +- providers/supermicro/supermicro.go | 6 +- utils/asrr_bioscontrol.go | 26 +- utils/dell_racadm.go | 18 +- utils/dell_racadm_test.go | 3 +- utils/dmidecode.go | 4 +- utils/dnf.go | 5 +- utils/dsu.go | 16 +- utils/executor.go | 2 +- utils/fake_executor.go | 4 +- utils/hdparm_test.go | 546 ++++++++------- utils/lsblk_test.go | 70 +- utils/lshw.go | 14 +- utils/lshw_test.go | 1 - utils/mlxup.go | 8 +- utils/msecli.go | 14 +- utils/msecli_test.go | 4 +- utils/mvcli.go | 13 +- utils/nvme.go | 6 +- utils/nvme_test.go | 112 +-- utils/smartctl.go | 38 +- utils/smartctl_test.go | 10 +- utils/smc_ipmicfg.go | 12 +- utils/smc_sum_test.go | 3 +- utils/storecli.go | 8 +- utils/uefi_vars.go | 8 +- 46 files changed, 1457 insertions(+), 1465 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8fe5dc9b..bf975f65 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -40,6 +40,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 @@ -48,11 +53,11 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild @@ -61,7 +66,7 @@ jobs: # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. + # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | diff --git a/.github/workflows/push-pr-lint.yaml b/.github/workflows/push-pr-lint.yaml index 461cbae9..b4edfe69 100644 --- a/.github/workflows/push-pr-lint.yaml +++ b/.github/workflows/push-pr-lint.yaml @@ -5,19 +5,19 @@ jobs: lint-test: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Go uses: actions/setup-go@v4 with: - go-version: '^1.19' - - - name: Checkout code - uses: actions/checkout@v4 + go-version-file: go.mod - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: args: --config .golangci.yml - version: v1.55.2 + version: v1.57 - name: Test run: go test ./... diff --git a/.golangci.yml b/.golangci.yml index 8276cd44..81124681 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,123 +1,93 @@ +# +# This file lives in the github.com/metal-toolbox/golangci-lint-config repo. +# +# Do not edit this file outside of this repo otherwise we will be grumpy. +# Seriously though, this is meant to help promote a "standard" config and coding style. +# If you don't like something, lets have a discussion in GitHub issues! +# + linters-settings: - govet: - # TODO: enable and fix struct alignments - #enable: - # - fieldalignment - check-shadowing: true - settings: - printf: - funcs: - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - golint: - min-confidence: 0 - gocyclo: - min-complexity: 10 - maligned: - suggest-new: true dupl: - threshold: 100 + threshold: 125 goconst: min-len: 2 min-occurrences: 2 - depguard: - list-type: blacklist - packages: - # logging is allowed only by logutils.Log, logrus - # is allowed to use only in logutils package - - github.com/sirupsen/logrus - misspell: - locale: US - auto-fix: true - lll: - line-length: 140 - goimports: - local-prefixes: github.com/golangci/golangci-lint gocritic: enabled-tags: + - experimental - performance - style - - experimental disabled-checks: + - whyNoLint - wrapperFunc + gocyclo: + min-complexity: 15 gofumpt: extra-rules: true + govet: + enable: + - shadow + lll: + line-length: 140 + misspell: + locale: US + revive: + confidence: 0 linters: - enable: - - errcheck - - gosimple - - govet - - gofmt - - gocyclo - - ineffassign - - stylecheck - - misspell - - staticcheck - - unused - - prealloc - - typecheck - # XXX: add me back! - revive - # additional linters - - bodyclose - - gocritic - - goerr113 - - goimports + enable-all: true + disable-all: false + # Linters we don't like + # Comments help explain why its disabled or point at ones we should not disable but will take a little work + # If its not commented its likely because its just too annoying or we don't find useful + disable: + - copyloopvar # requires go >=1.22 + - cyclop + - deadcode # deprecated + - depguard + - errname # maybe should be enabled + - exhaustivestruct # deprecated + - exhaustruct + - forbidigo + - funlen + - gochecknoglobals + - gochecknoinits + - gocognit + - goconst + - godot + - godox + - golint # deprecated - gomnd - - misspell - - noctx - - stylecheck - - whitespace - enable-all: false - disable-all: true - -run: - build-tags: - - gingonic - skip-dirs: - - scripts - - docker - - samples - #modules-download-mode: vendor + - ifshort # deprecated + - inamedparam + - interfacebloat + - interfacer # deprecated + - intrange # requires go >=1.22 + - ireturn # should be enabled, ironlib needs some changes + - lll # not previously enabled, ironlib and mctl both fail this + - maligned # deprecated + - nestif + - nilnil + - nlreturn + - nolintlint + - nonamedreturns # should be enabled, probably + - nosnakecase # deprecated + - paralleltest + - perfsprint + - scopelint # deprecated + - structcheck # deprecated + - tagliatelle + - tenv # should be enabled + - testpackage + - testifylint # should be enabled + - thelper # should be enabled + - varcheck # deprecated + - varnamelen + - wrapcheck + - wsl issues: exclude-rules: - - linters: - - gosec - text: "weak cryptographic primitive" - - linters: - stylecheck text: "ST1016" - exclude: - # Default excludes from `golangci-lint run --help` with EXC0002 removed - # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok - - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked - # EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments - # - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) - # EXC0003 golint: False positive when tests are defined in package 'test' - - func name will be used as test\.Test.* by other packages, and that stutters; consider calling this - # EXC0004 govet: Common false positives - - (possible misuse of unsafe.Pointer|should have signature) - # EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore - - ineffective break statement. Did you mean to break out of the outer loop - # EXC0006 gosec: Too many false-positives on 'unsafe' usage - - Use of unsafe calls should be audited - # EXC0007 gosec: Too many false-positives for parametrized shell calls - - Subprocess launch(ed with variable|ing should be audited) - # EXC0008 gosec: Duplicated errcheck checks - - (G104|G307) - # EXC0009 gosec: Too many issues in popular repos - - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less) - # EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)' - - Potential file inclusion via variable -exclude-use-default: false - -# golangci.com configuration -# https://github.com/golangci/golangci/wiki/Configuration -#service: -# golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly -# prepare: -# - echo "here I can run custom commands, but no preparation needed for this repo" diff --git a/Dockerfile b/Dockerfile index 6be4a75a..80c6235e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build ironlib wrapper binaries -FROM golang:1.20-alpine AS stage0 +FROM golang:1.22-alpine AS stage0 WORKDIR /workspace diff --git a/Makefile b/Makefile index 158056a0..657228cf 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ -LINTER_EXPECTED_VERSION := "1.55.2" - .DEFAULT_GOAL := help ## lint lint: - (golangci-lint --version | grep -q "${LINTER_EXPECTED_VERSION}" && golangci-lint run --config .golangci.yml) \ - || echo "expected linter version: ${LINTER_EXPECTED_VERSION}" + go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57 run --config .golangci.yml ## Go test test: lint diff --git a/actions/inventory.go b/actions/inventory.go index d06c56c2..76ab4a86 100644 --- a/actions/inventory.go +++ b/actions/inventory.go @@ -8,14 +8,13 @@ import ( "strings" "github.com/bmc-toolbox/common" + "github.com/metal-toolbox/ironlib/firmware" + "github.com/metal-toolbox/ironlib/model" + "github.com/metal-toolbox/ironlib/utils" "github.com/pkg/errors" "github.com/r3labs/diff/v2" "github.com/sirupsen/logrus" "golang.org/x/exp/slices" - - "github.com/metal-toolbox/ironlib/firmware" - "github.com/metal-toolbox/ironlib/model" - "github.com/metal-toolbox/ironlib/utils" ) var ( @@ -877,6 +876,7 @@ func (a *InventoryCollectorAction) vetChanges(changes diff.Changelog) diff.Chang for _, change := range changes { // Skip changes that delete items + change := change if a.acceptChange(&change) { accepted = append(accepted, change) } @@ -904,28 +904,54 @@ func (a *InventoryCollectorAction) acceptChange(change *diff.Change) bool { func (a *InventoryCollectorAction) vetUpdate(change *diff.Change) bool { // allow vendor, model field changes only if the older value was not defined if slices.Contains(change.Path, "Vendor") || slices.Contains(change.Path, "Model") { - if strings.TrimSpace(change.To.(string)) != "" && strings.TrimSpace(change.From.(string)) == "" { + from, ok := change.From.(string) + if !ok { + return false + } + to, ok := change.To.(string) + if !ok { + return false + } + if strings.TrimSpace(to) != "" && strings.TrimSpace(from) == "" { return true } } // accept description if its longer than the older value if slices.Contains(change.Path, "Description") { - if len(strings.TrimSpace(change.To.(string))) > len(strings.TrimSpace(change.From.(string))) { + from, ok := change.From.(string) + if !ok { + return false + } + to, ok := change.To.(string) + if !ok { + return false + } + + if len(strings.TrimSpace(to)) > len(strings.TrimSpace(from)) { return true } } // keep product name if not empty if slices.Contains(change.Path, "ProductName") { - if strings.TrimSpace(change.From.(string)) != "" { + from, ok := change.From.(string) + if !ok { + return false + } + + if strings.TrimSpace(from) != "" { return false } } // keep existing serial value if not empty if slices.Contains(change.Path, "Serial") { - if strings.TrimSpace(change.From.(string)) != "" { + from, ok := change.From.(string) + if !ok { + return false + } + if strings.TrimSpace(from) != "" { return false } } diff --git a/actions/storage_controller.go b/actions/storage_controller.go index 2c6a88a4..e1911a29 100644 --- a/actions/storage_controller.go +++ b/actions/storage_controller.go @@ -12,9 +12,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - ErrVirtualDiskManagerUtilNotIdentified = errors.New("virtual disk management utility not identifed") -) +var ErrVirtualDiskManagerUtilNotIdentified = errors.New("virtual disk management utility not identifed") type StorageControllerAction struct { Logger *logrus.Logger diff --git a/examples/firmware-install/firmware-install.go b/examples/firmware-install/firmware-install.go index 02b88ab6..ce2e566e 100644 --- a/examples/firmware-install/firmware-install.go +++ b/examples/firmware-install/firmware-install.go @@ -38,5 +38,4 @@ func main() { if err != nil { logger.Fatal(err) } - } diff --git a/firmware/bios_checksum.go b/firmware/bios_checksum.go index bee285de..61881ea8 100644 --- a/firmware/bios_checksum.go +++ b/firmware/bios_checksum.go @@ -15,18 +15,24 @@ import ( "github.com/pkg/errors" ) -const FirmwareDumpUtility model.CollectorUtility = "flashrom" -const UEFIParserUtility model.CollectorUtility = "uefi-firmware-parser" -const ChecksumComposedCollector model.CollectorUtility = "checksum-collector" -const hashPrefix = "SHA256" -const uefiDefaultBMPLogoGUID = "7bb28b99-61bb-11d5-9a5d-0090273fc14d" +const ( + FirmwareDumpUtility model.CollectorUtility = "flashrom" + UEFIParserUtility model.CollectorUtility = "uefi-firmware-parser" + ChecksumComposedCollector model.CollectorUtility = "checksum-collector" + hashPrefix = "SHA256" + uefiDefaultBMPLogoGUID = "7bb28b99-61bb-11d5-9a5d-0090273fc14d" +) -var defaultOutputPath = "/tmp/bios_checksum" -var defaultBIOSImgName = "bios_img.bin" -var expectedLogoSuffix = fmt.Sprintf("file-%s/section0/section0.raw", uefiDefaultBMPLogoGUID) +var ( + defaultOutputPath = "/tmp/bios_checksum" + defaultBIOSImgName = "bios_img.bin" + expectedLogoSuffix = fmt.Sprintf("file-%s/section0/section0.raw", uefiDefaultBMPLogoGUID) +) -var directoryPermissions fs.FileMode = 0o750 -var errNoLogo = errors.New("no logo found") +var ( + directoryPermissions fs.FileMode = 0o750 + errNoLogo = errors.New("no logo found") +) // ChecksumCollector implements the FirmwareChecksumCollector interface type ChecksumCollector struct { @@ -185,7 +191,6 @@ func (cc *ChecksumCollector) findExtractedRawLogo(ctx context.Context) (string, // XXX: Check the DirEntry for a bogus size so we don't blow up trying to hash the thing! return nil }) - if err != nil { return "", errors.Wrap(err, "walking the extract directory") } diff --git a/fixtures/asrr/e3c246d4i-nl.go b/fixtures/asrr/e3c246d4i-nl.go index 951d5311..36576cf2 100644 --- a/fixtures/asrr/e3c246d4i-nl.go +++ b/fixtures/asrr/e3c246d4i-nl.go @@ -36,87 +36,87 @@ var E3C246D4INL = &common.Device{ }, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "acpi", Description: "ACPI", Enabled: true, }, - &common.Capability{ + { Name: "biosbootspecification", Description: "BIOS boot specification", Enabled: true, }, - &common.Capability{ + { Name: "bootselect", Description: "Selectable boot path", Enabled: true, }, - &common.Capability{ + { Name: "cdboot", Description: "Booting from CD-ROM/DVD", Enabled: true, }, - &common.Capability{ + { Name: "edd", Description: "Enhanced Disk Drive extensions", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy1200", Description: "5.25\" 1.2MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy2880", Description: "3.5\" 2.88MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy720", Description: "3.5\" 720KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int14serial", Description: "INT14 serial line control", Enabled: true, }, - &common.Capability{ + { Name: "int17printer", Description: "INT17 printer control", Enabled: true, }, - &common.Capability{ + { Name: "int5printscreen", Description: "Print Screen key", Enabled: true, }, - &common.Capability{ + { Name: "pci", Description: "PCI bus", Enabled: true, }, - &common.Capability{ + { Name: "shadowing", Description: "BIOS shadowing", Enabled: true, }, - &common.Capability{ + { Name: "socketedrom", Description: "BIOS ROM is socketed", Enabled: true, }, - &common.Capability{ + { Name: "uefi", Description: "UEFI specification is supported", Enabled: true, }, - &common.Capability{ + { Name: "upgrade", Description: "BIOS EEPROM can be upgraded", Enabled: true, }, - &common.Capability{ + { Name: "usb", Description: "USB legacy emulation", Enabled: true, @@ -181,612 +181,612 @@ var E3C246D4INL = &common.Device{ Firmware: nil, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "3dnowprefetch", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "abm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "acpi", Description: "thermal control (ACPI)", Enabled: true, }, - &common.Capability{ + { Name: "adx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aes", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aperfmperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "apic", Description: "on-chip advanced programmable interrupt controller (APIC)", Enabled: true, }, - &common.Capability{ + { Name: "arat", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_capabilities", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_perfmon", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "art", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflush", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflushopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cmov", Description: "conditional move instruction", Enabled: true, }, - &common.Capability{ + { Name: "constant_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpufreq", Description: "CPU Frequency scaling", Enabled: true, }, - &common.Capability{ + { Name: "cpuid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpuid_fault", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx16", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx8", Description: "compare and exchange 8-byte", Enabled: true, }, - &common.Capability{ + { Name: "de", Description: "debugging extensions", Enabled: true, }, - &common.Capability{ + { Name: "ds_cpl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtes64", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtherm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dts", Description: "debug trace and EMON store MSRs", Enabled: true, }, - &common.Capability{ + { Name: "epb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept_ad", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "erms", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "est", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "f16c", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flexpriority", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flush_l1d", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fma", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fpu", Description: "mathematical co-processor", Enabled: true, }, - &common.Capability{ + { Name: "fpu_exception", Description: "FPU exceptions reporting", Enabled: true, }, - &common.Capability{ + { Name: "fsgsbase", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fxsr", Description: "fast floating point save/restore", Enabled: true, }, - &common.Capability{ + { Name: "ht", Description: "HyperThreading", Enabled: true, }, - &common.Capability{ + { Name: "hwp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "hwp_act_window", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "hwp_epp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "hwp_notify", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs_enhanced", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ida", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "intel_pt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid_single", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lahf_lm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lm", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "mca", Description: "machine check architecture", Enabled: true, }, - &common.Capability{ + { Name: "mce", Description: "machine check exceptions", Enabled: true, }, - &common.Capability{ + { Name: "md_clear", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mmx", Description: "multimedia extensions (MMX)", Enabled: true, }, - &common.Capability{ + { Name: "monitor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "movbe", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mpx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msr", Description: "model-specific registers", Enabled: true, }, - &common.Capability{ + { Name: "mtrr", Description: "memory type range registers", Enabled: true, }, - &common.Capability{ + { Name: "nonstop_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nopl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nx", Description: "no-execute bit (NX)", Enabled: true, }, - &common.Capability{ + { Name: "pae", Description: "4GB+ memory addressing (Physical Address Extension)", Enabled: true, }, - &common.Capability{ + { Name: "pat", Description: "page attribute table", Enabled: true, }, - &common.Capability{ + { Name: "pbe", Description: "pending break event", Enabled: true, }, - &common.Capability{ + { Name: "pcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pclmulqdq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdcm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdpe1gb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pebs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pge", Description: "page global enable", Enabled: true, }, - &common.Capability{ + { Name: "pln", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "popcnt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pse", Description: "page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pse36", Description: "36-bit page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdrand", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdseed", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdtscp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rep_good", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sdbg", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sep", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "smap", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smep", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ss", Description: "self-snoop", Enabled: true, }, - &common.Capability{ + { Name: "ssbd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse", Description: "streaming SIMD extensions (SSE)", Enabled: true, }, - &common.Capability{ + { Name: "sse2", Description: "streaming SIMD extensions (SSE2)", Enabled: true, }, - &common.Capability{ + { Name: "sse4_1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4_2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssse3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "stibp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "syscall", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "tm", Description: "thermal interrupt and status", Enabled: true, }, - &common.Capability{ + { Name: "tm2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tpr_shadow", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc", Description: "time stamp counter", Enabled: true, }, - &common.Capability{ + { Name: "tsc_adjust", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc_deadline_timer", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vme", Description: "virtual mode extensions", Enabled: true, }, - &common.Capability{ + { Name: "vmx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vnmi", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vpid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x2apic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x86-64", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "xgetbv1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsave", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsavec", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaves", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtopology", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtpr", Description: "", Enabled: true, @@ -865,62 +865,62 @@ var E3C246D4INL = &common.Device{ "speed": "10Gbit/s", }, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "10000bt-fd", Description: "10Gbit/s (full duplex)", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fibre", Description: "optical fibre", Enabled: true, }, - &common.Capability{ + { Name: "msi", Description: "Message Signalled Interrupts", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, diff --git a/fixtures/dell/r6515.go b/fixtures/dell/r6515.go index a59c0afc..9ef88f22 100644 --- a/fixtures/dell/r6515.go +++ b/fixtures/dell/r6515.go @@ -267,102 +267,102 @@ var ( }, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "acpi", Description: "ACPI", Enabled: true, }, - &common.Capability{ + { Name: "biosbootspecification", Description: "BIOS boot specification", Enabled: true, }, - &common.Capability{ + { Name: "bootselect", Description: "Selectable boot path", Enabled: true, }, - &common.Capability{ + { Name: "cdboot", Description: "Booting from CD-ROM/DVD", Enabled: true, }, - &common.Capability{ + { Name: "edd", Description: "Enhanced Disk Drive extensions", Enabled: true, }, - &common.Capability{ + { Name: "int10video", Description: "INT10 CGA/Mono video", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy1200", Description: "5.25\" 1.2MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy360", Description: "5.25\" 360KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy720", Description: "3.5\" 720KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppytoshiba", Description: "Toshiba floppy", Enabled: true, }, - &common.Capability{ + { Name: "int14serial", Description: "INT14 serial line control", Enabled: true, }, - &common.Capability{ + { Name: "int9keyboard", Description: "i8042 keyboard controller", Enabled: true, }, - &common.Capability{ + { Name: "isa", Description: "ISA bus", Enabled: true, }, - &common.Capability{ + { Name: "netboot", Description: "Function-key initiated network service boot", Enabled: true, }, - &common.Capability{ + { Name: "pci", Description: "PCI bus", Enabled: true, }, - &common.Capability{ + { Name: "pnp", Description: "Plug-and-Play", Enabled: true, }, - &common.Capability{ + { Name: "shadowing", Description: "BIOS shadowing", Enabled: true, }, - &common.Capability{ + { Name: "uefi", Description: "UEFI specification is supported", Enabled: true, }, - &common.Capability{ + { Name: "upgrade", Description: "BIOS EEPROM can be upgraded", Enabled: true, }, - &common.Capability{ + { Name: "usb", Description: "USB legacy emulation", Enabled: true, @@ -427,662 +427,662 @@ var ( Firmware: &common.Firmware{Installed: "137367629", Metadata: map[string]string{}}, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "3dnowprefetch", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "abm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "adx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aes", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aperfmperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "apic", Description: "on-chip advanced programmable interrupt controller (APIC)", Enabled: true, }, - &common.Capability{ + { Name: "arat", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bpext", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cat_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cdp_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflush", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflushopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clwb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clzero", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cmov", Description: "conditional move instruction", Enabled: true, }, - &common.Capability{ + { Name: "cmp_legacy", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "constant_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpuid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_local", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_total", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_occup_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cr8_legacy", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx16", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx8", Description: "compare and exchange 8-byte", Enabled: true, }, - &common.Capability{ + { Name: "de", Description: "debugging extensions", Enabled: true, }, - &common.Capability{ + { Name: "decodeassists", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "extapic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "extd_apicid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "f16c", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flushbyasid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fma", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fpu", Description: "mathematical co-processor", Enabled: true, }, - &common.Capability{ + { Name: "fpu_exception", Description: "FPU exceptions reporting", Enabled: true, }, - &common.Capability{ + { Name: "fsgsbase", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fxsr", Description: "fast floating point save/restore", Enabled: true, }, - &common.Capability{ + { Name: "fxsr_opt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ht", Description: "HyperThreading", Enabled: true, }, - &common.Capability{ + { Name: "hw_pstate", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "irperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lahf_lm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lbrv", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lm", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "mba", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mca", Description: "machine check architecture", Enabled: true, }, - &common.Capability{ + { Name: "mce", Description: "machine check exceptions", Enabled: true, }, - &common.Capability{ + { Name: "misalignsse", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mmx", Description: "multimedia extensions (MMX)", Enabled: true, }, - &common.Capability{ + { Name: "mmxext", Description: "multimedia extensions (MMXExt)", Enabled: true, }, - &common.Capability{ + { Name: "monitor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "movbe", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msr", Description: "model-specific registers", Enabled: true, }, - &common.Capability{ + { Name: "mtrr", Description: "memory type range registers", Enabled: true, }, - &common.Capability{ + { Name: "mwaitx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nonstop_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nopl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "npt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nrip_save", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nx", Description: "no-execute bit (NX)", Enabled: true, }, - &common.Capability{ + { Name: "osvw", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "overflow_recov", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pae", Description: "4GB+ memory addressing (Physical Address Extension)", Enabled: true, }, - &common.Capability{ + { Name: "pat", Description: "page attribute table", Enabled: true, }, - &common.Capability{ + { Name: "pausefilter", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pclmulqdq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdpe1gb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_core", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_nb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pfthreshold", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pge", Description: "page global enable", Enabled: true, }, - &common.Capability{ + { Name: "pni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "popcnt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pse", Description: "page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pse36", Description: "36-bit page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "rdpid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdrand", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdseed", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdt_a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdtscp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rep_good", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sep", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "sev", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sha_ni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "skinit", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smap", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smca", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sme", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smep", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssbd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse", Description: "streaming SIMD extensions (SSE)", Enabled: true, }, - &common.Capability{ + { Name: "sse2", Description: "streaming SIMD extensions (SSE2)", Enabled: true, }, - &common.Capability{ + { Name: "sse4_1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4_2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssse3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "stibp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "succor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "svm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "svm_lock", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "syscall", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "tce", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "topoext", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc", Description: "time stamp counter", Enabled: true, }, - &common.Capability{ + { Name: "tsc_scale", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "umip", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "v_vmsave_vmload", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vgif", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vmcb_clean", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vme", Description: "virtual mode extensions", Enabled: true, }, - &common.Capability{ + { Name: "vmmcall", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wbnoinvd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wdt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x2apic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x86-64", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "xgetbv1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsave", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsavec", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveerptr", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaves", Description: "", Enabled: true, @@ -1428,62 +1428,62 @@ var ( PCIVendorID: "dead", PCIProductID: "beef", Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "autonegotiation", Description: "Auto-negotiation", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fibre", Description: "optical fibre", Enabled: true, }, - &common.Capability{ + { Name: "msi", Description: "Message Signalled Interrupts", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, @@ -1826,102 +1826,102 @@ var ( }, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "acpi", Description: "ACPI", Enabled: true, }, - &common.Capability{ + { Name: "biosbootspecification", Description: "BIOS boot specification", Enabled: true, }, - &common.Capability{ + { Name: "bootselect", Description: "Selectable boot path", Enabled: true, }, - &common.Capability{ + { Name: "cdboot", Description: "Booting from CD-ROM/DVD", Enabled: true, }, - &common.Capability{ + { Name: "edd", Description: "Enhanced Disk Drive extensions", Enabled: true, }, - &common.Capability{ + { Name: "int10video", Description: "INT10 CGA/Mono video", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy1200", Description: "5.25\" 1.2MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy360", Description: "5.25\" 360KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy720", Description: "3.5\" 720KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppytoshiba", Description: "Toshiba floppy", Enabled: true, }, - &common.Capability{ + { Name: "int14serial", Description: "INT14 serial line control", Enabled: true, }, - &common.Capability{ + { Name: "int9keyboard", Description: "i8042 keyboard controller", Enabled: true, }, - &common.Capability{ + { Name: "isa", Description: "ISA bus", Enabled: true, }, - &common.Capability{ + { Name: "netboot", Description: "Function-key initiated network service boot", Enabled: true, }, - &common.Capability{ + { Name: "pci", Description: "PCI bus", Enabled: true, }, - &common.Capability{ + { Name: "pnp", Description: "Plug-and-Play", Enabled: true, }, - &common.Capability{ + { Name: "shadowing", Description: "BIOS shadowing", Enabled: true, }, - &common.Capability{ + { Name: "uefi", Description: "UEFI specification is supported", Enabled: true, }, - &common.Capability{ + { Name: "upgrade", Description: "BIOS EEPROM can be upgraded", Enabled: true, }, - &common.Capability{ + { Name: "usb", Description: "USB legacy emulation", Enabled: true, @@ -1986,662 +1986,662 @@ var ( Firmware: &common.Firmware{Installed: "137367629", Metadata: map[string]string{}}, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "3dnowprefetch", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "abm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "adx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aes", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aperfmperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "apic", Description: "on-chip advanced programmable interrupt controller (APIC)", Enabled: true, }, - &common.Capability{ + { Name: "arat", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bpext", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cat_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cdp_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflush", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflushopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clwb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clzero", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cmov", Description: "conditional move instruction", Enabled: true, }, - &common.Capability{ + { Name: "cmp_legacy", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "constant_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpuid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_local", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_total", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_occup_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cr8_legacy", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx16", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx8", Description: "compare and exchange 8-byte", Enabled: true, }, - &common.Capability{ + { Name: "de", Description: "debugging extensions", Enabled: true, }, - &common.Capability{ + { Name: "decodeassists", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "extapic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "extd_apicid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "f16c", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flushbyasid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fma", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fpu", Description: "mathematical co-processor", Enabled: true, }, - &common.Capability{ + { Name: "fpu_exception", Description: "FPU exceptions reporting", Enabled: true, }, - &common.Capability{ + { Name: "fsgsbase", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fxsr", Description: "fast floating point save/restore", Enabled: true, }, - &common.Capability{ + { Name: "fxsr_opt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ht", Description: "HyperThreading", Enabled: true, }, - &common.Capability{ + { Name: "hw_pstate", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "irperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lahf_lm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lbrv", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lm", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "mba", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mca", Description: "machine check architecture", Enabled: true, }, - &common.Capability{ + { Name: "mce", Description: "machine check exceptions", Enabled: true, }, - &common.Capability{ + { Name: "misalignsse", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mmx", Description: "multimedia extensions (MMX)", Enabled: true, }, - &common.Capability{ + { Name: "mmxext", Description: "multimedia extensions (MMXExt)", Enabled: true, }, - &common.Capability{ + { Name: "monitor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "movbe", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msr", Description: "model-specific registers", Enabled: true, }, - &common.Capability{ + { Name: "mtrr", Description: "memory type range registers", Enabled: true, }, - &common.Capability{ + { Name: "mwaitx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nonstop_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nopl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "npt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nrip_save", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nx", Description: "no-execute bit (NX)", Enabled: true, }, - &common.Capability{ + { Name: "osvw", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "overflow_recov", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pae", Description: "4GB+ memory addressing (Physical Address Extension)", Enabled: true, }, - &common.Capability{ + { Name: "pat", Description: "page attribute table", Enabled: true, }, - &common.Capability{ + { Name: "pausefilter", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pclmulqdq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdpe1gb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_core", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "perfctr_nb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pfthreshold", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pge", Description: "page global enable", Enabled: true, }, - &common.Capability{ + { Name: "pni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "popcnt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pse", Description: "page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pse36", Description: "36-bit page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "rdpid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdrand", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdseed", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdt_a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdtscp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rep_good", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sep", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "sev", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sha_ni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "skinit", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smap", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smca", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sme", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smep", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssbd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse", Description: "streaming SIMD extensions (SSE)", Enabled: true, }, - &common.Capability{ + { Name: "sse2", Description: "streaming SIMD extensions (SSE2)", Enabled: true, }, - &common.Capability{ + { Name: "sse4_1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4_2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssse3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "stibp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "succor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "svm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "svm_lock", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "syscall", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "tce", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "topoext", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc", Description: "time stamp counter", Enabled: true, }, - &common.Capability{ + { Name: "tsc_scale", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "umip", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "v_vmsave_vmload", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vgif", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vmcb_clean", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vme", Description: "virtual mode extensions", Enabled: true, }, - &common.Capability{ + { Name: "vmmcall", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wbnoinvd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wdt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x2apic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x86-64", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "xgetbv1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsave", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsavec", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveerptr", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaves", Description: "", Enabled: true, @@ -2987,62 +2987,62 @@ var ( PCIVendorID: "dead", PCIProductID: "beef", Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "autonegotiation", Description: "Auto-negotiation", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fibre", Description: "optical fibre", Enabled: true, }, - &common.Capability{ + { Name: "msi", Description: "Message Signalled Interrupts", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, diff --git a/fixtures/supermicro/x11dph-t.go b/fixtures/supermicro/x11dph-t.go index 30b9f518..f8c75287 100644 --- a/fixtures/supermicro/x11dph-t.go +++ b/fixtures/supermicro/x11dph-t.go @@ -261,87 +261,87 @@ var ( }, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "acpi", Description: "ACPI", Enabled: true, }, - &common.Capability{ + { Name: "biosbootspecification", Description: "BIOS boot specification", Enabled: true, }, - &common.Capability{ + { Name: "bootselect", Description: "Selectable boot path", Enabled: true, }, - &common.Capability{ + { Name: "cdboot", Description: "Booting from CD-ROM/DVD", Enabled: true, }, - &common.Capability{ + { Name: "edd", Description: "Enhanced Disk Drive extensions", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy1200", Description: "5.25\" 1.2MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy2880", Description: "3.5\" 2.88MB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int13floppy720", Description: "3.5\" 720KB floppy", Enabled: true, }, - &common.Capability{ + { Name: "int14serial", Description: "INT14 serial line control", Enabled: true, }, - &common.Capability{ + { Name: "int17printer", Description: "INT17 printer control", Enabled: true, }, - &common.Capability{ + { Name: "int5printscreen", Description: "Print Screen key", Enabled: true, }, - &common.Capability{ + { Name: "pci", Description: "PCI bus", Enabled: true, }, - &common.Capability{ + { Name: "shadowing", Description: "BIOS shadowing", Enabled: true, }, - &common.Capability{ + { Name: "socketedrom", Description: "BIOS ROM is socketed", Enabled: true, }, - &common.Capability{ + { Name: "uefi", Description: "UEFI specification is supported", Enabled: true, }, - &common.Capability{ + { Name: "upgrade", Description: "BIOS EEPROM can be upgraded", Enabled: true, }, - &common.Capability{ + { Name: "usb", Description: "USB legacy emulation", Enabled: true, @@ -441,692 +441,692 @@ var ( Firmware: &common.Firmware{Installed: "83898113", Metadata: map[string]string{}}, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "3dnowprefetch", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "abm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "acpi", Description: "thermal control (ACPI)", Enabled: true, }, - &common.Capability{ + { Name: "adx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aes", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aperfmperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "apic", Description: "on-chip advanced programmable interrupt controller (APIC)", Enabled: true, }, - &common.Capability{ + { Name: "arat", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_capabilities", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_perfmon", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "art", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512_vnni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512bw", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512cd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512dq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512f", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512vl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cat_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cdp_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflush", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflushopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clwb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cmov", Description: "conditional move instruction", Enabled: true, }, - &common.Capability{ + { Name: "constant_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpufreq", Description: "CPU Frequency scaling", Enabled: true, }, - &common.Capability{ + { Name: "cpuid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpuid_fault", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_local", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_total", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_occup_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx16", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx8", Description: "compare and exchange 8-byte", Enabled: true, }, - &common.Capability{ + { Name: "dca", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "de", Description: "debugging extensions", Enabled: true, }, - &common.Capability{ + { Name: "ds_cpl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtes64", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtherm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dts", Description: "debug trace and EMON store MSRs", Enabled: true, }, - &common.Capability{ + { Name: "epb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept_ad", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "erms", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "est", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "f16c", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flexpriority", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flush_l1d", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fma", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fpu", Description: "mathematical co-processor", Enabled: true, }, - &common.Capability{ + { Name: "fpu_exception", Description: "FPU exceptions reporting", Enabled: true, }, - &common.Capability{ + { Name: "fsgsbase", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fxsr", Description: "fast floating point save/restore", Enabled: true, }, - &common.Capability{ + { Name: "ht", Description: "HyperThreading", Enabled: true, }, - &common.Capability{ + { Name: "ibpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs_enhanced", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ida", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "intel_ppin", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "intel_pt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid_single", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lahf_lm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lm", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "mba", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mca", Description: "machine check architecture", Enabled: true, }, - &common.Capability{ + { Name: "mce", Description: "machine check exceptions", Enabled: true, }, - &common.Capability{ + { Name: "md_clear", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mmx", Description: "multimedia extensions (MMX)", Enabled: true, }, - &common.Capability{ + { Name: "monitor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "movbe", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mpx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msr", Description: "model-specific registers", Enabled: true, }, - &common.Capability{ + { Name: "mtrr", Description: "memory type range registers", Enabled: true, }, - &common.Capability{ + { Name: "nonstop_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nopl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nx", Description: "no-execute bit (NX)", Enabled: true, }, - &common.Capability{ + { Name: "ospke", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pae", Description: "4GB+ memory addressing (Physical Address Extension)", Enabled: true, }, - &common.Capability{ + { Name: "pat", Description: "page attribute table", Enabled: true, }, - &common.Capability{ + { Name: "pbe", Description: "pending break event", Enabled: true, }, - &common.Capability{ + { Name: "pcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pclmulqdq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdcm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdpe1gb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pebs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pge", Description: "page global enable", Enabled: true, }, - &common.Capability{ + { Name: "pku", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pln", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "popcnt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pse", Description: "page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pse36", Description: "36-bit page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdrand", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdseed", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdt_a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdtscp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rep_good", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sdbg", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sep", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "smap", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smep", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ss", Description: "self-snoop", Enabled: true, }, - &common.Capability{ + { Name: "ssbd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse", Description: "streaming SIMD extensions (SSE)", Enabled: true, }, - &common.Capability{ + { Name: "sse2", Description: "streaming SIMD extensions (SSE2)", Enabled: true, }, - &common.Capability{ + { Name: "sse4_1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4_2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssse3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "stibp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "syscall", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "tm", Description: "thermal interrupt and status", Enabled: true, }, - &common.Capability{ + { Name: "tm2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tpr_shadow", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc", Description: "time stamp counter", Enabled: true, }, - &common.Capability{ + { Name: "tsc_adjust", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc_deadline_timer", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vme", Description: "virtual mode extensions", Enabled: true, }, - &common.Capability{ + { Name: "vmx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vnmi", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vpid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x2apic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x86-64", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "xgetbv1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsave", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsavec", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaves", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtopology", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtpr", Description: "", Enabled: true, @@ -1151,692 +1151,692 @@ var ( Firmware: &common.Firmware{Installed: "83898113", Metadata: map[string]string{}}, Status: nil, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "3dnowprefetch", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "abm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "acpi", Description: "thermal control (ACPI)", Enabled: true, }, - &common.Capability{ + { Name: "adx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aes", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "aperfmperf", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "apic", Description: "on-chip advanced programmable interrupt controller (APIC)", Enabled: true, }, - &common.Capability{ + { Name: "arat", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_capabilities", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "arch_perfmon", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "art", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512_vnni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512bw", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512cd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512dq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512f", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "avx512vl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bmi2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "bts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cat_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cdp_l3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflush", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clflushopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "clwb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cmov", Description: "conditional move instruction", Enabled: true, }, - &common.Capability{ + { Name: "constant_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpufreq", Description: "CPU Frequency scaling", Enabled: true, }, - &common.Capability{ + { Name: "cpuid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cpuid_fault", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_local", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_mbm_total", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cqm_occup_llc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx16", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "cx8", Description: "compare and exchange 8-byte", Enabled: true, }, - &common.Capability{ + { Name: "dca", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "de", Description: "debugging extensions", Enabled: true, }, - &common.Capability{ + { Name: "ds_cpl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtes64", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dtherm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "dts", Description: "debug trace and EMON store MSRs", Enabled: true, }, - &common.Capability{ + { Name: "epb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ept_ad", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "erms", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "est", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "f16c", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flexpriority", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "flush_l1d", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fma", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fpu", Description: "mathematical co-processor", Enabled: true, }, - &common.Capability{ + { Name: "fpu_exception", Description: "FPU exceptions reporting", Enabled: true, }, - &common.Capability{ + { Name: "fsgsbase", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "fxsr", Description: "fast floating point save/restore", Enabled: true, }, - &common.Capability{ + { Name: "ht", Description: "HyperThreading", Enabled: true, }, - &common.Capability{ + { Name: "ibpb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ibrs_enhanced", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ida", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "intel_ppin", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "intel_pt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "invpcid_single", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lahf_lm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "lm", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "mba", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mca", Description: "machine check architecture", Enabled: true, }, - &common.Capability{ + { Name: "mce", Description: "machine check exceptions", Enabled: true, }, - &common.Capability{ + { Name: "md_clear", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mmx", Description: "multimedia extensions (MMX)", Enabled: true, }, - &common.Capability{ + { Name: "monitor", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "movbe", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "mpx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msr", Description: "model-specific registers", Enabled: true, }, - &common.Capability{ + { Name: "mtrr", Description: "memory type range registers", Enabled: true, }, - &common.Capability{ + { Name: "nonstop_tsc", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nopl", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "nx", Description: "no-execute bit (NX)", Enabled: true, }, - &common.Capability{ + { Name: "ospke", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pae", Description: "4GB+ memory addressing (Physical Address Extension)", Enabled: true, }, - &common.Capability{ + { Name: "pat", Description: "page attribute table", Enabled: true, }, - &common.Capability{ + { Name: "pbe", Description: "pending break event", Enabled: true, }, - &common.Capability{ + { Name: "pcid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pclmulqdq", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdcm", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pdpe1gb", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pebs", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pge", Description: "page global enable", Enabled: true, }, - &common.Capability{ + { Name: "pku", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pln", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pni", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "popcnt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "pse", Description: "page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pse36", Description: "36-bit page size extensions", Enabled: true, }, - &common.Capability{ + { Name: "pts", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdrand", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdseed", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdt_a", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rdtscp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "rep_good", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sdbg", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sep", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "smap", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smep", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "smx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ss", Description: "self-snoop", Enabled: true, }, - &common.Capability{ + { Name: "ssbd", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse", Description: "streaming SIMD extensions (SSE)", Enabled: true, }, - &common.Capability{ + { Name: "sse2", Description: "streaming SIMD extensions (SSE2)", Enabled: true, }, - &common.Capability{ + { Name: "sse4_1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "sse4_2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "ssse3", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "stibp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "syscall", Description: "fast system calls", Enabled: true, }, - &common.Capability{ + { Name: "tm", Description: "thermal interrupt and status", Enabled: true, }, - &common.Capability{ + { Name: "tm2", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tpr_shadow", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc", Description: "time stamp counter", Enabled: true, }, - &common.Capability{ + { Name: "tsc_adjust", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "tsc_deadline_timer", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vme", Description: "virtual mode extensions", Enabled: true, }, - &common.Capability{ + { Name: "vmx", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vnmi", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "vpid", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "wp", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x2apic", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "x86-64", Description: "64bits extensions (x86-64)", Enabled: true, }, - &common.Capability{ + { Name: "xgetbv1", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsave", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsavec", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaveopt", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xsaves", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtopology", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "xtpr", Description: "", Enabled: true, @@ -2103,67 +2103,67 @@ var ( "link": "no", }, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "10000bt-fd", Description: "10Gbit/s (full duplex)", Enabled: true, }, - &common.Capability{ + { Name: "1000bt-fd", Description: "1Gbit/s (full duplex)", Enabled: true, }, - &common.Capability{ + { Name: "autonegotiation", Description: "Auto-negotiation", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msi", Description: "Message Signalled Interrupts", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, @@ -2201,67 +2201,67 @@ var ( "link": "no", }, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "10000bt-fd", Description: "10Gbit/s (full duplex)", Enabled: true, }, - &common.Capability{ + { Name: "1000bt-fd", Description: "1Gbit/s (full duplex)", Enabled: true, }, - &common.Capability{ + { Name: "autonegotiation", Description: "Auto-negotiation", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msi", Description: "Message Signalled Interrupts", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, @@ -2307,52 +2307,52 @@ var ( "speed": "10Gbit/s", }, Capabilities: []*common.Capability{ - &common.Capability{ + { Name: "autonegotiation", Description: "Auto-negotiation", Enabled: true, }, - &common.Capability{ + { Name: "bus_master", Description: "bus mastering", Enabled: true, }, - &common.Capability{ + { Name: "cap_list", Description: "PCI capabilities listing", Enabled: true, }, - &common.Capability{ + { Name: "ethernet", Description: "", Enabled: true, }, - &common.Capability{ + { Name: "msix", Description: "MSI-X", Enabled: true, }, - &common.Capability{ + { Name: "pciexpress", Description: "PCI Express", Enabled: true, }, - &common.Capability{ + { Name: "physical", Description: "Physical interface", Enabled: true, }, - &common.Capability{ + { Name: "pm", Description: "Power Management", Enabled: true, }, - &common.Capability{ + { Name: "rom", Description: "extension ROM", Enabled: true, }, - &common.Capability{ + { Name: "vpd", Description: "Vital Product Data", Enabled: true, diff --git a/go.mod b/go.mod index 463578e5..2ac21609 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/metal-toolbox/ironlib -go 1.19 +go 1.22 require ( github.com/beevik/etree v1.1.0 diff --git a/model/consts.go b/model/consts.go index 70079e96..94e1b268 100644 --- a/model/consts.go +++ b/model/consts.go @@ -74,7 +74,7 @@ var ( SlugDell64bitUefiDiagnostics: {}, } - // DellComponentSlug is an ordered list of of dell component identifiers to component slug + // 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{ diff --git a/providers/asrockrack/asrockrack.go b/providers/asrockrack/asrockrack.go index e3049923..35761106 100644 --- a/providers/asrockrack/asrockrack.go +++ b/providers/asrockrack/asrockrack.go @@ -82,23 +82,23 @@ func (a *asrockrack) UpdatesApplied() bool { } // ListAvailableUpdates runs the vendor tooling (dsu) to identify updates available -func (a *asrockrack) ListAvailableUpdates(ctx context.Context, options *model.UpdateOptions) (*common.Device, error) { +func (a *asrockrack) ListAvailableUpdates(context.Context, *model.UpdateOptions) (*common.Device, error) { return nil, nil } // InstallUpdates for asrockrack based on updateOptions -func (a *asrockrack) InstallUpdates(ctx context.Context, options *model.UpdateOptions) error { +func (a *asrockrack) InstallUpdates(context.Context, *model.UpdateOptions) error { return nil } // GetInventoryOEM collects device inventory using vendor specific tooling // and updates the given device.OemComponents object with the OEM inventory -func (a *asrockrack) GetInventoryOEM(ctx context.Context, device *common.Device, options *model.UpdateOptions) error { +func (a *asrockrack) GetInventoryOEM(context.Context, *common.Device, *model.UpdateOptions) error { return nil } // ApplyUpdate is here to satisfy the actions.Updater interface // it is to be deprecated in favor of InstallUpdates. -func (a *asrockrack) ApplyUpdate(ctx context.Context, updateFile, component string) error { +func (a *asrockrack) ApplyUpdate(context.Context, string, string) error { return nil } diff --git a/providers/asrockrack/bios.go b/providers/asrockrack/bios.go index 52f08196..9e4aa70c 100644 --- a/providers/asrockrack/bios.go +++ b/providers/asrockrack/bios.go @@ -7,7 +7,7 @@ import ( "github.com/metal-toolbox/ironlib/utils" ) -func (a *asrockrack) SetBIOSConfiguration(ctx context.Context, cfg map[string]string) error { +func (a *asrockrack) SetBIOSConfiguration(context.Context, map[string]string) error { return nil } diff --git a/providers/dell/bios.go b/providers/dell/bios.go index f64d2fbc..096ab06f 100644 --- a/providers/dell/bios.go +++ b/providers/dell/bios.go @@ -8,20 +8,20 @@ import ( "github.com/metal-toolbox/ironlib/utils" ) -func (d *dell) SetBIOSConfiguration(_ context.Context, cfg map[string]string) error { +func (d *dell) SetBIOSConfiguration(context.Context, map[string]string) error { return nil } func (d *dell) GetBIOSConfiguration(ctx context.Context) (map[string]string, error) { if envRacadmUtil := os.Getenv("IRONLIB_UTIL_RACADM7"); envRacadmUtil == "" { - err := d.pre() // ensure runtime pre-requisites are installed + err := d.pre(ctx) // ensure runtime pre-requisites are installed if err != nil { return nil, err } } // Make sure service that loads ipmi modules is running before attempting to collect bios config - err := d.startSrvHelper() + err := d.startSrvHelper(ctx) if err != nil { return nil, err } diff --git a/providers/dell/dell.go b/providers/dell/dell.go index 7bafcb59..2ab62888 100644 --- a/providers/dell/dell.go +++ b/providers/dell/dell.go @@ -126,10 +126,10 @@ func (d *dell) GetInventory(ctx context.Context, options ...actions.Option) (*co // GetInventoryOEM collects device inventory using vendor specific tooling // and updates the given device.OemComponents object with the OEM inventory -func (d *dell) GetInventoryOEM(_ context.Context, device *common.Device, options *model.UpdateOptions) error { +func (d *dell) GetInventoryOEM(ctx context.Context, _ *common.Device, options *model.UpdateOptions) error { d.setUpdateOptions(options) - oemComponents, err := d.dsuInventory() + oemComponents, err := d.dsuInventory(ctx) if err != nil { return err } @@ -146,7 +146,7 @@ func (d *dell) ListAvailableUpdates(ctx context.Context, options *model.UpdateOp d.setUpdateOptions(options) - oemUpdates, err := d.dsuListUpdates() + oemUpdates, err := d.dsuListUpdates(ctx) if err != nil { return nil, err } @@ -186,7 +186,7 @@ func (d *dell) installAvailableUpdates(ctx context.Context, downloadOnly bool) e // the installer returns non-zero return code on failure, // when no updates are available // or when the device requires a reboot - exitCode, err := d.dsuInstallUpdates(downloadOnly) + exitCode, err := d.dsuInstallUpdates(ctx, downloadOnly) if err != nil { switch exitCode { case utils.DSUExitCodeNoUpdatesAvailable: @@ -230,6 +230,6 @@ func (d *dell) setUpdateOptions(options *model.UpdateOptions) { // ApplyUpdate is here to satisfy the actions.Updater interface // it is to be deprecated in favor of InstallUpdates. -func (d *dell) ApplyUpdate(ctx context.Context, updateFile, component string) error { +func (d *dell) ApplyUpdate(context.Context, string, string) error { return nil } diff --git a/providers/dell/dell_test.go b/providers/dell/dell_test.go index 073c6e5b..2974a989 100644 --- a/providers/dell/dell_test.go +++ b/providers/dell/dell_test.go @@ -9,18 +9,15 @@ import ( "github.com/bmc-toolbox/common" "github.com/metal-toolbox/ironlib/actions" dellFixtures "github.com/metal-toolbox/ironlib/fixtures/dell" - "github.com/metal-toolbox/ironlib/model" "github.com/metal-toolbox/ironlib/utils" "github.com/sirupsen/logrus" "gotest.tools/assert" ) -var ( - r6515fixtures = "../../fixtures/dell/r6515" -) +var r6515fixtures = "../../fixtures/dell/r6515" -func newFakeDellDevice() (*dell, error) { +func newFakeDellDevice() *dell { device := common.NewDevice() device.Oem = true @@ -35,7 +32,7 @@ func newFakeDellDevice() (*dell, error) { hw: hardware, dnf: utils.NewFakeDnf(), logger: logrus.New(), - }, nil + } } // Get inventory, not listing updates available @@ -45,10 +42,7 @@ func TestGetInventory(t *testing.T) { expected.Oem = true expectedOemComponents := dellFixtures.R6515_oem_components - dell, err := newFakeDellDevice() - if err != nil { - t.Error(err) - } + dell := newFakeDellDevice() // dsu b, err := os.ReadFile(r6515fixtures + "/dsu_inventory") @@ -104,10 +98,7 @@ func TestGetInventory(t *testing.T) { // Get inventory, not listing updates available func TestListUpdates(t *testing.T) { - dell, err := newFakeDellDevice() - if err != nil { - t.Error(err) - } + dell := newFakeDellDevice() // dsu b, err := os.ReadFile(r6515fixtures + "/dsu_preview") diff --git a/providers/dell/helpers.go b/providers/dell/helpers.go index bb348504..249597e2 100644 --- a/providers/dell/helpers.go +++ b/providers/dell/helpers.go @@ -21,15 +21,15 @@ var ( ) // dsuInstallUpdates installs DSU identified updates -func (d *dell) dsuInstallUpdates(downloadOnly bool) (int, error) { +func (d *dell) dsuInstallUpdates(ctx context.Context, downloadOnly bool) (int, error) { // install pre-requisites - err := d.pre() + err := d.pre(ctx) if err != nil { return 0, errors.Wrap(err, "error installing pre-requisites for DSU") } // Fetch DSU identified update files - exitCode, err := d.dsu.FetchUpdateFiles(utils.LocalUpdatesDirectory) + exitCode, err := d.dsu.FetchUpdateFiles(ctx, utils.LocalUpdatesDirectory) if err != nil { return exitCode, err } @@ -39,7 +39,7 @@ func (d *dell) dsuInstallUpdates(downloadOnly bool) (int, error) { } // Install DSU fetched local update files - return d.dsu.ApplyLocalUpdates(utils.LocalUpdatesDirectory) + return d.dsu.ApplyLocalUpdates(ctx, utils.LocalUpdatesDirectory) } // installUpdate installs a given dell update file (DUP) @@ -59,7 +59,7 @@ func (d *dell) installUpdate(ctx context.Context, updateFile string, downgrade b // set files executable // nolint gocritic: this fs mode declaration is as clear as it gets - err := os.Chmod(updateFile, 0744) + err := os.Chmod(updateFile, 0o744) if err != nil { return 0, err } @@ -97,14 +97,14 @@ func (d *dell) installUpdate(ctx context.Context, updateFile string, downgrade b } // dsuListUpdates runs the dell-system-update utility to retrieve device inventory -func (d *dell) dsuListUpdates() ([]*model.Component, error) { - err := d.pre() +func (d *dell) dsuListUpdates(ctx context.Context) ([]*model.Component, error) { + err := d.pre(ctx) if err != nil { return nil, errors.Wrap(err, "error ensuring prerequisites for dsu update list") } // collect firmware updates available for components - updates, exitCode, err := d.dsu.ComponentFirmwareUpdatePreview() + updates, exitCode, err := d.dsu.ComponentFirmwareUpdatePreview(ctx) if err != nil && exitCode != utils.DSUExitCodeNoUpdatesAvailable { return nil, errors.Wrap(err, "error running dsu update preview") } @@ -113,17 +113,17 @@ func (d *dell) dsuListUpdates() ([]*model.Component, error) { } // runs the dell-system-update utility to identify and list firmware updates available -func (d *dell) dsuInventory() ([]*model.Component, error) { - err := d.pre() +func (d *dell) dsuInventory(ctx context.Context) ([]*model.Component, error) { + err := d.pre(ctx) if err != nil { return nil, err } - return d.dsu.Inventory() + return d.dsu.Inventory(ctx) } // pre sets up prequisites for dealing with updates -func (d *dell) pre() (err error) { +func (d *dell) pre(ctx context.Context) (err error) { errPrefix := "dell dsu prereqs setup error: " if d.DsuPrequisitesInstalled { @@ -131,7 +131,7 @@ func (d *dell) pre() (err error) { } actions := []func() error{ - d.addDsuRepo, d.installPkgs, d.startSrvHelper, + d.addDsuRepo, d.installPkgs, func() error { return d.startSrvHelper(ctx) }, } for _, action := range actions { @@ -199,7 +199,7 @@ func (d *dell) addDsuRepo() error { // Since we're running dsu within a docker container on the target host, // this was found to be required to ensure dsu was able to inventorize the host correctly. // else it would not be able to retrieve data over IPMI -func (d *dell) startSrvHelper() error { +func (d *dell) startSrvHelper(ctx context.Context) error { if os.Getenv("IRONLIB_TEST") != "" { return nil } @@ -207,7 +207,7 @@ func (d *dell) startSrvHelper() error { e := utils.NewExecutor("/usr/libexec/instsvcdrv-helper") e.SetArgs([]string{"start"}) - result, err := e.ExecWithContext(context.Background()) + result, err := e.ExecWithContext(ctx) if err != nil || result.ExitCode != 0 { return err diff --git a/providers/supermicro/bios.go b/providers/supermicro/bios.go index 3dd784ee..cd4b9dee 100644 --- a/providers/supermicro/bios.go +++ b/providers/supermicro/bios.go @@ -8,7 +8,7 @@ import ( ) // SetBIOSConfiguration sets bios configuration settings -func (s *supermicro) SetBIOSConfiguration(_ context.Context, cfg map[string]string) error { +func (s *supermicro) SetBIOSConfiguration(context.Context, map[string]string) error { return nil } diff --git a/providers/supermicro/supermicro.go b/providers/supermicro/supermicro.go index f5829e85..dcbafe75 100644 --- a/providers/supermicro/supermicro.go +++ b/providers/supermicro/supermicro.go @@ -112,7 +112,7 @@ func (s *supermicro) GetInventory(ctx context.Context, options ...actions.Option } // ListUpdatesAvailable does nothing on a SMC device -func (s *supermicro) ListAvailableUpdates(_ context.Context, options *model.UpdateOptions) (*common.Device, error) { +func (s *supermicro) ListAvailableUpdates(context.Context, *model.UpdateOptions) (*common.Device, error) { return nil, nil } @@ -147,12 +147,12 @@ func (s *supermicro) InstallUpdates(ctx context.Context, option *model.UpdateOpt // GetInventoryOEM collects device inventory using vendor specific tooling // and updates the given device.OemComponents object with the OEM inventory -func (s *supermicro) GetInventoryOEM(_ context.Context, device *common.Device, options *model.UpdateOptions) error { +func (s *supermicro) GetInventoryOEM(context.Context, *common.Device, *model.UpdateOptions) error { return nil } // ApplyUpdate is here to satisfy the actions.Updater interface // it is to be deprecated in favor of InstallUpdates. -func (s *supermicro) ApplyUpdate(_ context.Context, updateFile, component string) error { +func (s *supermicro) ApplyUpdate(context.Context, string, string) error { return nil } diff --git a/utils/asrr_bioscontrol.go b/utils/asrr_bioscontrol.go index d619af51..fd1c370f 100644 --- a/utils/asrr_bioscontrol.go +++ b/utils/asrr_bioscontrol.go @@ -75,12 +75,12 @@ func (a *AsrrBioscontrol) Attributes() (utilName model.CollectorUtility, absolut } // kernelVersion returns the host kernel version -func kernelVersion() (string, error) { +func kernelVersion(ctx context.Context) (string, error) { unameExec := NewExecutor("uname") unameExec.SetArgs([]string{"-r"}) unameExec.SetQuiet() - r, err := unameExec.ExecWithContext(context.TODO()) + r, err := unameExec.ExecWithContext(ctx) if err != nil { return "", errors.Wrap(err, "error executing uname -r") } @@ -89,11 +89,11 @@ func kernelVersion() (string, error) { } // kernelModuleLoaded returns bool if the given module name is loaded -func kernelModuleLoaded(name string) (bool, error) { +func kernelModuleLoaded(ctx context.Context, name string) (bool, error) { lsmodExec := NewExecutor("lsmod") lsmodExec.SetQuiet() - r, err := lsmodExec.ExecWithContext(context.TODO()) + r, err := lsmodExec.ExecWithContext(ctx) if err != nil { return false, errors.Wrap(err, "error executing lsmod") } @@ -109,13 +109,13 @@ func kernelModuleLoaded(name string) (bool, error) { func loadAsrrBiosKernelModule(ctx context.Context) error { // begin ick code // 1. identify kernel release - kernelVersion, err := kernelVersion() + kernelVersion, err := kernelVersion(ctx) if err != nil { return errors.Wrap(ErrASRRBIOSKernelModule, err.Error()) } // 2. figure if the kernel module is loaded - isLoaded, err := kernelModuleLoaded("asrdev") + isLoaded, err := kernelModuleLoaded(ctx, "asrdev") if err != nil { return errors.Wrap(ErrASRRBIOSKernelModule, err.Error()) } @@ -199,7 +199,7 @@ type asrrBiosParam struct { } // asrrBiosConfigurationJSON returns a map of BIOS settings and values -func asrrBiosConfigurationJSON(ctx context.Context, configBytes []byte) (map[string]string, error) { +func asrrBiosConfigurationJSON(_ context.Context, configBytes []byte) (map[string]string, error) { cfg := make(map[string]string) params := []*asrrBiosParam{} @@ -237,7 +237,11 @@ func asrrBiosConfigurationJSON(ctx context.Context, configBytes []byte) (map[str // asrrBiosConfigValueTitle returns the Title name of the BIOS attribute value func asrrBiosConfigValueTitle(value, valueType string, validValues interface{}) string { - for _, m := range validValues.([]interface{}) { + values, ok := validValues.([]interface{}) + if !ok { + panic(fmt.Sprintf("validValues is an unexpected type...%v", validValues)) + } + for _, m := range values { // UINT8, UINT16 fields switch param := m.(type) { // slice item is map @@ -254,7 +258,11 @@ func asrrBiosConfigValueTitle(value, valueType string, validValues interface{}) } if v == value { - return param["Title"].(string) + title, ok := param["Title"].(string) + if !ok { + panic(fmt.Sprintf("Title is not a string...%v", param["Title"])) + } + return title } // BOOLEAN fields // slice item is a float64 diff --git a/utils/dell_racadm.go b/utils/dell_racadm.go index ba0fd1d7..924a8fc2 100644 --- a/utils/dell_racadm.go +++ b/utils/dell_racadm.go @@ -12,12 +12,16 @@ import ( "github.com/tidwall/gjson" ) -const DellRacadmPath = "/opt/dell/srvadmin/bin/idracadm7" -const EnvVarRacadm7 = "IRONLIB_UTIL_RACADM7" +const ( + DellRacadmPath = "/opt/dell/srvadmin/bin/idracadm7" + EnvVarRacadm7 = "IRONLIB_UTIL_RACADM7" +) -var ErrDellBiosCfgNil = errors.New("expected valid bios config object, got nil") -var ErrDellBiosCfgFileUndefined = errors.New("no BIOS config file defined") -var ErrDellBiosCfgFileEmpty = errors.New("BIOS config file empty or invalid") +var ( + ErrDellBiosCfgNil = errors.New("expected valid bios config object, got nil") + ErrDellBiosCfgFileUndefined = errors.New("no BIOS config file defined") + ErrDellBiosCfgFileEmpty = errors.New("BIOS config file empty or invalid") +) // DellRacadm is a dell racadm executor type DellRacadm struct { @@ -163,7 +167,7 @@ func (s *DellRacadm) racadmBIOSConfigJSON(ctx context.Context) (map[string]strin attrs := map[string]string{} attrJSON := gjson.Get(s.ConfigJSON, `SystemConfiguration.Components.#(FQDD=="BIOS.Setup.1-1").Attributes`) - attrJSON.ForEach(func(key, value gjson.Result) bool { + attrJSON.ForEach(func(_, value gjson.Result) bool { n := value.Get("Name").String() v := value.Get("Value").String() @@ -205,7 +209,7 @@ func NewFakeRacadm(biosCfgFile string) *DellRacadm { } // ExecWithContext implements the utils.Executor interface -func (e *FakeRacadmExecute) ExecWithContext(ctx context.Context) (*Result, error) { +func (e *FakeRacadmExecute) ExecWithContext(context.Context) (*Result, error) { return &Result{Stdout: []byte(`dummy`)}, nil } diff --git a/utils/dell_racadm_test.go b/utils/dell_racadm_test.go index 35995372..fa4f4858 100644 --- a/utils/dell_racadm_test.go +++ b/utils/dell_racadm_test.go @@ -241,7 +241,8 @@ func Test_RacadmBIOSConfigJSON(t *testing.T) { } func Test_RacadmBIOSConfigXML(t *testing.T) { - expected := map[string]string{"AcPwrRcvry": "Last", + expected := map[string]string{ + "AcPwrRcvry": "Last", "AcPwrRcvryDelay": "Immediate", "BootMode": "Bios", "BootSeqRetry": "Enabled", diff --git a/utils/dmidecode.go b/utils/dmidecode.go index 206a9a3d..e05eac80 100644 --- a/utils/dmidecode.go +++ b/utils/dmidecode.go @@ -17,7 +17,7 @@ type Dmidecode struct { } func NewDmidecode() (d *Dmidecode, err error) { - var dmi = dmidecode.New() + dmi := dmidecode.New() err = dmi.Run() if err != nil { @@ -119,7 +119,7 @@ func (d *Dmidecode) BIOSVersion() (string, error) { return d.query("BIOS Information", "Version") } -func (d *Dmidecode) TPMs(ctx context.Context) ([]*common.TPM, error) { +func (d *Dmidecode) TPMs(context.Context) ([]*common.TPM, error) { // TPM type ID tpmTypeID := 43 diff --git a/utils/dnf.go b/utils/dnf.go index 686241b2..0ba9042a 100644 --- a/utils/dnf.go +++ b/utils/dnf.go @@ -3,14 +3,12 @@ package utils import ( "context" "os" - "text/template" "github.com/metal-toolbox/ironlib/model" ) -var ( - DellRepoTemplate = `[{{ .Name }}-{{ .RepoVersion }}-system-update_independent] +var DellRepoTemplate = `[{{ .Name }}-{{ .RepoVersion }}-system-update_independent] name={{ .Name}}-{{ .RepoVersion }} baseurl={{ .BaseURL }}/os_independent/ {{- if .GPGCheck }} @@ -40,7 +38,6 @@ gpgkey=file:///usr/libexec/dell_dup/0x756ba70b1019ced6.asc file:///usr/libexec/dell_dup/0xca77951d23b66a9d.asc file:///usr/libexec/dell_dup/0x3CA66B4946770C59.asc enabled=1` -) const ( // EnvDnfUtility - to override the utility path diff --git a/utils/dsu.go b/utils/dsu.go index eb90d008..5f7257df 100644 --- a/utils/dsu.go +++ b/utils/dsu.go @@ -88,7 +88,7 @@ func NewFakeDsu(r io.Reader) (*Dsu, error) { // NOTE: // dsu 1.8 drops update files under the given $updateDir // dsu 1.9 creates a directory '$updateDir/dellupdates' and drops the updates in there -func (d *Dsu) FetchUpdateFiles(dstDir string) (int, error) { +func (d *Dsu) FetchUpdateFiles(ctx context.Context, dstDir string) (int, error) { // purge any existing update file/directory with the same name _ = os.Remove(dstDir) @@ -97,7 +97,7 @@ func (d *Dsu) FetchUpdateFiles(dstDir string) (int, error) { // because... yeah dsu wants to fetch updates interactively d.Executor.SetStdin(bytes.NewReader([]byte("a\nc\n"))) - result, err := d.Executor.ExecWithContext(context.Background()) + result, err := d.Executor.ExecWithContext(ctx) return result.ExitCode, err } @@ -105,7 +105,7 @@ func (d *Dsu) FetchUpdateFiles(dstDir string) (int, error) { // ApplyLocalUpdates installs update files fetched by FetchUpdateFiles() // DSU needs to be pointed to the right inventory bin or it barfs // returns the resulting exitcode and error if any -func (d *Dsu) ApplyLocalUpdates(updateDir string) (int, error) { +func (d *Dsu) ApplyLocalUpdates(ctx context.Context, updateDir string) (int, error) { // ensure the updates directory exists _, err := os.Stat(updateDir) if err != nil { @@ -140,17 +140,17 @@ func (d *Dsu) ApplyLocalUpdates(updateDir string) (int, error) { }, ) - result, err := d.Executor.ExecWithContext(context.Background()) + result, err := d.Executor.ExecWithContext(ctx) return result.ExitCode, err } // Inventory collects inventory with the dell-system-update utility and // updates device component firmware based on data listed by the dell system update tool -func (d *Dsu) Inventory() ([]*model.Component, error) { +func (d *Dsu) Inventory(ctx context.Context) ([]*model.Component, error) { d.Executor.SetArgs([]string{"--import-public-key", "--inventory"}) - result, err := d.Executor.ExecWithContext(context.Background()) + result, err := d.Executor.ExecWithContext(ctx) if err != nil { return nil, err } @@ -164,10 +164,10 @@ func (d *Dsu) Inventory() ([]*model.Component, error) { } // Returns component firmware updates available based on the dell system update -func (d *Dsu) ComponentFirmwareUpdatePreview() ([]*model.Component, int, error) { +func (d *Dsu) ComponentFirmwareUpdatePreview(ctx context.Context) ([]*model.Component, int, error) { d.Executor.SetArgs([]string{"--import-public-key", "--preview"}) - result, err := d.Executor.ExecWithContext(context.Background()) + result, err := d.Executor.ExecWithContext(ctx) if err != nil { return nil, result.ExitCode, err } diff --git a/utils/executor.go b/utils/executor.go index d3ae2c79..5310a8d2 100644 --- a/utils/executor.go +++ b/utils/executor.go @@ -116,7 +116,7 @@ func (e *Execute) ExecWithContext(ctx context.Context) (result *Result, err erro } } - cmd := exec.CommandContext(ctx, e.Cmd, e.Args...) + cmd := exec.CommandContext(ctx, e.Cmd, e.Args...) //nolint:gosec // This is a generic command so need to support this cmd.Env = append(cmd.Env, e.Env...) cmd.Stdin = e.Stdin diff --git a/utils/fake_executor.go b/utils/fake_executor.go index 0c6ee2ab..38033399 100644 --- a/utils/fake_executor.go +++ b/utils/fake_executor.go @@ -183,8 +183,7 @@ func (e *FakeExecute) GetCmd() string { return strings.Join(cmd, " ") } -var ( - nvmeListDummyJSON = []byte(`{ +var nvmeListDummyJSON = []byte(`{ "Devices" : [ { "NameSpace" : 1, @@ -215,4 +214,3 @@ var ( ] } `) -) diff --git a/utils/hdparm_test.go b/utils/hdparm_test.go index f2e42710..10e9b0bd 100644 --- a/utils/hdparm_test.go +++ b/utils/hdparm_test.go @@ -14,7 +14,6 @@ func Test_HdparmDriveCapabilities(t *testing.T) { device := "/dev/sda" capabilities, err := h.DriveCapabilities(context.TODO(), device) - if err != nil { t.Fatal(err) } @@ -22,276 +21,275 @@ func Test_HdparmDriveCapabilities(t *testing.T) { assert.Equal(t, fixtureHdparmDeviceCapabilities, capabilities) } -var ( - fixtureHdparmDeviceCapabilities = []*common.Capability{ - { - Name: "sf", - Description: "SMART feature", - Enabled: true, - }, - { - Name: "smf", - Description: "Security Mode feature", - Enabled: false, - }, - { - Name: "pmf", - Description: "Power Management feature", - Enabled: true, - }, - { - Name: "wc", - Description: "Write cache", - Enabled: true, - }, - { - Name: "la", - Description: "Look ahead", - Enabled: true, - }, - { - Name: "hpaf", - Description: "Host Protected Area feature", - Enabled: true, - }, - { - Name: "wb", - Description: "WRITE BUFFER", - Enabled: true, - }, - { - Name: "rb", - Description: "READ BUFFER", - Enabled: true, - }, - { - Name: "nc", - Description: "NOP cmd", - Enabled: true, - }, - { - Name: "dm", - Description: "DOWNLOAD MICROCODE", - Enabled: true, - }, - { - Name: "smse", - Description: "SET MAX security extension", - Enabled: false, - }, - { - Name: "4baf", - Description: "48 bit Address feature", - Enabled: true, - }, - { - Name: "dcof", - Description: "Device Configuration Overlay feature", - Enabled: true, - }, - { - Name: "mfc", - Description: "Mandatory FLUSH CACHE", - Enabled: true, - }, - { - Name: "fce", - Description: "FLUSH CACHE EXT", - Enabled: true, - }, - { - Name: "sel", - Description: "SMART error logging", - Enabled: true, - }, - { - Name: "sst", - Description: "SMART self test", - Enabled: true, - }, - { - Name: "gplf", - Description: "General Purpose Logging feature", - Enabled: true, - }, - { - Name: "wdfe", - Description: "WRITE DMAMULTIPLE FUA EXT", - Enabled: true, - }, - { - Name: "6bwwn", - Description: "64 bit World wide name", - Enabled: true, - }, - { - Name: "wrvf", - Description: "Write Read Verify feature", - Enabled: false, - }, - { - Name: "wue", - Description: "WRITE UNCORRECTABLE EXT", - Enabled: true, - }, - { - Name: "rdegs", - Description: "READWRITE DMA EXT GPL s", - Enabled: true, - }, - { - Name: "sdm", - Description: "Segmented DOWNLOAD MICROCODE", - Enabled: true, - }, - { - Name: "gss1", - Description: "Gen1 signaling speed 1.5Gb/s", - Enabled: true, - }, - { - Name: "gss3", - Description: "Gen2 signaling speed 3.0Gb/s", - Enabled: true, - }, - { - Name: "gss6", - Description: "Gen3 signaling speed 6.0Gb/s", - Enabled: true, - }, - { - Name: "ncqn", - Description: "Native Command Queueing NCQ", - Enabled: true, - }, - { - Name: "pec", - Description: "Phy event counters", - Enabled: true, - }, - { - Name: "rldeetrle", - Description: "READ LOG DMA EXT equivalent to READ LOG EXT", - Enabled: true, - }, - { - Name: "dsaao", - Description: "DMA Setup Auto Activate optimization", - Enabled: true, - }, - { - Name: "diipm", - Description: "Device initiated interface power management", - Enabled: true, - }, - { - Name: "anemc", - Description: "Asynchronous notification eg. media change", - Enabled: true, - }, - { - Name: "stp", - Description: "Software tings preservation", - Enabled: true, - }, - { - Name: "dsd", - Description: "Device Sleep DEVSLP", - Enabled: false, - }, - { - Name: "sctsf", - Description: "SMART Command Transport SCT feature", - Enabled: true, - }, - { - Name: "swsa", - Description: "SCT Write Same AC2", - Enabled: true, - }, - { - Name: "serca", - Description: "SCT Error Recovery Control AC3", - Enabled: true, - }, - { - Name: "sfca", - Description: "SCT Features Control AC4", - Enabled: true, - }, - { - Name: "sdta", - Description: "SCT Data Tables AC5", - Enabled: true, - }, - { - Name: "deaud", - Description: "Device encrypts all user data", - Enabled: true, - }, - { - Name: "dmd", - Description: "DOWNLOAD MICROCODE DMA", - Enabled: true, - }, - { - Name: "smsds", - Description: "SET MAX SETPASSWORD/UNLOCK DMA s", - Enabled: true, - }, - { - Name: "wbd", - Description: "WRITE BUFFER DMA", - Enabled: true, - }, - { - Name: "rbd", - Description: "READ BUFFER DMA", - Enabled: true, - }, - { - Name: "dsmtsl8b", - Description: "Data Set Management TRIM supported limit 8 blocks", - Enabled: true, - }, - { - Name: "pns", - Description: "password not set", - Enabled: true, - }, - { - Name: "es", - Description: "encryption supported", - Enabled: true, - }, - { - Name: "ena", - Description: "encryption not active", - Enabled: true, - }, - { - Name: "dnl", - Description: "device is not locked", - Enabled: true, - }, - { - Name: "dnf", - Description: "device is not frozen", - Enabled: true, - }, - { - Name: "ene", - Description: "encryption not expired", - Enabled: true, - }, - { - Name: "esee", - Description: "encryption supports enhanced erase", - Enabled: true, - }, - { - Name: "time2:8", - Description: "erase time: 2m, 8m (enhanced)", - Enabled: false, - }} -) +var fixtureHdparmDeviceCapabilities = []*common.Capability{ + { + Name: "sf", + Description: "SMART feature", + Enabled: true, + }, + { + Name: "smf", + Description: "Security Mode feature", + Enabled: false, + }, + { + Name: "pmf", + Description: "Power Management feature", + Enabled: true, + }, + { + Name: "wc", + Description: "Write cache", + Enabled: true, + }, + { + Name: "la", + Description: "Look ahead", + Enabled: true, + }, + { + Name: "hpaf", + Description: "Host Protected Area feature", + Enabled: true, + }, + { + Name: "wb", + Description: "WRITE BUFFER", + Enabled: true, + }, + { + Name: "rb", + Description: "READ BUFFER", + Enabled: true, + }, + { + Name: "nc", + Description: "NOP cmd", + Enabled: true, + }, + { + Name: "dm", + Description: "DOWNLOAD MICROCODE", + Enabled: true, + }, + { + Name: "smse", + Description: "SET MAX security extension", + Enabled: false, + }, + { + Name: "4baf", + Description: "48 bit Address feature", + Enabled: true, + }, + { + Name: "dcof", + Description: "Device Configuration Overlay feature", + Enabled: true, + }, + { + Name: "mfc", + Description: "Mandatory FLUSH CACHE", + Enabled: true, + }, + { + Name: "fce", + Description: "FLUSH CACHE EXT", + Enabled: true, + }, + { + Name: "sel", + Description: "SMART error logging", + Enabled: true, + }, + { + Name: "sst", + Description: "SMART self test", + Enabled: true, + }, + { + Name: "gplf", + Description: "General Purpose Logging feature", + Enabled: true, + }, + { + Name: "wdfe", + Description: "WRITE DMAMULTIPLE FUA EXT", + Enabled: true, + }, + { + Name: "6bwwn", + Description: "64 bit World wide name", + Enabled: true, + }, + { + Name: "wrvf", + Description: "Write Read Verify feature", + Enabled: false, + }, + { + Name: "wue", + Description: "WRITE UNCORRECTABLE EXT", + Enabled: true, + }, + { + Name: "rdegs", + Description: "READWRITE DMA EXT GPL s", + Enabled: true, + }, + { + Name: "sdm", + Description: "Segmented DOWNLOAD MICROCODE", + Enabled: true, + }, + { + Name: "gss1", + Description: "Gen1 signaling speed 1.5Gb/s", + Enabled: true, + }, + { + Name: "gss3", + Description: "Gen2 signaling speed 3.0Gb/s", + Enabled: true, + }, + { + Name: "gss6", + Description: "Gen3 signaling speed 6.0Gb/s", + Enabled: true, + }, + { + Name: "ncqn", + Description: "Native Command Queueing NCQ", + Enabled: true, + }, + { + Name: "pec", + Description: "Phy event counters", + Enabled: true, + }, + { + Name: "rldeetrle", + Description: "READ LOG DMA EXT equivalent to READ LOG EXT", + Enabled: true, + }, + { + Name: "dsaao", + Description: "DMA Setup Auto Activate optimization", + Enabled: true, + }, + { + Name: "diipm", + Description: "Device initiated interface power management", + Enabled: true, + }, + { + Name: "anemc", + Description: "Asynchronous notification eg. media change", + Enabled: true, + }, + { + Name: "stp", + Description: "Software tings preservation", + Enabled: true, + }, + { + Name: "dsd", + Description: "Device Sleep DEVSLP", + Enabled: false, + }, + { + Name: "sctsf", + Description: "SMART Command Transport SCT feature", + Enabled: true, + }, + { + Name: "swsa", + Description: "SCT Write Same AC2", + Enabled: true, + }, + { + Name: "serca", + Description: "SCT Error Recovery Control AC3", + Enabled: true, + }, + { + Name: "sfca", + Description: "SCT Features Control AC4", + Enabled: true, + }, + { + Name: "sdta", + Description: "SCT Data Tables AC5", + Enabled: true, + }, + { + Name: "deaud", + Description: "Device encrypts all user data", + Enabled: true, + }, + { + Name: "dmd", + Description: "DOWNLOAD MICROCODE DMA", + Enabled: true, + }, + { + Name: "smsds", + Description: "SET MAX SETPASSWORD/UNLOCK DMA s", + Enabled: true, + }, + { + Name: "wbd", + Description: "WRITE BUFFER DMA", + Enabled: true, + }, + { + Name: "rbd", + Description: "READ BUFFER DMA", + Enabled: true, + }, + { + Name: "dsmtsl8b", + Description: "Data Set Management TRIM supported limit 8 blocks", + Enabled: true, + }, + { + Name: "pns", + Description: "password not set", + Enabled: true, + }, + { + Name: "es", + Description: "encryption supported", + Enabled: true, + }, + { + Name: "ena", + Description: "encryption not active", + Enabled: true, + }, + { + Name: "dnl", + Description: "device is not locked", + Enabled: true, + }, + { + Name: "dnf", + Description: "device is not frozen", + Enabled: true, + }, + { + Name: "ene", + Description: "encryption not expired", + Enabled: true, + }, + { + Name: "esee", + Description: "encryption supports enhanced erase", + Enabled: true, + }, + { + Name: "time2:8", + Description: "erase time: 2m, 8m (enhanced)", + Enabled: false, + }, +} diff --git a/utils/lsblk_test.go b/utils/lsblk_test.go index d0599663..d7a10f05 100644 --- a/utils/lsblk_test.go +++ b/utils/lsblk_test.go @@ -19,43 +19,41 @@ func Test_lsblk_Drives(t *testing.T) { assert.Equal(t, fixtureLsblkDrives, drives) } -var ( - fixtureLsblkDrives = []*common.Drive{ - { - Common: common.Common{ - Model: "MTFDDAV240TDU", - Serial: "203329F89392", - LogicalName: "/dev/sda", - }, - Protocol: "sata", - StorageControllerDriveID: -1, +var fixtureLsblkDrives = []*common.Drive{ + { + Common: common.Common{ + Model: "MTFDDAV240TDU", + Serial: "203329F89392", + LogicalName: "/dev/sda", }, - { - Common: common.Common{ - Model: "MTFDDAV240TDU", - Serial: "203329F89796", - LogicalName: "/dev/sdb", - }, - Protocol: "sata", - StorageControllerDriveID: -1, + Protocol: "sata", + StorageControllerDriveID: -1, + }, + { + Common: common.Common{ + Model: "MTFDDAV240TDU", + Serial: "203329F89796", + LogicalName: "/dev/sdb", }, - { - Common: common.Common{ - Model: "Micron_9300_MTFDHAL3T8TDP", - Serial: "202728F691F5", - LogicalName: "/dev/nvme0", - }, - Protocol: "nvme", - StorageControllerDriveID: -1, + Protocol: "sata", + StorageControllerDriveID: -1, + }, + { + Common: common.Common{ + Model: "Micron_9300_MTFDHAL3T8TDP", + Serial: "202728F691F5", + LogicalName: "/dev/nvme0", }, - { - Common: common.Common{ - Model: "Micron_9300_MTFDHAL3T8TDP", - Serial: "202728F691C6", - LogicalName: "/dev/nvme1", - }, - Protocol: "nvme", - StorageControllerDriveID: -1, + Protocol: "nvme", + StorageControllerDriveID: -1, + }, + { + Common: common.Common{ + Model: "Micron_9300_MTFDHAL3T8TDP", + Serial: "202728F691C6", + LogicalName: "/dev/nvme1", }, - } -) + Protocol: "nvme", + StorageControllerDriveID: -1, + }, +} diff --git a/utils/lshw.go b/utils/lshw.go index 58864c96..60e05c84 100644 --- a/utils/lshw.go +++ b/utils/lshw.go @@ -34,8 +34,10 @@ type LshwOutput []*LshwNode // fields of the ChildNodes in the lshw output // theres some fields with non-string attributes, in these fields, which are currently ignored -type LshwNodeConfiguration map[string]string -type LshwNodeCapabilities map[string]interface{} +type ( + LshwNodeConfiguration map[string]string + LshwNodeCapabilities map[string]interface{} +) // lshw -json output is unmarshalled into this struct // each ChildNode is a LshwNode with almost all of the same fields @@ -105,7 +107,7 @@ func (l *Lshw) Collect(ctx context.Context, device *common.Device) error { l.Device = device // lshw output - lshwDevice, err := l.ListJSON() + lshwDevice, err := l.ListJSON(ctx) if err != nil { return errors.Wrap(err, ErrParseLshwOutput.Error()) } @@ -141,11 +143,11 @@ func (l *Lshw) Collect(ctx context.Context, device *common.Device) error { } // ListJSON returns the lshw output as a struct -func (l *Lshw) ListJSON() (*LshwOutput, error) { +func (l *Lshw) ListJSON(ctx context.Context) (*LshwOutput, error) { // lshw -json -notime l.Executor.SetArgs([]string{"-json", "-notime", "-numeric"}) - result, err := l.Executor.ExecWithContext(context.Background()) + result, err := l.Executor.ExecWithContext(ctx) if err != nil { return nil, err } @@ -670,7 +672,7 @@ func NewFakeLshw(stdin io.Reader) *Lshw { } // ExecWithContext implements the utils.Executor interface -func (e *FakeLshwExecute) ExecWithContext(ctx context.Context) (*Result, error) { +func (e *FakeLshwExecute) ExecWithContext(context.Context) (*Result, error) { b := bytes.Buffer{} _, err := b.ReadFrom(e.Stdin) diff --git a/utils/lshw_test.go b/utils/lshw_test.go index aefc26e2..56176d54 100644 --- a/utils/lshw_test.go +++ b/utils/lshw_test.go @@ -9,7 +9,6 @@ import ( "github.com/bmc-toolbox/common" asrrFixtures "github.com/metal-toolbox/ironlib/fixtures/asrr" dellFixtures "github.com/metal-toolbox/ironlib/fixtures/dell" - "github.com/stretchr/testify/assert" ) diff --git a/utils/mlxup.go b/utils/mlxup.go index f47d3982..e241c1a5 100644 --- a/utils/mlxup.go +++ b/utils/mlxup.go @@ -65,7 +65,7 @@ func (m *Mlxup) Attributes() (utilName model.CollectorUtility, absolutePath stri // NICs returns a slice of mellanox components as *common.NIC's func (m *Mlxup) NICs(ctx context.Context) ([]*common.NIC, error) { - devices, err := m.Query() + devices, err := m.Query(ctx) if err != nil { return nil, err } @@ -152,7 +152,7 @@ func setNICFirmware(d *MlxupDevice, firmware *common.Firmware) { // UpdateNIC updates mellanox NIC with the given update file func (m *Mlxup) UpdateNIC(ctx context.Context, updateFile, modelNumber string) error { // query list of nics - nics, err := m.Query() + nics, err := m.Query(ctx) if err != nil { return err } @@ -187,11 +187,11 @@ func (m *Mlxup) UpdateNIC(ctx context.Context, updateFile, modelNumber string) e } // Query returns a slice of mellanox devices -func (m *Mlxup) Query() ([]*MlxupDevice, error) { +func (m *Mlxup) Query(ctx context.Context) ([]*MlxupDevice, error) { // mlxup --query m.Executor.SetArgs([]string{"--query"}) - result, err := m.Executor.ExecWithContext(context.Background()) + result, err := m.Executor.ExecWithContext(ctx) if err != nil { return nil, err } diff --git a/utils/msecli.go b/utils/msecli.go index 6fb16d2a..6bb22e97 100644 --- a/utils/msecli.go +++ b/utils/msecli.go @@ -12,9 +12,7 @@ import ( "github.com/pkg/errors" ) -var ( - ErrMseCliDriveNotIdentified = errors.New("failed to identify drive for update") -) +var ErrMseCliDriveNotIdentified = errors.New("failed to identify drive for update") const ( EnvMsecliUtility = "IRONLIB_UTIL_MSECLI" @@ -60,8 +58,8 @@ func (m *Msecli) Attributes() (utilName model.CollectorUtility, absolutePath str } // Drives returns a slice of drive components identified -func (m *Msecli) Drives(_ context.Context) ([]*common.Drive, error) { - devices, err := m.Query() +func (m *Msecli) Drives(ctx context.Context) ([]*common.Drive, error) { + devices, err := m.Query(ctx) if err != nil { return nil, err } @@ -91,7 +89,7 @@ func (m *Msecli) Drives(_ context.Context) ([]*common.Drive, error) { // UpdateDrive installs drive updates func (m *Msecli) UpdateDrive(ctx context.Context, updateFile, modelNumber, serialNumber string) error { // query list of drives - drives, err := m.Query() + drives, err := m.Query(ctx) if err != nil { return err } @@ -161,10 +159,10 @@ func (m *Msecli) updateDrive(ctx context.Context, modelNumber, updateFile string } // Query parses the output of mseli -L and returns a slice of *MsecliDevice's -func (m *Msecli) Query() ([]*MsecliDevice, error) { +func (m *Msecli) Query(ctx context.Context) ([]*MsecliDevice, error) { m.Executor.SetArgs([]string{"-L"}) - result, err := m.Executor.ExecWithContext(context.Background()) + result, err := m.Executor.ExecWithContext(ctx) if err != nil { return nil, err } diff --git a/utils/msecli_test.go b/utils/msecli_test.go index 0e9190da..658fbf27 100644 --- a/utils/msecli_test.go +++ b/utils/msecli_test.go @@ -61,7 +61,7 @@ func Test_MsecliDrives(t *testing.T) { t.Error(err) } - drives, err := m.Drives(context.TODO()) + drives, err := m.Drives(context.Background()) if err != nil { t.Error(err) } @@ -129,6 +129,6 @@ func Test_QueryOutputEmpty(t *testing.T) { m.Executor.SetArgs([]string{"-L"}) - _, err = m.Query() + _, err = m.Query(context.Background()) assert.Equal(t, ErrNoCommandOutput, errors.Cause(err)) } diff --git a/utils/mvcli.go b/utils/mvcli.go index da199f0b..be161f1e 100644 --- a/utils/mvcli.go +++ b/utils/mvcli.go @@ -226,7 +226,7 @@ func (m *Mvcli) Info(ctx context.Context, infoType string) ([]*MvcliDevice, erro m.Executor.SetArgs([]string{"info", "-o", infoType}) - result, err := m.Executor.ExecWithContext(context.Background()) + result, err := m.Executor.ExecWithContext(ctx) if err != nil { return nil, err } @@ -397,7 +397,8 @@ func (m *Mvcli) Create(ctx context.Context, physicalDiskIDs []uint, raidMode, na return InvalidInitModeError(initMode) } - m.Executor.SetArgs([]string{"create", + m.Executor.SetArgs([]string{ + "create", "-o", "vd", "-r", raidMode, "-d", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(physicalDiskIDs)), ","), "[]"), @@ -418,7 +419,7 @@ func (m *Mvcli) Create(ctx context.Context, physicalDiskIDs []uint, raidMode, na // Specified RAID mode is not supported. // Gigabyte rounding scheme is not supported - if match, _ := regexp.MatchString(`^SG driver version \S+\n$`, string(result.Stdout)); !match { + if match, _ := regexp.Match(`^SG driver version \S+\n$`, result.Stdout); !match { return CreateVirtualDiskError(result.Stdout) } @@ -427,7 +428,8 @@ func (m *Mvcli) Create(ctx context.Context, physicalDiskIDs []uint, raidMode, na func (m *Mvcli) Destroy(ctx context.Context, virtualDiskID int) error { m.Executor.SetStdin(bytes.NewReader([]byte("y\n"))) - m.Executor.SetArgs([]string{"delete", + m.Executor.SetArgs([]string{ + "delete", "-o", "vd", "-i", fmt.Sprintf("%d", virtualDiskID), }) @@ -444,7 +446,7 @@ func (m *Mvcli) Destroy(ctx context.Context, virtualDiskID int) error { // Possible errors: // Unable to get status of VD \S (error 59: Specified virtual disk doesn't exist). - if match, _ := regexp.MatchString(`Delete VD \S successfully.`, string(result.Stdout)); !match { + if match, _ := regexp.Match(`Delete VD \S successfully.`, result.Stdout); !match { return DestroyVirtualDiskError(result.Stdout) } @@ -461,7 +463,6 @@ func (m *Mvcli) FindVdByID(ctx context.Context, virtualDiskID int) *MvcliDevice func (m *Mvcli) FindVdBy(ctx context.Context, k string, v interface{}) *MvcliDevice { virtualDisks, err := m.VirtualDisks(ctx) - if err != nil { return nil } diff --git a/utils/nvme.go b/utils/nvme.go index 8fd6286a..38227493 100644 --- a/utils/nvme.go +++ b/utils/nvme.go @@ -204,7 +204,7 @@ func (n *Nvme) DriveCapabilities(ctx context.Context, logicalName string) ([]*co case (fnaStart || saniStart): capability := new(common.Capability) - var partsLen = 2 + partsLen := 2 parts := strings.Split(line, ":") if len(parts) != partsLen { @@ -234,7 +234,7 @@ func (n *Nvme) DriveCapabilities(ctx context.Context, logicalName string) ([]*co case (fnaBool && !fnaEnd && !isBlank): capability := new(common.Capability) - var partsLen = 3 + partsLen := 3 parts := strings.Split(line, ":") if len(parts) != partsLen { @@ -265,7 +265,7 @@ func (n *Nvme) DriveCapabilities(ctx context.Context, logicalName string) ([]*co case (saniBool && !saniEnd && !isBlank): capability := new(common.Capability) - var partsLen = 3 + partsLen := 3 parts := strings.Split(line, ":") if len(parts) != partsLen { diff --git a/utils/nvme_test.go b/utils/nvme_test.go index 9c0321d0..a69e295c 100644 --- a/utils/nvme_test.go +++ b/utils/nvme_test.go @@ -10,7 +10,8 @@ import ( func Test_NvmeComponents(t *testing.T) { expected := []*common.Drive{ - {Common: common.Common{Serial: "Z9DF70I8FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", + {Common: common.Common{ + Serial: "Z9DF70I8FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", Metadata: map[string]string{ "Additional media modification after sanitize operation completes successfully is not defined": "false", "Block Erase Sanitize Operation Not Supported": "false", @@ -24,7 +25,8 @@ func Test_NvmeComponents(t *testing.T) { "Sanitize Support": "false", }, }}, - {Common: common.Common{Serial: "Z9DF70I9FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", + {Common: common.Common{ + Serial: "Z9DF70I9FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", Metadata: map[string]string{ "Additional media modification after sanitize operation completes successfully is not defined": "false", "Block Erase Sanitize Operation Not Supported": "false", @@ -63,57 +65,55 @@ func Test_NvmeDriveCapabilities(t *testing.T) { assert.Equal(t, fixtureNvmeDeviceCapabilities, capabilities) } -var ( - fixtureNvmeDeviceCapabilities = []*common.Capability{ - { - Name: "sanicap", - Description: "Sanitize Support", - Enabled: false, - }, - { - Name: "ammasocsind", - Description: "Additional media modification after sanitize operation completes successfully is not defined", - Enabled: false, - }, - { - Name: "nasbiscs", - Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", - Enabled: false, - }, - { - Name: "osons", - Description: "Overwrite Sanitize Operation Not Supported", - Enabled: false, - }, - { - Name: "besons", - Description: "Block Erase Sanitize Operation Not Supported", - Enabled: false, - }, - { - Name: "cesons", - Description: "Crypto Erase Sanitize Operation Not Supported", - Enabled: false, - }, - { - Name: "fna", - Description: "Crypto Erase Support", - Enabled: true, - }, - { - Name: "cesapose", - Description: "Crypto Erase Supported as part of Secure Erase", - Enabled: true, - }, - { - Name: "ceatsn", - Description: "Crypto Erase Applies to Single Namespace(s)", - Enabled: false, - }, - { - Name: "fatsn", - Description: "Format Applies to Single Namespace(s)", - Enabled: false, - }, - } -) +var fixtureNvmeDeviceCapabilities = []*common.Capability{ + { + Name: "sanicap", + Description: "Sanitize Support", + Enabled: false, + }, + { + Name: "ammasocsind", + Description: "Additional media modification after sanitize operation completes successfully is not defined", + Enabled: false, + }, + { + Name: "nasbiscs", + Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", + Enabled: false, + }, + { + Name: "osons", + Description: "Overwrite Sanitize Operation Not Supported", + Enabled: false, + }, + { + Name: "besons", + Description: "Block Erase Sanitize Operation Not Supported", + Enabled: false, + }, + { + Name: "cesons", + Description: "Crypto Erase Sanitize Operation Not Supported", + Enabled: false, + }, + { + Name: "fna", + Description: "Crypto Erase Support", + Enabled: true, + }, + { + Name: "cesapose", + Description: "Crypto Erase Supported as part of Secure Erase", + Enabled: true, + }, + { + Name: "ceatsn", + Description: "Crypto Erase Applies to Single Namespace(s)", + Enabled: false, + }, + { + Name: "fatsn", + Description: "Format Applies to Single Namespace(s)", + Enabled: false, + }, +} diff --git a/utils/smartctl.go b/utils/smartctl.go index ad7f21ac..beee8157 100644 --- a/utils/smartctl.go +++ b/utils/smartctl.go @@ -16,19 +16,17 @@ import ( const EnvSmartctlUtility = "IRONLIB_UTIL_SMARTCTL" -var ( - // map of smartctl error bits to explanation - man 8 smartctl - smartclErrors = map[int]string{ - 0: "Command line did not parse", - 1: "Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode", - 2: "Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure", - 3: "SMART status check returned 'DISK FAILING'", - 4: "We found prefail Attributes <= threshold", - 5: "SMART status check returned 'DISK OK' but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past", - 6: "The device error log contains records of errors", - 7: "The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored", - } -) +// map of smartctl error bits to explanation - man 8 smartctl +var smartclErrors = map[int]string{ + 0: "Command line did not parse", + 1: "Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode", + 2: "Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure", + 3: "SMART status check returned 'DISK FAILING'", + 4: "We found prefail Attributes <= threshold", + 5: "SMART status check returned 'DISK OK' but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past", + 6: "The device error log contains records of errors", + 7: "The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored", +} type Smartctl struct { Executor Executor @@ -89,14 +87,14 @@ func (s *Smartctl) Attributes() (utilName model.CollectorUtility, absolutePath s func (s *Smartctl) Drives(ctx context.Context) ([]*common.Drive, error) { drives := make([]*common.Drive, 0) - DrivesList, err := s.Scan() + DrivesList, err := s.Scan(ctx) if err != nil { return nil, err } for _, drive := range DrivesList.Drives { // collect drive information with smartctl -a - smartctlAll, err := s.All(drive.Name) + smartctlAll, err := s.All(ctx, drive.Name) if err != nil { return nil, err } @@ -144,10 +142,10 @@ func (s *Smartctl) Drives(ctx context.Context) ([]*common.Drive, error) { } // Scan runs smartctl scan -j and returns its value as an object -func (s *Smartctl) Scan() (*SmartctlScan, error) { +func (s *Smartctl) Scan(ctx context.Context) (*SmartctlScan, error) { s.Executor.SetArgs([]string{"--scan", "-j"}) - result, err := s.Executor.ExecWithContext(context.Background()) + result, err := s.Executor.ExecWithContext(ctx) if err != nil { return nil, err } @@ -167,12 +165,12 @@ func (s *Smartctl) Scan() (*SmartctlScan, error) { } // All runs smartctl -a /dev/ and returns its value as an object -func (s *Smartctl) All(device string) (*SmartctlDriveAttributes, error) { +func (s *Smartctl) All(ctx context.Context, device string) (*SmartctlDriveAttributes, error) { // smartctl -a /dev/sda1 -j s.Executor.SetArgs([]string{"-a", device, "-j"}) // smartctl can exit with a non-zero status based on drive smart data - result, _ := s.Executor.ExecWithContext(context.Background()) + result, _ := s.Executor.ExecWithContext(ctx) // determine the errors if any based on the exit code smartCtlErrs := smartCtlExitStatus(result.ExitCode) @@ -284,7 +282,7 @@ func NewFakeSmartctl(dataDir string) *Smartctl { // nolint:gocyclo // test code // ExecWithContext implements the utils.Executor interface -func (e *FakeSmartctlExecute) ExecWithContext(ctx context.Context) (*Result, error) { +func (e *FakeSmartctlExecute) ExecWithContext(context.Context) (*Result, error) { switch e.Args[0] { case "--scan": b, err := os.ReadFile(e.JSONFilesDir + "/scan.json") diff --git a/utils/smartctl_test.go b/utils/smartctl_test.go index 4afa15ac..a72da2b8 100644 --- a/utils/smartctl_test.go +++ b/utils/smartctl_test.go @@ -27,7 +27,7 @@ func Test_SmartctlScan(t *testing.T) { s := newFakeSmartctl() - scan, err := s.Scan() + scan, err := s.Scan(context.Background()) if err != nil { t.Error(err) } @@ -39,7 +39,7 @@ func Test_SmartctlAllSCSI(t *testing.T) { expected := &SmartctlDriveAttributes{ModelName: "Micron_5200_MTFDDAK960TDN", ModelFamily: "Micron 5100 Pro / 5200 SSDs", SerialNumber: "2013273A99BD", FirmwareVersion: "D1MU020", Status: &SmartctlStatus{Passed: true}} s := newFakeSmartctl() - results, err := s.All("/dev/sda") + results, err := s.All(context.Background(), "/dev/sda") if err != nil { t.Error(err) } @@ -51,7 +51,7 @@ func Test_SmartctlAllNVME(t *testing.T) { expected := &SmartctlDriveAttributes{ModelName: "KXG60ZNV256G TOSHIBA", SerialNumber: "Z9DF70I8FY3L", FirmwareVersion: "AGGA4104", Status: &SmartctlStatus{Passed: true}} s := newFakeSmartctl() - results, err := s.All("/dev/nvme0") + results, err := s.All(context.Background(), "/dev/nvme0") if err != nil { t.Error(err) } @@ -69,7 +69,7 @@ func Test_SmartctlDeviceAttributes(t *testing.T) { } s := newFakeSmartctl() - drives, err := s.Drives(context.TODO()) + drives, err := s.Drives(context.Background()) if err != nil { t.Error(err) } @@ -95,7 +95,7 @@ func Test_SmartctlNonZeroExit(t *testing.T) { s := newFakeSmartctl() s.Executor.SetExitCode(4) - results, err := s.All("/dev/sdc") + results, err := s.All(context.Background(), "/dev/sdc") if err != nil { t.Error(err) } diff --git a/utils/smc_ipmicfg.go b/utils/smc_ipmicfg.go index 3bb2ea04..02e2e321 100644 --- a/utils/smc_ipmicfg.go +++ b/utils/smc_ipmicfg.go @@ -64,8 +64,8 @@ func NewFakeIpmicfg(r io.Reader) *Ipmicfg { } // BMC returns a SMC BMC component -func (i Ipmicfg) BMC(_ context.Context) (*common.BMC, error) { - summary, err := i.Summary() +func (i Ipmicfg) BMC(ctx context.Context) (*common.BMC, error) { + summary, err := i.Summary(ctx) if err != nil { return nil, err } @@ -86,7 +86,7 @@ func (i Ipmicfg) BMC(_ context.Context) (*common.BMC, error) { // BIOS returns a SMC BIOS component func (i *Ipmicfg) BIOS(ctx context.Context) (*common.BIOS, error) { - summary, err := i.Summary() + summary, err := i.Summary(ctx) if err != nil { return nil, err } @@ -108,7 +108,7 @@ func (i *Ipmicfg) BIOS(ctx context.Context) (*common.BIOS, error) { // CPLDs returns a slice of SMC CPLD components func (i Ipmicfg) CPLDs(ctx context.Context) ([]*common.CPLD, error) { - summary, err := i.Summary() + summary, err := i.Summary(ctx) if err != nil { return nil, err } @@ -127,11 +127,11 @@ func (i Ipmicfg) CPLDs(ctx context.Context) ([]*common.CPLD, error) { return cplds, nil } -func (i *Ipmicfg) Summary() (*IpmicfgSummary, error) { +func (i *Ipmicfg) Summary(ctx context.Context) (*IpmicfgSummary, error) { // smc-ipmicfg --summary i.Executor.SetArgs([]string{"-summary"}) - result, err := i.Executor.ExecWithContext(context.Background()) + result, err := i.Executor.ExecWithContext(ctx) if err != nil { return nil, err } diff --git a/utils/smc_sum_test.go b/utils/smc_sum_test.go index 78744160..9b01bb6f 100644 --- a/utils/smc_sum_test.go +++ b/utils/smc_sum_test.go @@ -43,7 +43,8 @@ func Test_SMCUpdateBios(t *testing.T) { } func Test_parseSMCBIOSConfig_X11SCHFF(t *testing.T) { - expected := map[string]string{"boot_mode": "BIOS", + expected := map[string]string{ + "boot_mode": "BIOS", "intel_sgx": "Software Controlled", "secure_boot": "Disabled", "smt": "Enabled", diff --git a/utils/storecli.go b/utils/storecli.go index 0436ec7a..80d16939 100644 --- a/utils/storecli.go +++ b/utils/storecli.go @@ -86,10 +86,10 @@ func NewFakeStoreCLI(r io.Reader) (*StoreCLI, error) { } // StorageControllers returns a slice of model.StorageControllers from the output of nvme list -func (s *StoreCLI) StorageControllers(_ context.Context) ([]*common.StorageController, error) { +func (s *StoreCLI) StorageControllers(ctx context.Context) ([]*common.StorageController, error) { controllers := make([]*common.StorageController, 0) - out, err := s.ShowController0() + out, err := s.ShowController0(ctx) if err != nil { return nil, err } @@ -126,11 +126,11 @@ func (s *StoreCLI) StorageControllers(_ context.Context) ([]*common.StorageContr } // ShowController0 runs storecli to list controller 0 -func (s *StoreCLI) ShowController0() ([]byte, error) { +func (s *StoreCLI) ShowController0(ctx context.Context) ([]byte, error) { // /opt/MegaRAID/storcli/storcli64 /c0 show J s.Executor.SetArgs([]string{"/c0", "show", "J"}) - result, err := s.Executor.ExecWithContext(context.Background()) + result, err := s.Executor.ExecWithContext(ctx) if err != nil { return nil, err } diff --git a/utils/uefi_vars.go b/utils/uefi_vars.go index 6d75e8b8..12f2f888 100644 --- a/utils/uefi_vars.go +++ b/utils/uefi_vars.go @@ -6,9 +6,7 @@ import ( "crypto/sha256" "fmt" "io/fs" - - //nolint:staticcheck // this is deprecated but I can't rewrite now - "io/ioutil" + "os" "path/filepath" "github.com/metal-toolbox/ironlib/model" @@ -44,14 +42,14 @@ func (UEFIVariableCollector) GetUEFIVars(ctx context.Context) (UEFIVars, error) // Capture all errors, even directories entry.Error = true uefivars[info.Name()] = entry - return nil // Keep walking + return nil //nolint:nilerr // Not an error, keep walking } // No need to capture anything for directory entries without errors if info.IsDir() { return nil } entry.Size = info.Size() - b, err := ioutil.ReadFile(path) + b, err := os.ReadFile(path) if err != nil { entry.Error = true } else {