model

package
v0.0.0-...-19f5c96 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AppName                = "agent"
	AppKindService AppKind = "service"
	AppKindCLI     AppKind = "cli"

	RunInband    RunMode = "inband"
	RunOutofband RunMode = "outofband"

	InventoryStoreYAML          StoreKind = "yaml"
	InventoryStoreServerservice StoreKind = "serverservice"

	LogLevelInfo  LogLevel = "info"
	LogLevelDebug LogLevel = "debug"
	LogLevelTrace LogLevel = "trace"
)
View Source
const (
	// InstallMethodOutofband indicates the out of band firmware install method.
	InstallMethodOutofband InstallMethod = "outofband"
	InstallMethodInband    InstallMethod = "inband"

	// FromFirmwareSet is a TaskParameter attribute that declares the
	// the firmware versions to be installed are to be planned from the given firmware set ID.
	FromFirmwareSet FirmwarePlanMethod = "fromFirmwareSet"

	// FromRequestedFirmware is a TaskParameter attribute that declares the
	// firmware versions to be installed have been defined as part of the request,
	// and so no further firmware planning is required.
	FromRequestedFirmware FirmwarePlanMethod = "fromRequestedFirmware"

	// task states
	//
	// states the task state machine transitions through
	StatePending   = rctypes.Pending
	StateActive    = rctypes.Active
	StateSucceeded = rctypes.Succeeded
	StateFailed    = rctypes.Failed

	TaskDataStructVersion = "1.0"
)
View Source
const (
	// Each action may be tried upto these many times.
	ActionMaxAttempts = 3
)
View Source
const (
	// Each action may be tried upto these many times.
	StepMaxAttempts = 2
)

Variables

View Source
var (
	ErrInstalledFirmwareEqual = errors.New("installed and expected firmware are equal, no action necessary")
	ErrHostPowerCycleRequired = errors.New("host powercycle required")
)
View Source
var (
	// ErrComponentConverter is returned when an error occurs in the component data conversion.
	ErrComponentConverter = errors.New("error in component converter")
)
View Source
var (
	ErrInitTask = errors.New("error initializing new task from condition")
)
View Source
var (
	// FirmwareInstallOrder defines the order in which firmware is installed.
	//
	// TODO(joel): fix up bmc-toolbox/common slugs to be of lower case instead of upper
	// nolint:gomnd // component install order number is clear as is.
	FirmwareInstallOrder = map[string]int{
		strings.ToLower(common.SlugBMC):               0,
		strings.ToLower(common.SlugBIOS):              1,
		strings.ToLower(common.SlugCPLD):              2,
		strings.ToLower(common.SlugDrive):             3,
		strings.ToLower(common.SlugBackplaneExpander): 4,
		strings.ToLower(common.SlugStorageController): 5,
		strings.ToLower(common.SlugNIC):               6,
		strings.ToLower(common.SlugPSU):               7,
		strings.ToLower(common.SlugTPM):               8,
		strings.ToLower(common.SlugGPU):               9,
		strings.ToLower(common.SlugCPU):               10,
	}
)

Functions

func ConditionKinds

func ConditionKinds() []rctypes.Kind

Returns the Conditions supported by this agent

func CopyAsGenericTask

func CopyAsGenericTask(task *Task) (*rctypes.Task[any, any], error)

func SingularComponent

func SingularComponent(slug string) bool

These components are in most cases are present in a single package and from one vendor in a server, in comparison to drives, nics, raid controllers which could be in multiples and from different vendors for these 'singular' components we don't require to compare the exact model number for a firmware install.

Types

type Action

type Action struct {
	// ID is a unique identifier for this action
	ID string `json:"id"`

	// The parent task identifier
	TaskID string `json:"task_id"`

	// BMCTaskID is the task identifier to track a BMC job
	// these are returned when the firmware is uploaded and is being verified
	// or an install was initiated on the BMC .
	BMCTaskID string `json:"bmc_task_id,omitempty"`

	// Set to the component identified as the target of the firmware install
	Component *rtypes.Component `json:"component"`

	// Method of install
	InstallMethod InstallMethod `json:"install_method"`

	// status indicates the action state
	State rctypes.State `json:"state"`

	// Firmware to be installed, this is set in the Task Plan phase.
	Firmware rctypes.Firmware `json:"firmware"`

	// In the remote inband case a list of firmwares will be delegated for install
	Firmwares []rctypes.Firmware `json:"firmwares"`

	FirmwareInstallStep string `json:"firmware_install_step"`

	// FirmwareTempFile is the temporary file downloaded to be installed.
	//
	// This is declared once the firmware file has been downloaded for install.
	FirmwareTempFile string `json:"firmware_temp_file"`

	// ForceInstall will cause the action to skip checking the currently installed component firmware
	ForceInstall bool `json:"verify_current_firmware"`

	// BMC reset required before install
	BMCResetPreInstall bool `json:"bmc_reset_pre_install"`

	// BMC reset required after install
	BMCResetPostInstall bool `json:"bmc_reset_post_install"`

	// BMC reset required on install failure
	BMCResetOnInstallFailure bool `json:"bmc_reset_on_install_failure"`

	// HostPowerCycled is set when the host has been power cycled for the action.
	HostPowerCycled bool `json:"host_power_cycled"`

	// HostPowerCycleInitiated indicates when a power cycle has been initated for the host.
	HostPowerCycleInitiated bool `json:"host_power_cycle_initiated"`

	// HostPowerOffInitiated indicates a power off was initated on the host.
	HostPowerOffInitiated bool `json:"host_power_off_initiated"`

	// HostPowerOffPreInstall is set when the firmware install provider indicates
	// the host must be powered off before proceeding with the install step.
	HostPowerOffPreInstall bool `json:"host_power_off_pre_install"`

	// First is set to true when its the first action being executed
	First bool `json:"first"`

	// Last is set to true when its the last action being executed
	Last bool `json:"last"`

	// Attempts indicates how many times this action has been tried
	Attempts int `json:"attempts"`

	// Steps identify the smallest unit of work executed by an action
	Steps Steps `json:"steps"`
}

