componentmanager

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTyped

func GetTyped[T Provider](pr *ProviderRegistry, name string) (T, error)

GetTyped retrieves a provider by name and casts it to the expected type. Returns an error if the provider is not found or cannot be cast to the expected type.

Types

type ComponentManager

type ComponentManager interface {
	Type() devicetypes.ComponentType
	InjectExpectation(ctx context.Context, target common.Target, info operations.InjectExpectationTaskInfo) error //nolint
	PowerControl(ctx context.Context, target common.Target, info operations.PowerControlTaskInfo) error           //nolint
	GetPowerStatus(ctx context.Context, target common.Target) (map[string]operations.PowerStatus, error)          //nolint
	FirmwareControl(ctx context.Context, target common.Target, info operations.FirmwareControlTaskInfo) error     //nolint

	// StartFirmwareUpdate initiates firmware update without waiting for completion.
	// Returns immediately after the update request is accepted.
	StartFirmwareUpdate(ctx context.Context, target common.Target, info operations.FirmwareControlTaskInfo) error //nolint

	// GetFirmwareUpdateStatus returns the current status of firmware updates for the target components.
	// Returns a map of component ID to FirmwareUpdateStatus.
	GetFirmwareUpdateStatus(ctx context.Context, target common.Target) (map[string]operations.FirmwareUpdateStatus, error) //nolint

	// AllowBringUpAndPowerOn opens the power-on gate for the target components.
	AllowBringUpAndPowerOn(ctx context.Context, target common.Target) error //nolint

	// GetBringUpState returns the bring-up state for each target component.
	// Returns a map of component ID to MachineBringUpState.
	GetBringUpState(ctx context.Context, target common.Target) (map[string]operations.MachineBringUpState, error) //nolint
}

ComponentManager defines the interface for managing various types of components. Implementations handle component-specific operations like power control, firmware management, and status monitoring.

type Config

type Config struct {
	// ComponentManagers maps component types to their implementation names.
	ComponentManagers map[devicetypes.ComponentType]string

	// Providers holds provider-specific configuration.
	Providers ProviderConfig
}

Config holds the component manager configuration.

func DefaultProdConfig

func DefaultProdConfig() Config

DefaultProdConfig returns the embedded production configuration. Used when no config file is specified. Connects to external services

Timing parameters for operations are configured per-rule via action parameters.

func DefaultTestConfig

func DefaultTestConfig() Config

DefaultTestConfig returns the default configuration for testing/development. Uses mock implementations that don't require external services.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads the component manager configuration from a YAML file.

func ParseConfig

func ParseConfig(data []byte) (Config, error)

ParseConfig parses the component manager configuration from YAML data.

func (*Config) HasProvider

func (c *Config) HasProvider(name string) bool

HasProvider checks if a provider is enabled in the configuration.

type ManagerFactory

type ManagerFactory func(providers *ProviderRegistry) (ComponentManager, error)

ManagerFactory is a function that creates a ComponentManager instance. It receives a ProviderRegistry from which it can retrieve the providers it needs.

type Provider

type Provider interface {
	// Name returns the unique identifier for this provider type.
	Name() string
}

Provider is a marker interface for API client providers. Each provider wraps an API client and exposes it to component manager implementations.

type ProviderConfig

type ProviderConfig struct {
	// Carbide holds Carbide-specific configuration. Nil means disabled.
	Carbide *carbide.Config

	// PSM holds PSM-specific configuration. Nil means disabled.
	PSM *psm.Config

	// NVSwitchManager holds NV-Switch Manager-specific configuration. Nil means disabled.
	NVSwitchManager *nvswitchmanager.Config
}

ProviderConfig holds the configuration for API providers. A nil pointer means the provider is not enabled.

type ProviderRegistry

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

ProviderRegistry manages API providers for component manager implementations. It allows implementations to request their required providers by name.

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

NewProviderRegistry creates a new ProviderRegistry instance.

func (*ProviderRegistry) Get

func (pr *ProviderRegistry) Get(name string) Provider

Get retrieves a provider by name. Returns nil if the provider is not found.

func (*ProviderRegistry) Has

func (pr *ProviderRegistry) Has(name string) bool

Has checks if a provider with the given name is registered.

func (*ProviderRegistry) List

func (pr *ProviderRegistry) List() []string

List returns the names of all registered providers.

func (*ProviderRegistry) Register

func (pr *ProviderRegistry) Register(provider Provider) bool

Register adds a provider to the registry. Returns false if a provider with the same name already exists.

type Registry

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

Registry maintains a collection of component manager factories and active managers. It allows dynamic registration and selection of implementations per component type.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry instance.

func (*Registry) GetAllManagers

func (r *Registry) GetAllManagers() []ComponentManager

GetAllManagers returns all active managers.

func (*Registry) GetManager

func (r *Registry) GetManager(componentType devicetypes.ComponentType) ComponentManager

GetManager returns the active manager for the specified component type. Returns nil if no manager is active for the type.

func (*Registry) Initialize

func (r *Registry) Initialize(config Config, providers *ProviderRegistry) error

Initialize creates and activates component managers based on the provided configuration. The config maps component types to implementation names.

func (*Registry) ListRegisteredImplementations

func (r *Registry) ListRegisteredImplementations() map[devicetypes.ComponentType][]string

ListRegisteredImplementations returns a map of component types to their registered implementation names.

func (*Registry) RegisterFactory

func (r *Registry) RegisterFactory(
	componentType devicetypes.ComponentType,
	implName string,
	factory ManagerFactory,
) bool

RegisterFactory registers a factory for a specific component type and implementation name. Returns false if a factory with the same type and name already exists.

Directories

Path Synopsis
compute
nvlswitch
nvswitchmanager
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
powershelf
psm
providers
nvswitchmanager
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
psm

Jump to

Keyboard shortcuts

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