usecase

package
v1.19.2-redfish.preview.1 Latest Latest
Warning

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

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

Documentation

Overview

Package usecase provides interfaces for accessing Redfish computer system data.

Package usecase provides interfaces for accessing Redfish computer system data.

Package usecase provides a WSMAN-backed implementation of ComputerSystemRepository.

Index

Constants

View Source
const (
	// ComputerSystemODataType represents the OData type for ComputerSystem.
	ComputerSystemODataType = "#ComputerSystem.v1_26_0.ComputerSystem"

	// ComputerSystemODataContext represents the OData context for ComputerSystem.
	ComputerSystemODataContext = "/redfish/v1/$metadata#ComputerSystem.ComputerSystem"

	// RedfishSystemsBasePath represents the base path for Systems collection.
	RedfishSystemsBasePath = "/redfish/v1/Systems"

	// Default system type.
	DefaultSystemType = "Physical"
)

OData and schema constants for ComputerSystem.

View Source
const (
	HealthOK       = "OK"
	HealthWarning  = "Warning"
	HealthCritical = "Critical"
)

Resource Health constants.

View Source
const (
	StateEnabled            = "Enabled"
	StateDisabled           = "Disabled"
	StateStandbyOffline     = "StandbyOffline"
	StateStandbySpare       = "StandbySpare"
	StateInTest             = "InTest"
	StateStarting           = "Starting"
	StateAbsent             = "Absent"
	StateUnavailableOffline = "UnavailableOffline"
	StateDeferring          = "Deferring"
	StateQuiesced           = "Quiesced"
	StateUpdating           = "Updating"
	StateDegraded           = "Degraded"
)

Resource State constants.

View Source
const (
	// ErrMsgDeviceNotFound is the error message returned by devices use case when device is not found.
	ErrMsgDeviceNotFound = "DevicesUseCase -  - : "

	// CIM OperationalStatus constants for memory health mapping.
	CIMStatusOK                  = 2  // OK
	CIMStatusDegraded            = 3  // Degraded
	CIMStatusError               = 6  // Error
	CIMStatusNonRecoverableError = 7  // Non-Recoverable Error
	CIMStatusStressed            = 10 // Stressed

)

Variables

View Source
var (
	// ErrInvalidPowerState is returned when an invalid power state is requested.
	ErrInvalidPowerState = errors.New("invalid power state")

	// ErrPowerStateConflict is returned when a power state transition is not allowed.
	ErrPowerStateConflict = errors.New("power state transition not allowed")

	// ErrInvalidResetType is returned when an invalid reset type is provided.
	ErrInvalidResetType = errors.New("invalid reset type")

	// ErrInvalidBootSettings is returned when invalid boot settings are provided.
	ErrInvalidBootSettings = errors.New("invalid boot settings")

	// ErrInvalidBootTarget is returned when an invalid boot target is provided.
	ErrInvalidBootTarget = errors.New("invalid boot target")

	// ErrInvalidBootEnabled is returned when an invalid boot enabled setting is provided.
	ErrInvalidBootEnabled = errors.New("invalid boot enabled setting")

	// ErrSystemNotFound is returned when a system is not found.
	ErrSystemNotFound = errors.New("system not found")
)
View Source
var (
	// ErrGetAllNotImplemented is returned when GetAll is called (not yet implemented).
	ErrGetAllNotImplemented = errors.New("GetAll not implemented")

	// ErrUnsupportedPowerState is returned when an unsupported power state is requested.
	ErrUnsupportedPowerState = errors.New("unsupported power state")

	// ErrBootSettingsNotAvailable is returned when boot settings cannot be retrieved.
	ErrBootSettingsNotAvailable = errors.New("boot settings not available")

	// ErrUnsupportedBootTarget is returned when an unsupported boot target is requested.
	ErrUnsupportedBootTarget = errors.New("unsupported boot target")
)

Functions

func StringPtr

func StringPtr(s string) *string

StringPtr creates a pointer to a string value.

func SystemTypePtr

SystemTypePtr creates a pointer to a ComputerSystemSystemType value.

Types

type CIMObjectType

type CIMObjectType string

CIMObjectType represents different types of CIM objects.