Action holds attributes for each firmware to be installed

func (*Action) SetID

func (a *Action) SetID(taskID, componentSlug string, idx int)

func (*Action) SetState

func (a *Action) SetState(state rctypes.State)

type Actions

type Actions []*Action

Actions is a list of actions

func (Actions) ByID

func (a Actions) ByID(id string) *Action

ByID returns the Action matched by the identifier

func (Actions) Prepend

func (a Actions) Prepend(action *Action) Actions

type AppKind

type AppKind string

func AppKinds

func AppKinds() []AppKind

AppKinds returns the supported agent app kinds

type ComponentConverter

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

ComponentConvertor provides methods to convert a common.Device to its Component equivalents.

func NewComponentConverter

func NewComponentConverter() *ComponentConverter

NewComponentConverter returns a new ComponentConvertor

func (*ComponentConverter) CommonDeviceToComponents

func (cc *ComponentConverter) CommonDeviceToComponents(device *common.Device) (rtypes.Components, error)

CommonDeviceToComponents converts a bmc-toolbox/common Device object to its agent Components type

TODO(joel): the bmc-toolbox/common Device component types could implement an interface with methods to retrieve component - firmware installed, vendor, model, serial, slug attributes this method can then call the interface methods instead of multiple small methods for each device component type.

type FirmwarePlanMethod

type FirmwarePlanMethod string

FirmwarePlanMethod type defines the firmware resolution method by which the firmware to applied is planned.

type InstallMethod

type InstallMethod string

InstallMethod is one of 'outofband' OR 'inband' it is the method by which the firmware is installed on the device.

type LogLevel

type LogLevel string

LogLevel is the logging level string.

type RunMode

type RunMode string

type Step

type Step struct {
	Name        StepName      `json:"name"`
	Handler     StepHandler   `json:"-"`
	Group       StepGroup     `json:"step_group"`
	PostStep    StepHandler   `json:"-"`
	Description string        `json:"doc"`
	State       rctypes.State `json:"state"`
	Status      string        `json:"status"`
	Attempts    int           `json:"attempts"`
}

Step is the smallest unit of work within an Action

func (*Step) SetState

func (s *Step) SetState(state rctypes.State)

func (*Step) SetStatus

func (s *Step) SetStatus(status string)

type StepGroup

type StepGroup string

StepGroup identifies a group of units.

type StepHandler

type StepHandler func(ctx context.Context) error

StepHandler defines the signature for each action unit to be executed

type StepName

type StepName string

StepName identifies a single step within an action

type Steps

type Steps []*Step

Steps is the list of steps to be executed

func (Steps) ByGroup

func (us Steps) ByGroup(name StepGroup) (found Steps, err error)

ByGroup returns steps identified by the matching Group attribute

func (Steps) ByName

func (us Steps) ByName(name StepName) (u Step, err error)

ByName returns the step identified by its name

func (Steps) Remove

func (us Steps) Remove(name StepName) (final Steps)

type StoreKind

type StoreKind string

func StoreKinds

func StoreKinds() []StoreKind

StoreKinds returns the supported asset inventory, firmware configuration sources

type Task

Alias parameterized model.Task

func CopyAsFwInstallTask

func CopyAsFwInstallTask(task *rctypes.Task[any, any]) (*Task, error)

func NewTask

func NewTask(conditionID uuid.UUID, kind rctypes.Kind, params *rctypes.FirmwareInstallTaskParameters) (Task, error)

func (*Task) MustMarshal

func (t *Task) MustMarshal() json.RawMessage

func (*Task) SetState

func (t *Task) SetState(s rctypes.State)

type TaskData

type TaskData struct {
	StructVersion string `json:"struct_version"`

	// This flag is set when a action requires a host power cycle.
	HostPowercycleRequired bool `json:"host_powercycle_required,omitempty"`

	// Agent determines the firmware to be installed for each component based on the firmware plan method.
	FirmwarePlanMethod FirmwarePlanMethod `json:"firmware_plan_method,omitempty"`

	// ActionsPlanned to be executed for each firmware to be installed.
	ActionsPlanned Actions `json:"actions_planned,omitempty"`

	// Scratch is an arbitrary key values map available to all task, action handler methods.
	Scratch map[string]string `json:"scratch,omitempty"`
}

func (*TaskData) MapStringInterfaceToStruct

func (td *TaskData) MapStringInterfaceToStruct(m map[string]interface{}) error

func (*TaskData) Marshal

func (td *TaskData) Marshal() (json.RawMessage, error)

func (*TaskData) Unmarshal

func (td *TaskData) Unmarshal(r json.RawMessage) error

Jump to

Keyboard shortcuts

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