actions

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

The inventory package ties together the various collectors under utils through its InventoryCollectorAction type.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInventoryDeviceObjNil = errors.New("method Inventory() expects a valid device object, got nil")
	ErrPanic                 = errors.New("recovered from panic")
)
View Source
var (
	ErrUpdaterUtilNotIdentified = errors.New("updater utility not identifed")
	ErrVendorComponentOptions   = errors.New("component vendor does not match update options vendor attribute")
)
View Source
var ErrVirtualDiskManagerUtilNotIdentified = errors.New("virtual disk management utility not identifed")

Functions

func UpdateAll

func UpdateAll(ctx context.Context, device *common.Device, options []*model.UpdateOptions) error

UpdateAll installs all updates based on given options, options acts as a filter

func UpdateBIOS

func UpdateBIOS(ctx context.Context, bios *common.BIOS, options *model.UpdateOptions) error

UpdateBIOS identifies the bios eligible for update from the inventory and runs the firmware update utility based on the bios vendor

func UpdateBMC

func UpdateBMC(ctx context.Context, bmc *common.BMC, options *model.UpdateOptions) error

UpdateBMC identifies the bios eligible for update from the inventory and runs the firmware update utility based on the bmc vendor

func UpdateComponent

func UpdateComponent(ctx context.Context, device *common.Device, option *model.UpdateOptions) error

func UpdateDrive

func UpdateDrive(ctx context.Context, drives []*common.Drive, options *model.UpdateOptions) error

UpdateDrive identifies the drive eligible for update from the inventory and runs the firmware update utility based on the drive vendor

func UpdateNIC

func UpdateNIC(ctx context.Context, nics []*common.NIC, options *model.UpdateOptions) error

UpdateNIC identifies the nic eligible for update from the inventory and runs the firmware update utility based on the nic vendor

func UpdateRequirements

func UpdateRequirements(componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error)

UpdateRequirements returns requirements to be met before and after a firmware install, the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.

Types

type BIOSCollector

type BIOSCollector interface {
	UtilAttributeGetter
	BIOS(ctx context.Context) (*common.BIOS, error)
}

BIOSCollector defines an interface to return BIOS inventory

type BIOSConfiguror

type BIOSConfiguror interface {
	// GetBIOSConfiguration returns the BIOS configuration for the device
	// deviceModel is an optional parameter depending on the hardware variants
	GetBIOSConfiguration(ctx context.Context, deviceModel string) (map[string]string, error)
}

BIOSConfiguror defines an interface to collect BIOS configuration

type BIOSUpdater

type BIOSUpdater interface {
	UtilAttributeGetter
	UpdateBIOS(ctx context.Context, updateFile, modelNumber string) error
}

BIOSUpdater defines an interface to update BIOS firmware

func GetBIOSUpdater

func GetBIOSUpdater(vendor string) (BIOSUpdater, error)

GetBIOSUpdater returns the updater for the given vendor

type BMCCollector

type BMCCollector interface {
	UtilAttributeGetter
	BMC(ctx context.Context) (*common.BMC, error)
}

BMCCollector defines an interface to return BMC inventory

type BMCUpdater

type BMCUpdater interface {
	UtilAttributeGetter
	UpdateBMC(ctx context.Context, updateFile, modelNumber string) error
}

BMCUpdater defines an interface to update BMC firmware

func GetBMCUpdater

func GetBMCUpdater(vendor string) (BMCUpdater, error)

GetBMCUpdater returns the updater for the given vendor

type CPLDCollector

type CPLDCollector interface {
	UtilAttributeGetter
	CPLDs(ctx context.Context) ([]*common.CPLD, error)
}

CPLDCollector defines an interface to return CPLD inventory

type CPLDUpdater

type CPLDUpdater interface {
	UtilAttributeGetter
	UpdateCPLD() error
}

CPLDUpdater defines an interface to update CPLD firmware

type Collectors

Collectors is a struct acting as a registry of various inventory collectors

func (*Collectors) Empty

func (c *Collectors) Empty() bool

