model

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AppName               = "flasher"
	AppKindWorker AppKind = "worker"
	AppKindCLI    AppKind = "cli"

	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"

	// 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   sw.State = sw.State(rctypes.Pending)
	StateActive    sw.State = sw.State(rctypes.Active)
	StateSucceeded sw.State = sw.State(rctypes.Succeeded)
	StateFailed    sw.State = sw.State(rctypes.Failed)
)

Variables

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

This section is empty.

Types

type Action

type Action struct {
	// ID is a unique identifier for this action
	ID string

	// The parent task identifier
	TaskID string

	// 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

	// Method of install
	InstallMethod InstallMethod

	// Firmware to be installed, this is set in the Task Plan phase.
	Firmware Firmware

	FirmwareInstallStep string

	// FirwareTempFile is the temporary file downloaded to be installed.
	//
	// This is declared once the firmware file has been downloaded for install.
	FirmwareTempFile string

	// VerifyCurrentFirmware will cause the action to verify the current firmware
	// on the component is not equal to one being installed. If its equal, the action will return an error.
	VerifyCurrentFirmware bool

	// BMC reset required before install
	BMCResetPreInstall bool

	// BMC reset required after install
	BMCResetPostInstall bool

	// BMC reset required on install failure
	BMCResetOnInstallFailure bool

	// HostPowerCycled is set when the host has been power cycled for the action.
	HostPowerCycled bool

	// Final is set to true when its the last action being executed
	Final bool
	// contains filtered or unexported fields
}

Action holds attributes of a Task sub-statemachine

func (*Action) SetState

func (a *Action) SetState(state sw.State) error

func (*Action) State

func (a *Action) State() sw.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

type AppKind

type AppKind string

func AppKinds

func AppKinds() []AppKind

AppKinds returns the supported flasher app kinds

type Asset

type Asset struct {
	ID uuid.UUID

	// Device BMC attributes
	BmcAddress  net.IP
	BmcUsername string
	BmcPassword string

	// Inventory status attribute
	State string

	// Manufacturer attributes
	Vendor string
	Model  string
	Serial string

	// Facility this Asset is hosted in.
	FacilityCode string

	// Device components
	Components Components
}

Asset holds attributes of a server retrieved from the inventory store.

nolint:govet // fieldalignment struct is easier to read in the current format

type Component

type Component struct {
	Slug              string
	Serial            string
	Vendor            string
	Model             string
	FirmwareInstalled string
}

Component is a device component

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) (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 Components

type Components []*Component

Components is a slice of Component on which one or more methods may be available.

func (Components) BySlugModel added in v0.2.5

func (c Components) BySlugModel(cSlug string, cModels []string) *Component

BySlug returns a component that matches the slug value.

type DeviceQueryor

type DeviceQueryor interface {
	// Open opens the connection to the device.
	Open(ctx context.Context) error

	// Close closes the connection to the device.
	Close(ctx context.Context) error

	PowerStatus(ctx context.Context) (status string, err error)

	SetPowerState(ctx context.Context, state string) error

	ResetBMC(ctx context.Context) error

	// Reinitializes the underlying device queryor client to purge old session information.
	ReinitializeClient(ctx context.Context)

	// Inventory returns the device inventory
	Inventory(ctx context.Context) (*common.Device, error)

	FirmwareInstallSteps(ctx context.Context, component string) ([]bconsts.FirmwareInstallStep, error)

	FirmwareUpload(ctx context.Context, component string, reader *os.File) (uploadVerifyTaskID string, err error)

	FirmwareTaskStatus(ctx context.Context, kind bconsts.FirmwareInstallStep, component, taskID, installVersion string) (state bconsts.TaskState, status string, err error)

	FirmwareInstallUploaded(ctx context.Context, component, uploadVerifyTaskID string) (installTaskID string, err error)

	FirmwareInstallUploadAndInitiate(ctx context.Context, component string, file *os.File) (taskID string, err error)
}

DeviceQueryor interface defines methods to query a device.

This is common interface to the ironlib and bmclib libraries.

type Firmware

type Firmware struct {
	ID        string   `yaml:"id"`
	Vendor    string   `yaml:"vendor"`
	Models    []string `yaml:"models"`
	FileName  string   `yaml:"filename"`
	Version   string   `yaml:"version"`
	URL       string   `yaml:"URL"`
	Component string   `yaml:"component"`
	Checksum  string   `yaml:"checksum"`
}

Firmware includes a firmware version attributes and is part of FirmwareConfig

nolint:govet // fieldalignment struct is easier to read in the current format

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 StatusMsg added in v0.2.7

type StatusMsg struct {
	Timestamp time.Time `json:"ts,omitempty"`
	Msg       string    `json:"msg,omitempty"`
}

type StatusRecord added in v0.2.7

type StatusRecord struct {
	StatusMsgs []StatusMsg `json:"records"`
}

func NewTaskStatusRecord added in v0.2.7

func NewTaskStatusRecord(s string) StatusRecord

func (*StatusRecord) Append added in v0.2.7

func (sr *StatusRecord) Append(s string)

func (*StatusRecord) Last added in v1.0.0

func (sr *StatusRecord) Last() string

func (*StatusRecord) MustMarshal added in v0.2.7

func (sr *StatusRecord) MustMarshal() json.RawMessage

func (*StatusRecord) Update added in v1.0.0

func (sr *StatusRecord) Update(currentMsg, newMsg string)

type StoreKind

type StoreKind string

func StoreKinds

func StoreKinds() []StoreKind

StoreKinds returns the supported asset inventory, firmware configuration sources

type Task

type Task struct {
	// Task unique identifier, this is set to the Condition identifier.
	ID uuid.UUID

	// status holds informational data on the state
	Status StatusRecord

	// Flasher determines the firmware to be installed for each component based on the firmware plan method.
	FirmwarePlanMethod FirmwarePlanMethod

	// ActionsPlanned to be executed for task are generated from the InstallFirmwares and install parameters
	// these are generated in the `pending` stage of the task.
	ActionsPlanned Actions

	// Parameters for this task
	Parameters rctypes.FirmwareInstallTaskParameters

	// Fault is a field to inject failures into a flasher task execution,
	// this is set from the Condition only when the worker is run with fault-injection enabled.
	Fault *rctypes.Fault `json:"fault,omitempty"`

	CreatedAt   time.Time
	UpdatedAt   time.Time
	CompletedAt time.Time
	// contains filtered or unexported fields
}

Task is a top level unit of work handled by flasher.

A task performs one or more actions, each of the action corresponds to a Firmware planned for install.

nolint:govet // fieldalignment - struct is better readable in its current form.

func (*Task) SetState

func (t *Task) SetState(state sw.State) error

SetState implements the stateswitch statemachine interface

func (*Task) State

func (t *Task) State() sw.State

State implements the stateswitch statemachine interface

Jump to

Keyboard shortcuts

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