Documentation
¶
Overview ¶
Package packages provides firmware package definition and loading.
Index ¶
- Variables
- type ComponentDef
- type FirmwarePackage
- type RedfishConfig
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) Get(version string) (*FirmwarePackage, error)
- func (r *Registry) GetFirmwarePath(pkg *FirmwarePackage, componentName string) (string, error)
- func (r *Registry) List() []string
- func (r *Registry) ListPackages() []*FirmwarePackage
- func (r *Registry) LoadFromDirectory(packagesDir string) error
- type SSHConfig
- type ScriptConfig
- type StrategyConfig
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var DefaultComponentOrder = []string{"bmc", "cpld", "bios", "nvos"}
DefaultComponentOrder defines the fallback update order when not specified in YAML. Update sequence: BMC → CPLD → BIOS → NVOS
Functions ¶
This section is empty.
Types ¶
type ComponentDef ¶
type ComponentDef struct {
// Version of this specific component
Version string `yaml:"version"`
// File is the relative path to the firmware file within the firmware directory
File string `yaml:"file"`
// Checksum for integrity verification (optional, format: "sha256:abc123...")
Checksum string `yaml:"checksum,omitempty"`
// Strategy specifies how this component is updated: "redfish", "ssh", or "script"
Strategy string `yaml:"strategy"`
// Script is the path to the update script (required when strategy is "script")
// Can be absolute or relative to the scripts directory
Script string `yaml:"script,omitempty"`
// ScriptArgs specifies which arguments to pass to the script (when strategy is "script")
// Each item is a token that resolves to a value at runtime.
// Valid tokens:
// - bmc_ip, bmc_user, bmc_password
// - nvos_ip, nvos_user, nvos_password
// - fw_file (path to firmware file)
// Example: [nvos_ip, nvos_user, nvos_password, fw_file]
ScriptArgs []string `yaml:"script_args,omitempty"`
}
ComponentDef defines a single component within a firmware bundle.
type FirmwarePackage ¶
type FirmwarePackage struct {
// Version is the unique identifier for this bundle (e.g., "1.0.0", "2024.01.15")
Version string `yaml:"version"`
// Description provides human-readable info about this bundle
Description string `yaml:"description,omitempty"`
// ComponentOrder defines the update sequence for components in this bundle.
// Components are updated in the order listed. If not specified, uses DefaultComponentOrder.
// e.g., ["bmc", "cpld", "bios", "nvos"]
ComponentOrder []string `yaml:"component_order,omitempty"`
// Components maps component name (lowercase) to its definition
// e.g., "bmc", "cpld", "bios", "nvos"
Components map[string]ComponentDef `yaml:"components"`
// StrategyConfig contains configuration for each update strategy
StrategyConfig StrategyConfig `yaml:"strategy_config,omitempty"`
}
FirmwarePackage represents a firmware bundle defined in YAML. The Version field serves as the unique identifier for the bundle.
func (*FirmwarePackage) GetComponent ¶
func (p *FirmwarePackage) GetComponent(name string) *ComponentDef
GetComponent returns the component definition for the given component name. Returns nil if the component is not found.
func (*FirmwarePackage) GetOrderedComponents ¶
func (p *FirmwarePackage) GetOrderedComponents() []string
GetOrderedComponents returns the components in this package in the correct update order. Uses the package's ComponentOrder if defined, otherwise falls back to DefaultComponentOrder. Only components present in the package are returned.
func (*FirmwarePackage) HasComponent ¶
func (p *FirmwarePackage) HasComponent(name string) bool
HasComponent returns true if the package contains the given component.
func (*FirmwarePackage) Validate ¶
func (p *FirmwarePackage) Validate() error
Validate checks that the package definition is valid.
type RedfishConfig ¶
type RedfishConfig struct {
// PollIntervalSeconds is how often to poll task status
PollIntervalSeconds int `yaml:"poll_interval_seconds,omitempty"`
// PollTimeoutSeconds is max time to wait for task completion
PollTimeoutSeconds int `yaml:"poll_timeout_seconds,omitempty"`
}
RedfishConfig contains configuration for Redfish-based updates.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry loads and provides access to firmware packages.
func NewRegistry ¶
NewRegistry creates a new package registry.
func (*Registry) Get ¶
func (r *Registry) Get(version string) (*FirmwarePackage, error)
Get retrieves a firmware package by version.
func (*Registry) GetFirmwarePath ¶
func (r *Registry) GetFirmwarePath(pkg *FirmwarePackage, componentName string) (string, error)
GetFirmwarePath returns the full filesystem path to a component's firmware file.
func (*Registry) ListPackages ¶
func (r *Registry) ListPackages() []*FirmwarePackage
ListPackages returns all loaded packages.
func (*Registry) LoadFromDirectory ¶
LoadFromDirectory loads all YAML package definitions from a directory.
type SSHConfig ¶
type SSHConfig struct {
// RemoteDir is the directory on the switch where files are copied
RemoteDir string `yaml:"remote_dir,omitempty"`
// RebootTimeoutSeconds is how long to wait for reboot (NVOS updates)
RebootTimeoutSeconds int `yaml:"reboot_timeout_seconds,omitempty"`
}
SSHConfig contains configuration for SSH-based updates.
type ScriptConfig ¶
type ScriptConfig struct {
// ScriptDir is the directory containing update scripts
ScriptDir string `yaml:"script_dir"`
// Timeout for script execution in seconds
TimeoutSeconds int `yaml:"timeout_seconds,omitempty"`
}
ScriptConfig contains configuration for script-based updates.
type StrategyConfig ¶
type StrategyConfig struct {
Script *ScriptConfig `yaml:"script,omitempty"`
SSH *SSHConfig `yaml:"ssh,omitempty"`
Redfish *RedfishConfig `yaml:"redfish,omitempty"`
}
StrategyConfig contains configuration for each update strategy.
type ValidationError ¶
ValidationError represents a validation error in the package definition.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string