Empty returns a bool value

type DeviceManager

type DeviceManager interface {
	Setter
	Getter
	Updater
}

DeviceManager interface is returned to the caller when calling ironlib.New()

type DriveCapabilityCollector

type DriveCapabilityCollector interface {
	UtilAttributeGetter
	DriveCapabilities(ctx context.Context, logicalName string) ([]*common.Capability, error)
}

DriveCapabilityCollector defines an interface to collect disk drive capability attributes

The logicalName is the kernel/OS assigned drive name - /dev/sdX or /dev/nvmeX

type DriveCollector

type DriveCollector interface {
	UtilAttributeGetter
	Drives(ctx context.Context) ([]*common.Drive, error)
}

DriveCollector defines an interface to return disk drive inventory

func DriveCollectorByStorageControllerVendor

func DriveCollectorByStorageControllerVendor(vendor string, trace bool) DriveCollector

type DriveUpdater

type DriveUpdater interface {
	UtilAttributeGetter
	UpdateDrive(ctx context.Context, updateFile, modelNumber, serialNumber string) error
}

DriveUpdater defines an interface to update drive firmware

func GetDriveUpdater

func GetDriveUpdater(vendor string) (DriveUpdater, error)

GetDriveUpdater returns the updater for the given vendor

type DriveWiper

type DriveWiper interface {
	// WipeDrive wipes away all data from the drive, wipe is always verified to have succeeded
	WipeDrive(context.Context, *logrus.Logger, *common.Drive) error
}

DriveWiper defines an interface to override disk data

type FirmwareChecksumCollector

type FirmwareChecksumCollector interface {
	UtilAttributeGetter
	// return the sha-256 of the BIOS logo as a string, or the associated error
	BIOSLogoChecksum(ctx context.Context) (string, error)
}

FirmwareChecksumCollector defines an interface to collect firmware checksums

type Getter

type Getter interface {
	// Get device model
	GetModel() string
	// Get device vendor
	GetVendor() string
	// Check the device reboot required flag
	RebootRequired() bool
	// Check if any updates were applied
	UpdatesApplied() bool
	// Retrieve inventory for the device
	GetInventory(ctx context.Context, options ...Option) (*common.Device, error)
	// Retrieve inventory using the OEM tooling for the device,
	GetInventoryOEM(ctx context.Context, device *common.Device, options *model.UpdateOptions) error
	// List updates identifed by the vendor tooling (DSU for dells)
	ListAvailableUpdates(ctx context.Context, options *model.UpdateOptions) (*common.Device, error)
	// Retrieve BIOS configuration for device
	GetBIOSConfiguration(ctx context.Context) (map[string]string, error)
	// UpdateRequirements returns requirements to be met before and after a firmware install
	UpdateRequirements(ctx context.Context, componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error)
}

Getter interface declares methods implemented by providers to return various attributes.

type InventoryCollector

type InventoryCollector interface {
	UtilAttributeGetter
	Collect(ctx context.Context, device *common.Device) error
}

InventoryCollector defines an interface to collect all device inventory

type InventoryCollectorAction

type InventoryCollectorAction struct {
	// contains filtered or unexported fields
}

InventoryCollectorAction provides methods to collect hardware, firmware inventory.

func NewInventoryCollectorAction

func NewInventoryCollectorAction(ll *logrus.Logger, options ...Option) *InventoryCollectorAction

NewActionrunner returns an Actions runner that is capable of collecting inventory.

func (*InventoryCollectorAction) Collect

func (a *InventoryCollectorAction) Collect(ctx context.Context, device *common.Device) error

Collect collects device inventory data based on the given collectors, the device object fields are updated based on the collected inventory

Inventory expects a device object and optionally a collectors object, when the collectors object provided is nil, the default collectors are added - lshw, smartctl

The lshw collector always executes first and is included by default. nolint:gocyclo //since we're collecting inventory for each type, this is cyclomatic

func (*InventoryCollectorAction) CollectBIOS

func (a *InventoryCollectorAction) CollectBIOS(ctx context.Context) (err error)

