model

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName               = "flasher"
	AppKindWorker AppKind = "worker"
	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 (
	ErrPublishStatus = errors.New("error in publish Condition status")
	ErrPublishTask   = errors.New("error in publish Condition Task")
)
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 (
	// 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 CopyAsGenericTask added in v1.1.0

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

func SingularComponent added in v1.1.0

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 added in v1.0.8

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 added in v1.1.0

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

type AppKind

type AppKind string

func AppKinds

func AppKinds() []AppKind

AppKinds returns the supported flasher 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 flasher 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 Publisher added in v1.0.8

type Publisher interface {
	Publish(ctx context.Context, task *Task) error
}

Publisher defines methods to publish task information.

func NewTaskStatusPublisher added in v1.1.0

func NewTaskStatusPublisher(logger *logrus.Entry, cp ctrl.Publisher) Publisher

type RunMode added in v1.1.0

type RunMode string

type StatusPublisher added in v1.0.8

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

StatusPublisher implements the Publisher interface to wrap the condition controller publish method

func (*StatusPublisher) Publish added in v1.0.8

func (s *StatusPublisher) Publish(ctx context.Context, task *Task) error

type Step added in v1.0.8

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 added in v1.0.8

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

func (*Step) SetStatus added in v1.0.8

func (s *Step) SetStatus(status string)

type StepGroup added in v1.0.8

type StepGroup string

StepGroup identifies a group of units.

type StepHandler added in v1.0.8

type StepHandler func(ctx context.Context) error

StepHandler defines the signature for each action unit to be executed

type StepName added in v1.0.8

type StepName string

StepName identifies a single step within an action

type Steps added in v1.0.8

type Steps []*Step

Steps is the list of steps to be executed

func (Steps) ByGroup added in v1.0.8

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

ByGroup returns steps identified by the matching Group attribute

func (Steps) ByName added in v1.0.8

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

ByName returns the step identified by its name

func (Steps) Remove added in v1.0.8

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 added in v1.1.0

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

func NewTask added in v1.0.8

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

func (*Task) MustMarshal added in v1.1.0

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

func (*Task) SetState

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

type TaskData added in v1.1.0

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"`

	// Flasher 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 added in v1.1.0

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

func (*TaskData) Marshal added in v1.1.0

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

func (*TaskData) Unmarshal added in v1.1.0

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