const (
	CIMObjectChassis               CIMObjectType = "chassis"
	CIMObjectComputerSystemPackage CIMObjectType = "computersystem"
	CIMObjectBIOSElement           CIMObjectType = "bioselement"
	CIMObjectPhysicalMemory        CIMObjectType = "physicalmemory"
	CIMObjectProcessor             CIMObjectType = "processor"
	CIMObjectChip                  CIMObjectType = "chip"
)

type CIMPropertyConfig

type CIMPropertyConfig struct {
	CIMObject    CIMObjectType     // Which CIM object to extract from
	CIMProperty  string            // The property name in the CIM object
	StructField  string            // Optional: key name for storing in results map (defaults to CIMProperty)
	Transformer  PropertyExtractor // Optional transformation function
	UseFirstItem bool              // For array responses, use first item (default: true)
}

CIMPropertyConfig defines the configuration for extracting a property from CIM data.

type ComputerSystemRepository

type ComputerSystemRepository interface {
	GetAll(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, systemID string) (*redfishv1.ComputerSystem, error)
	UpdatePowerState(ctx context.Context, systemID string, state redfishv1.PowerState) error
	GetBootSettings(ctx context.Context, systemID string) (*generated.ComputerSystemBoot, error)
	UpdateBootSettings(ctx context.Context, systemID string, boot *generated.ComputerSystemBoot) error
}

ComputerSystemRepository defines the interface for computer system data access.

type ComputerSystemUseCase

type ComputerSystemUseCase struct {
	Repo ComputerSystemRepository
}

ComputerSystemUseCase provides business logic for ComputerSystem entities.

func (*ComputerSystemUseCase) GetAll

func (uc *ComputerSystemUseCase) GetAll(ctx context.Context) ([]string, error)

GetAll retrieves all ComputerSystem IDs from the repository.

func (*ComputerSystemUseCase) GetComputerSystem

func (uc *ComputerSystemUseCase) GetComputerSystem(ctx context.Context, systemID string) (*generated.ComputerSystemComputerSystem, error)

GetComputerSystem retrieves a ComputerSystem by its systemID and converts it to the generated API type.

func (*ComputerSystemUseCase) SetPowerState

func (uc *ComputerSystemUseCase) SetPowerState(ctx context.Context, id string, resetType generated.ResourceResetType) error

SetPowerState validates and sets the power state for a ComputerSystem.

func (*ComputerSystemUseCase) UpdateBootSettings

func (uc *ComputerSystemUseCase) UpdateBootSettings(ctx context.Context, systemID string, boot *generated.ComputerSystemBoot) error

UpdateBootSettings updates the boot configuration for a ComputerSystem.

type PropertyExtractor

type PropertyExtractor func(interface{}) interface{}

PropertyExtractor defines a function signature for custom property transformation.

type WsmanComputerSystemRepo

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

WsmanComputerSystemRepo implements ComputerSystemRepository using WSMAN backend.

func NewWsmanComputerSystemRepo

func NewWsmanComputerSystemRepo(uc *devices.UseCase, log logger.Interface) *WsmanComputerSystemRepo

NewWsmanComputerSystemRepo creates a new WSMAN-backed computer system repository.

func (*WsmanComputerSystemRepo) GetAll

func (r *WsmanComputerSystemRepo) GetAll(ctx context.Context) ([]string, error)

GetAll retrieves all computer system IDs from the WSMAN backend.

func (*WsmanComputerSystemRepo) GetBootSettings

func (r *WsmanComputerSystemRepo) GetBootSettings(ctx context.Context, systemID string) (*generated.ComputerSystemBoot, error)

GetBootSettings retrieves the current boot configuration for a system.

func (*WsmanComputerSystemRepo) GetByID

GetByID retrieves a computer system by its ID from the WSMAN backend.

func (*WsmanComputerSystemRepo) UpdateBootSettings

func (r *WsmanComputerSystemRepo) UpdateBootSettings(ctx context.Context, systemID string, boot *generated.ComputerSystemBoot) error

UpdateBootSettings updates the boot configuration for a system.

func (*WsmanComputerSystemRepo) UpdatePowerState

func (r *WsmanComputerSystemRepo) UpdatePowerState(ctx context.Context, systemID string, resetType redfishv1.PowerState) error

UpdatePowerState sends a power action command to the specified system via WSMAN.

Directories

Path Synopsis
Package sessions provides session management use cases for Redfish SessionService
Package sessions provides session management use cases for Redfish SessionService

Jump to

Keyboard shortcuts

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