CollectBIOS executes the bios collector and updates device bios information

func (*InventoryCollectorAction) CollectBMC

func (a *InventoryCollectorAction) CollectBMC(ctx context.Context) (err error)

CollectBMC executes the bmc collector and updates device bmc information

func (*InventoryCollectorAction) CollectCPLDs

func (a *InventoryCollectorAction) CollectCPLDs(ctx context.Context) (err error)

CollectCPLDs executes the bmc collector and updates device cpld information

func (*InventoryCollectorAction) CollectDriveCapabilities

func (a *InventoryCollectorAction) CollectDriveCapabilities(ctx context.Context) (err error)

CollectDriveCapabilities executes drive capability collectors

The capability collector is identified based on the drive logical name.

func (*InventoryCollectorAction) CollectDrives

func (a *InventoryCollectorAction) CollectDrives(ctx context.Context) (err error)

CollectDrives executes drive collectors and merges the data into device.[]*Drive nolint:gocyclo // TODO(joel) if theres more conditionals to be added in here, the method is to be split up.

func (*InventoryCollectorAction) CollectFirmwareChecksums

func (a *InventoryCollectorAction) CollectFirmwareChecksums(ctx context.Context) (err error)

CollectFirmwareChecksums executes the Firmware checksum collector and updates the component metadata.

func (*InventoryCollectorAction) CollectNICs

func (a *InventoryCollectorAction) CollectNICs(ctx context.Context) (err error)

CollectNICs executes nic collectors and merges the nic data into device.[]*NIC

func (*InventoryCollectorAction) CollectStorageControllers

func (a *InventoryCollectorAction) CollectStorageControllers(ctx context.Context) (err error)

CollectStorageControllers executes the StorageControllers collectors and updates device storage controller data

func (*InventoryCollectorAction) CollectTPMs

func (a *InventoryCollectorAction) CollectTPMs(ctx context.Context) (err error)

CollectTPMs executes the TPM collector and updates device TPM information

func (*InventoryCollectorAction) CollectUEFIVariables

func (a *InventoryCollectorAction) CollectUEFIVariables(ctx context.Context) (err error)

CollectUEFIVariables executes the UEFI variable collector and stores them on the device object

type NICCollector

type NICCollector interface {
	UtilAttributeGetter
	NICs(ctx context.Context) ([]*common.NIC, error)
}

NICCollector defines an interface to returns NIC inventory

type NICUpdater

type NICUpdater interface {
	UtilAttributeGetter
	UpdateRequirementsGetter
	UpdateNIC(ctx context.Context, updateFile, modelNumber string, force bool) error
}

NICUpdater defines an interface to update NIC firmware

func GetNICUpdater

func GetNICUpdater(vendor string) (NICUpdater, error)

GetNICUpdater returns the updater for the given vendor

type Option

type Option func(*InventoryCollectorAction)

Option returns a function that sets a InventoryCollectorAction parameter

func WithCollectors

func WithCollectors(collectors *Collectors) Option

WithCollectors sets collectors to the ones passed in as a parameter.

func WithDisabledCollectorUtilities

func WithDisabledCollectorUtilities(utilityNames []model.CollectorUtility) Option

WithDisabledCollectorUtilities disables the given collector utilities.

func WithDynamicCollection

func WithDynamicCollection() Option

DynamicCollection when enabled will cause ironlib to identify collectors based on the detected component vendor.

func WithFailOnError

func WithFailOnError() Option

WithFailOnError sets the InventoryCollectorAction to return on any error that may occur when collecting inventory.

By default the InventoryCollectorAction continues to collect inventory even if one or more collectors fail.

func WithTraceLevel

func WithTraceLevel() Option

WithTraceLevel sets trace level logging on the action runner.

type RaidController

type RaidController interface {
	VirtualDiskCreator
	VirtualDiskDestroyer
}

RaidController interface declares methods to manage virtual disks.

type Setter

type Setter interface {
	SetBIOSConfiguration(ctx context.Context, config map[string]string) error
}

