Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions api/v1alpha1/biosversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
package v1alpha1

import (
"github.com/stmcginnis/gofish/common"
"github.com/stmcginnis/gofish/redfish"
"github.com/stmcginnis/gofish/schemas"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -102,11 +101,11 @@ type Task struct {

// State is the current state of the task.
// +optional
State redfish.TaskState `json:"state,omitempty"`
State schemas.TaskState `json:"state,omitempty"`

// Status is the current status of the task.
// +optional
Status common.Health `json:"status,omitempty"`
Status schemas.Health `json:"status,omitempty"`

// PercentComplete is the percentage of completion of the task.
// +optional
Expand Down
16 changes: 8 additions & 8 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package v1alpha1

import "github.com/stmcginnis/gofish/redfish"
import "github.com/stmcginnis/gofish/schemas"

// establishing general rule for constants naming for Annotations
// "Key" for Annotation constants should be named OperationAnnotation.
Expand Down Expand Up @@ -69,11 +69,11 @@ const (
GracefulRestartBMC = "graceful-restart-bmc"
)

var AnnotationToRedfishMapping = map[string]redfish.ResetType{
GracefulRestartServerPower: redfish.GracefulRestartResetType,
HardRestartServerPower: redfish.ForceRestartResetType,
PowerCycleServerPower: redfish.PowerCycleResetType,
ForceOffServerPower: redfish.ForceOffResetType,
ForceOnServerPower: redfish.ForceOnResetType,
GracefulRestartBMC: redfish.GracefulRestartResetType,
var AnnotationToRedfishMapping = map[string]schemas.ResetType{
GracefulRestartServerPower: schemas.GracefulRestartResetType,
HardRestartServerPower: schemas.ForceRestartResetType,
PowerCycleServerPower: schemas.PowerCycleResetType,
ForceOffServerPower: schemas.ForceOffResetType,
ForceOnServerPower: schemas.ForceOnResetType,
GracefulRestartBMC: schemas.GracefulRestartResetType,
}
59 changes: 29 additions & 30 deletions bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"fmt"

"github.com/stmcginnis/gofish"
"github.com/stmcginnis/gofish/common"
"github.com/stmcginnis/gofish/redfish"
"github.com/stmcginnis/gofish/schemas"
"k8s.io/apimachinery/pkg/api/resource"

"github.com/ironcore-dev/metal-operator/bmc/oem"
Expand All @@ -37,7 +36,7 @@ type BMC interface {
ForcePowerOff(ctx context.Context, systemURI string) error

// Reset performs a reset on the system.
Reset(ctx context.Context, systemURI string, resetType redfish.ResetType) error
Reset(ctx context.Context, systemURI string, resetType schemas.ResetType) error

// SetPXEBootOnce sets the boot device for the next system boot.
SetPXEBootOnce(ctx context.Context, systemURI string) error
Expand All @@ -52,37 +51,37 @@ type BMC interface {
GetSystems(ctx context.Context) ([]Server, error)

// GetManager returns the manager
GetManager(UUID string) (*redfish.Manager, error)
GetManager(UUID string) (*schemas.Manager, error)

// ResetManager performs a reset on the Manager.
ResetManager(ctx context.Context, UUID string, resetType redfish.ResetType) error
ResetManager(ctx context.Context, UUID string, resetType schemas.ResetType) error

// GetBootOrder retrieves the boot order for the system.
GetBootOrder(ctx context.Context, systemURI string) ([]string, error)

// GetBiosAttributeValues retrieves BIOS attribute values for the system.
GetBiosAttributeValues(ctx context.Context, systemURI string, attributes []string) (redfish.SettingsAttributes, error)
GetBiosAttributeValues(ctx context.Context, systemURI string, attributes []string) (schemas.SettingsAttributes, error)

// GetBiosPendingAttributeValues retrieves pending BIOS attribute values for the system.
GetBiosPendingAttributeValues(ctx context.Context, systemURI string) (redfish.SettingsAttributes, error)
GetBiosPendingAttributeValues(ctx context.Context, systemURI string) (schemas.SettingsAttributes, error)

// GetBMCAttributeValues retrieves BMC attribute values for the system.
GetBMCAttributeValues(ctx context.Context, UUID string, attributes map[string]string) (redfish.SettingsAttributes, error)
GetBMCAttributeValues(ctx context.Context, UUID string, attributes map[string]string) (schemas.SettingsAttributes, error)

// GetBMCPendingAttributeValues retrieves pending BMC attribute values for the system.
GetBMCPendingAttributeValues(ctx context.Context, UUID string) (result redfish.SettingsAttributes, err error)
GetBMCPendingAttributeValues(ctx context.Context, UUID string) (result schemas.SettingsAttributes, err error)

// CheckBiosAttributes checks if the BIOS attributes are valid and returns whether a reset is required.
CheckBiosAttributes(attrs redfish.SettingsAttributes) (reset bool, err error)
CheckBiosAttributes(attrs schemas.SettingsAttributes) (reset bool, err error)

// CheckBMCAttributes checks if the BMC attributes are valid and returns whether a reset is required.
CheckBMCAttributes(ctx context.Context, UUID string, attrs redfish.SettingsAttributes) (reset bool, err error)
CheckBMCAttributes(ctx context.Context, UUID string, attrs schemas.SettingsAttributes) (reset bool, err error)

// SetBiosAttributesOnReset sets BIOS attributes on the system and applies them on the next reset.
SetBiosAttributesOnReset(ctx context.Context, systemURI string, attributes redfish.SettingsAttributes) (err error)
SetBiosAttributesOnReset(ctx context.Context, systemURI string, attributes schemas.SettingsAttributes) (err error)

// SetBMCAttributesImmediately sets BMC attributes on the system and applies them immediately.
SetBMCAttributesImmediately(ctx context.Context, UUID string, attributes redfish.SettingsAttributes) (err error)
SetBMCAttributesImmediately(ctx context.Context, UUID string, attributes schemas.SettingsAttributes) (err error)

// GetBiosVersion retrieves the BIOS version for the system.
GetBiosVersion(ctx context.Context, systemURI string) (string, error)
Expand All @@ -100,19 +99,19 @@ type BMC interface {
GetProcessors(ctx context.Context, systemURI string) ([]Processor, error)

// UpgradeBiosVersion upgrades the BIOS version for the system.
UpgradeBiosVersion(ctx context.Context, manufacturer string, parameters *redfish.SimpleUpdateParameters) (string, bool, error)
UpgradeBiosVersion(ctx context.Context, manufacturer string, parameters *schemas.UpdateServiceSimpleUpdateParameters) (string, bool, error)

// GetBiosUpgradeTask retrieves the task for the BIOS upgrade.
GetBiosUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*redfish.Task, error)
GetBiosUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*schemas.Task, error)

// WaitForServerPowerState waits for the server to reach the specified power state.
WaitForServerPowerState(ctx context.Context, systemURI string, powerState redfish.PowerState) error
WaitForServerPowerState(ctx context.Context, systemURI string, powerState schemas.PowerState) error

// UpgradeBMCVersion upgrades the BMC version for the system.
UpgradeBMCVersion(ctx context.Context, manufacturer string, parameters *redfish.SimpleUpdateParameters) (string, bool, error)
UpgradeBMCVersion(ctx context.Context, manufacturer string, parameters *schemas.UpdateServiceSimpleUpdateParameters) (string, bool, error)

// GetBMCUpgradeTask retrieves the task for the BMC upgrade.
GetBMCUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*redfish.Task, error)
GetBMCUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*schemas.Task, error)

// CreateOrUpdateAccount creates or updates a BMC user account.
CreateOrUpdateAccount(ctx context.Context, userName, role, password string, enabled bool) error
Expand All @@ -121,10 +120,10 @@ type BMC interface {
DeleteAccount(ctx context.Context, userName, id string) error

// GetAccounts retrieves all BMC user accounts.
GetAccounts() ([]*redfish.ManagerAccount, error)
GetAccounts() ([]*schemas.ManagerAccount, error)

// GetAccountService retrieves the account service.
GetAccountService() (*redfish.AccountService, error)
GetAccountService() (*schemas.AccountService, error)
}

type Entity struct {
Expand Down Expand Up @@ -163,7 +162,7 @@ type RegistryEntry struct {

// Registry describes the Message Registry file locator Resource.
type Registry struct {
common.Entity
schemas.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
Expand All @@ -189,7 +188,7 @@ type Server struct {
URI string
Model string
Manufacturer string
PowerState redfish.PowerState
PowerState schemas.PowerState
SerialNumber string
}

Expand All @@ -199,9 +198,9 @@ type Volume struct {
// CapacityBytes specifies the capacity of the volume in bytes.
SizeBytes int64 `json:"sizeBytes,omitempty"`
// Status specifies the status of the volume.
State common.State `json:"state,omitempty"`
State schemas.State `json:"state,omitempty"`
// RAIDType specifies the RAID type of the associated Volume.
RAIDType redfish.RAIDType `json:"raidType,omitempty"`
RAIDType schemas.RAIDType `json:"raidType,omitempty"`
// VolumeUsage specifies the volume usage type for the Volume.
VolumeUsage string `json:"volumeUsage,omitempty"`
}
Expand All @@ -212,22 +211,22 @@ type Drive struct {
// MediaType specifies the media type of the storage device.
MediaType string `json:"mediaType,omitempty"`
// Type specifies the type of the storage device.
Type redfish.FormFactor `json:"type,omitempty"`
Type schemas.FormFactor `json:"type,omitempty"`
// SizeBytes specifies the size of the storage device in bytes.
SizeBytes int64 `json:"sizeBytes,omitempty"`
// Vendor specifies the vendor of the storage device.
Vendor string `json:"vendor,omitempty"`
// Model specifies the model of the storage device.
Model string `json:"model,omitempty"`
// State specifies the state of the storage device.
State common.State `json:"state,omitempty"`
State schemas.State `json:"state,omitempty"`
}

// Storage represents a storage resource.
type Storage struct {
Entity
// State specifies the state of the storage.
State common.State `json:"state,omitempty"`
State schemas.State `json:"state,omitempty"`
// Drives is a collection of drives associated with this storage.
Drives []Drive `json:"drives,omitempty"`
// Volumes is a collection of volumes associated with this storage.
Expand Down Expand Up @@ -260,8 +259,8 @@ type Processor struct {
type SystemInfo struct {
Manufacturer string
Model string
Status common.Status
PowerState redfish.PowerState
Status schemas.Status
PowerState schemas.PowerState
TotalSystemMemory resource.Quantity
SystemURI string
SystemUUID string
Expand All @@ -285,7 +284,7 @@ type Manager struct {
OemLinks json.RawMessage
}

func NewOEMManager(manager *redfish.Manager, service *gofish.Service) (oem.ManagerInterface, error) {
func NewOEMManager(manager *schemas.Manager, service *gofish.Service) (oem.ManagerInterface, error) {
var OEMManager oem.ManagerInterface
switch manager.Manufacturer {
case string(ManufacturerDell):
Expand Down
12 changes: 6 additions & 6 deletions bmc/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"errors"
"fmt"

"github.com/stmcginnis/gofish/redfish"
"github.com/stmcginnis/gofish/schemas"
)

// todo: merge with checkBiosAttribues after #298
func CheckAttribues(
attrs redfish.SettingsAttributes,
filtered map[string]redfish.Attribute,
attrs schemas.SettingsAttributes,
filtered map[string]schemas.Attributes,
) (reset bool, err error) {
reset = false
var errs []error
Expand All @@ -28,7 +28,7 @@ func CheckAttribues(
reset = true
}
switch entryAttribute.Type {
case redfish.IntegerAttributeType:
case schemas.IntegerAttributeType:
if _, ok := value.(int); !ok {
errs = append(
errs,
Expand All @@ -40,7 +40,7 @@ func CheckAttribues(
entryAttribute,
))
}
case redfish.StringAttributeType:
case schemas.StringAttributeType:
if _, ok := value.(string); !ok {
errs = append(
errs,
Expand All @@ -52,7 +52,7 @@ func CheckAttribues(
entryAttribute,
))
}
case redfish.EnumerationAttributeType:
case schemas.EnumerationAttributeType:
if _, ok := value.(string); !ok {
errs = append(
errs,
Expand Down
Loading
Loading