Skip to content

Commit d1399f8

Browse files
authored
Update gofish dependency and adjust for changes (#644)
The gofish library has been extensively refactored. This updates usage based on those changes. Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
1 parent 89a3598 commit d1399f8

24 files changed

+372
-379
lines changed

api/v1alpha1/biosversion_types.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
package v1alpha1
55

66
import (
7-
"github.com/stmcginnis/gofish/common"
8-
"github.com/stmcginnis/gofish/redfish"
7+
"github.com/stmcginnis/gofish/schemas"
98
corev1 "k8s.io/api/core/v1"
109
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1110
)
@@ -101,11 +100,11 @@ type Task struct {
101100

102101
// State is the current state of the task.
103102
// +optional
104-
State redfish.TaskState `json:"state,omitempty"`
103+
State schemas.TaskState `json:"state,omitempty"`
105104

106105
// Status is the current status of the task.
107106
// +optional
108-
Status common.Health `json:"status,omitempty"`
107+
Status schemas.Health `json:"status,omitempty"`
109108

110109
// PercentComplete is the percentage of completion of the task.
111110
// +optional

api/v1alpha1/constants.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package v1alpha1
55

6-
import "github.com/stmcginnis/gofish/redfish"
6+
import "github.com/stmcginnis/gofish/schemas"
77

88
// establishing general rule for constants naming for Annotations
99
// "Key" for Annotation constants should be named OperationAnnotation.
@@ -69,11 +69,11 @@ const (
6969
GracefulRestartBMC = "graceful-restart-bmc"
7070
)
7171

72-
var AnnotationToRedfishMapping = map[string]redfish.ResetType{
73-
GracefulRestartServerPower: redfish.GracefulRestartResetType,
74-
HardRestartServerPower: redfish.ForceRestartResetType,
75-
PowerCycleServerPower: redfish.PowerCycleResetType,
76-
ForceOffServerPower: redfish.ForceOffResetType,
77-
ForceOnServerPower: redfish.ForceOnResetType,
78-
GracefulRestartBMC: redfish.GracefulRestartResetType,
72+
var AnnotationToRedfishMapping = map[string]schemas.ResetType{
73+
GracefulRestartServerPower: schemas.GracefulRestartResetType,
74+
HardRestartServerPower: schemas.ForceRestartResetType,
75+
PowerCycleServerPower: schemas.PowerCycleResetType,
76+
ForceOffServerPower: schemas.ForceOffResetType,
77+
ForceOnServerPower: schemas.ForceOnResetType,
78+
GracefulRestartBMC: schemas.GracefulRestartResetType,
7979
}

bmc/bmc.go

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import (
99
"fmt"
1010

1111
"github.com/stmcginnis/gofish"
12-
"github.com/stmcginnis/gofish/common"
13-
"github.com/stmcginnis/gofish/redfish"
12+
"github.com/stmcginnis/gofish/schemas"
1413
"k8s.io/apimachinery/pkg/api/resource"
1514

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

3938
// Reset performs a reset on the system.
40-
Reset(ctx context.Context, systemURI string, resetType redfish.ResetType) error
39+
Reset(ctx context.Context, systemURI string, resetType schemas.ResetType) error
4140

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

5453
// GetManager returns the manager
55-
GetManager(UUID string) (*redfish.Manager, error)
54+
GetManager(UUID string) (*schemas.Manager, error)
5655

5756
// ResetManager performs a reset on the Manager.
58-
ResetManager(ctx context.Context, UUID string, resetType redfish.ResetType) error
57+
ResetManager(ctx context.Context, UUID string, resetType schemas.ResetType) error
5958

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

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

6665
// GetBiosPendingAttributeValues retrieves pending BIOS attribute values for the system.
67-
GetBiosPendingAttributeValues(ctx context.Context, systemURI string) (redfish.SettingsAttributes, error)
66+
GetBiosPendingAttributeValues(ctx context.Context, systemURI string) (schemas.SettingsAttributes, error)
6867

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

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

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

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

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

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

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

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

105104
// GetBiosUpgradeTask retrieves the task for the BIOS upgrade.
106-
GetBiosUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*redfish.Task, error)
105+
GetBiosUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*schemas.Task, error)
107106

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

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

114113
// GetBMCUpgradeTask retrieves the task for the BMC upgrade.
115-
GetBMCUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*redfish.Task, error)
114+
GetBMCUpgradeTask(ctx context.Context, manufacturer string, taskURI string) (*schemas.Task, error)
116115

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

123122
// GetAccounts retrieves all BMC user accounts.
124-
GetAccounts() ([]*redfish.ManagerAccount, error)
123+
GetAccounts() ([]*schemas.ManagerAccount, error)
125124

126125
// GetAccountService retrieves the account service.
127-
GetAccountService() (*redfish.AccountService, error)
126+
GetAccountService() (*schemas.AccountService, error)
128127
}
129128

130129
type Entity struct {
@@ -163,7 +162,7 @@ type RegistryEntry struct {
163162

164163
// Registry describes the Message Registry file locator Resource.
165164
type Registry struct {
166-
common.Entity
165+
schemas.Entity
167166
// ODataContext is the odata context.
168167
ODataContext string `json:"@odata.context"`
169168
// ODataType is the odata type.
@@ -189,7 +188,7 @@ type Server struct {
189188
URI string
190189
Model string
191190
Manufacturer string
192-
PowerState redfish.PowerState
191+
PowerState schemas.PowerState
193192
SerialNumber string
194193
}
195194

@@ -199,9 +198,9 @@ type Volume struct {
199198
// CapacityBytes specifies the capacity of the volume in bytes.
200199
SizeBytes int64 `json:"sizeBytes,omitempty"`
201200
// Status specifies the status of the volume.
202-
State common.State `json:"state,omitempty"`
201+
State schemas.State `json:"state,omitempty"`
203202
// RAIDType specifies the RAID type of the associated Volume.
204-
RAIDType redfish.RAIDType `json:"raidType,omitempty"`
203+
RAIDType schemas.RAIDType `json:"raidType,omitempty"`
205204
// VolumeUsage specifies the volume usage type for the Volume.
206205
VolumeUsage string `json:"volumeUsage,omitempty"`
207206
}
@@ -212,22 +211,22 @@ type Drive struct {
212211
// MediaType specifies the media type of the storage device.
213212
MediaType string `json:"mediaType,omitempty"`
214213
// Type specifies the type of the storage device.
215-
Type redfish.FormFactor `json:"type,omitempty"`
214+
Type schemas.FormFactor `json:"type,omitempty"`
216215
// SizeBytes specifies the size of the storage device in bytes.
217216
SizeBytes int64 `json:"sizeBytes,omitempty"`
218217
// Vendor specifies the vendor of the storage device.
219218
Vendor string `json:"vendor,omitempty"`
220219
// Model specifies the model of the storage device.
221220
Model string `json:"model,omitempty"`
222221
// State specifies the state of the storage device.
223-
State common.State `json:"state,omitempty"`
222+
State schemas.State `json:"state,omitempty"`
224223
}
225224

226225
// Storage represents a storage resource.
227226
type Storage struct {
228227
Entity
229228
// State specifies the state of the storage.
230-
State common.State `json:"state,omitempty"`
229+
State schemas.State `json:"state,omitempty"`
231230
// Drives is a collection of drives associated with this storage.
232231
Drives []Drive `json:"drives,omitempty"`
233232
// Volumes is a collection of volumes associated with this storage.
@@ -260,8 +259,8 @@ type Processor struct {
260259
type SystemInfo struct {
261260
Manufacturer string
262261
Model string
263-
Status common.Status
264-
PowerState redfish.PowerState
262+
Status schemas.Status
263+
PowerState schemas.PowerState
265264
TotalSystemMemory resource.Quantity
266265
SystemURI string
267266
SystemUUID string
@@ -285,7 +284,7 @@ type Manager struct {
285284
OemLinks json.RawMessage
286285
}
287286

288-
func NewOEMManager(manager *redfish.Manager, service *gofish.Service) (oem.ManagerInterface, error) {
287+
func NewOEMManager(manager *schemas.Manager, service *gofish.Service) (oem.ManagerInterface, error) {
289288
var OEMManager oem.ManagerInterface
290289
switch manager.Manufacturer {
291290
case string(ManufacturerDell):

bmc/common/helpers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
"errors"
88
"fmt"
99

10-
"github.com/stmcginnis/gofish/redfish"
10+
"github.com/stmcginnis/gofish/schemas"
1111
)
1212

1313
// todo: merge with checkBiosAttribues after #298
1414
func CheckAttribues(
15-
attrs redfish.SettingsAttributes,
16-
filtered map[string]redfish.Attribute,
15+
attrs schemas.SettingsAttributes,
16+
filtered map[string]schemas.Attributes,
1717
) (reset bool, err error) {
1818
reset = false
1919
var errs []error
@@ -28,7 +28,7 @@ func CheckAttribues(
2828
reset = true
2929
}
3030
switch entryAttribute.Type {
31-
case redfish.IntegerAttributeType:
31+
case schemas.IntegerAttributeType:
3232
if _, ok := value.(int); !ok {
3333
errs = append(
3434
errs,
@@ -40,7 +40,7 @@ func CheckAttribues(
4040
entryAttribute,
4141
))
4242
}
43-
case redfish.StringAttributeType:
43+
case schemas.StringAttributeType:
4444
if _, ok := value.(string); !ok {
4545
errs = append(
4646
errs,
@@ -52,7 +52,7 @@ func CheckAttribues(
5252
entryAttribute,
5353
))
5454
}
55-
case redfish.EnumerationAttributeType:
55+
case schemas.EnumerationAttributeType:
5656
if _, ok := value.(string); !ok {
5757
errs = append(
5858
errs,

0 commit comments

Comments
 (0)