Setter interface declares methods to set attributes on a system.

type StorageControllerAction

type StorageControllerAction struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func NewStorageControllerAction

func NewStorageControllerAction(logger *logrus.Logger) *StorageControllerAction

func (*StorageControllerAction) CreateVirtualDisk

func (*StorageControllerAction) DestroyVirtualDisk

func (*StorageControllerAction) GetControllerUtility

func (s *StorageControllerAction) GetControllerUtility(vendorName, modelName string) (VirtualDiskManager, error)

GetControllerUtility returns the utility command for the given vendor

func (*StorageControllerAction) GetWipeUtility

func (s *StorageControllerAction) GetWipeUtility(drive *common.Drive) (DriveWiper, error)

GetWipeUtility returns the wipe utility based on the disk wipping features

func (*StorageControllerAction) ListVirtualDisks

func (*StorageControllerAction) WipeDrive

func (s *StorageControllerAction) WipeDrive(ctx context.Context, log *logrus.Logger, drive *common.Drive) error

type StorageControllerCollector

type StorageControllerCollector interface {
	UtilAttributeGetter
	StorageControllers(ctx context.Context) ([]*common.StorageController, error)
}

StorageControllerCollector defines an interface to returns storage controllers inventory

func StorageControllerCollectorByVendor

func StorageControllerCollectorByVendor(vendor string, trace bool) StorageControllerCollector

type StorageControllerUpdater

type StorageControllerUpdater interface {
	UtilAttributeGetter
	UpdateStorageController() error
}

StorageControllerUpdater defines an interface to update storage controller firmware

type TPMCollector

type TPMCollector interface {
	UtilAttributeGetter
	TPMs(ctx context.Context) ([]*common.TPM, error)
}

TPMCollector defines an interface to collect TPM device inventory

type UEFIVarsCollector

type UEFIVarsCollector interface {
	UtilAttributeGetter
	GetUEFIVars(ctx context.Context) (utils.UEFIVars, error)
}

UEFIVarsCollector defines an interface to collect EFI variables

type UpdateRequirementsGetter

type UpdateRequirementsGetter interface {
	UpdateRequirements(componentModel string) *model.UpdateRequirements
}

UpdateRequirements returns requirements to be met before and after a firmware install, the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.

type Updater

type Updater interface {
	// ApplyUpdate is to be deprecated in favor of InstallUpdates, its implementations are to be moved
	// to use InstallUpdates.
	ApplyUpdate(ctx context.Context, updateFile, component string) error

	// InstallUpdates installs updates based on the update options
	InstallUpdates(ctx context.Context, options *model.UpdateOptions) error
}

Updater defines an interface to install an update file

type Updaters

type Updaters struct {
	Drives             DriveUpdater
	NICs               NICUpdater
	BMC                BMCUpdater
	BIOS               BIOSUpdater
	StorageControllers StorageControllerUpdater
}

Updaters is a struct acting as a registry of various hardware component updaters

type UtilAttributeGetter

type UtilAttributeGetter interface {
	Attributes() (utilName model.CollectorUtility, absolutePath string, err error)
}

UtilAttributeGetter defines methods to retrieve utility attributes.

type Utility

type Utility interface {
	BIOSConfiguror
	InventoryCollector
	Updater
}

Utility interface couples the configuration, collection and update interfaces

type VirtualDiskCreator

type VirtualDiskCreator interface {
	CreateVirtualDisk(ctx context.Context, raidMode string, physicalDisks []uint, name string, blockSize uint) error
}

VirtualDiskCreator defines an interface to create virtual disks, generally via a StorageController

type VirtualDiskDestroyer

type VirtualDiskDestroyer interface {
	DestroyVirtualDisk(ctx context.Context, virtualDiskID int) error
}

VirtualDiskCreator defines an interface to destroy virtual disks, generally via a StorageController

type VirtualDiskManager

type VirtualDiskManager interface {
	VirtualDiskCreator
	VirtualDiskDestroyer
	VirtualDisks(ctx context.Context) ([]*utils.MvcliDevice, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL