Skip to content

Commit

Permalink
adds mediaType instead of rotational for drives
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhipfel committed Nov 5, 2024
1 parent 39b0023 commit 4bf66d9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ type NetworkInterface struct {
type StorageDrive struct {
// Name is the name of the storage interface.
Name string `json:"name,omitempty"`
// Rotational specifies whether the storage device is rotational.
Rotational bool `json:"rotational,omitempty"`
// MediaType specifies the media type of the storage device.
MediaType string `json:"mediaType,omitempty"`
// Type specifies the type of the storage device.
Type string `json:"type,omitempty"`
// Capacity specifies the size of the storage device in bytes.
Expand Down
10 changes: 6 additions & 4 deletions bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type Server struct {
SerialNumber string
}

// Volume represents a storage volume.
type Volume struct {
Entity
// CapacityBytes specifies the capacity of the volume in bytes.
Expand All @@ -126,10 +127,11 @@ type Volume struct {
VolumeUsage string `json:"volumeUsage,omitempty"`
}

// Drive represents a storage drive.
type Drive struct {
Entity
// Rotational specifies whether the storage device is rotational.
Rotational bool `json:"rotational,omitempty"`
// 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"`
// SizeBytes specifies the size of the storage device in bytes.
Expand All @@ -142,11 +144,11 @@ type Drive struct {
State common.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"`
// Description provides a description of this resource.
Description string `json:"description,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
20 changes: 9 additions & 11 deletions bmc/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ func (r *RedfishBMC) GetStorages(systemUUID string) ([]Storage, error) {
result := make([]Storage, 0, len(systemStorage))
for _, s := range systemStorage {
storage := Storage{
Description: s.Description,
Entity: Entity{ID: s.ID, Name: s.Name},
Entity: Entity{ID: s.ID, Name: s.Name},
}
volumes, err := s.Volumes()
if err != nil {
Expand All @@ -377,13 +376,13 @@ func (r *RedfishBMC) GetStorages(systemUUID string) ([]Storage, error) {
storage.Drives = make([]Drive, 0, len(drives))
for _, d := range drives {
storage.Drives = append(storage.Drives, Drive{
Entity: Entity{ID: d.ID, Name: d.Name},
Rotational: d.RotationSpeedRPM != 0,
Type: d.DriveFormFactor,
SizeBytes: d.CapacityBytes,
Vendor: d.Manufacturer,
Model: d.Model,
State: d.Status.State,
Entity: Entity{ID: d.ID, Name: d.Name},
MediaType: string(d.MediaType),
Type: d.DriveFormFactor,
SizeBytes: d.CapacityBytes,
Vendor: d.Manufacturer,
Model: d.Model,
State: d.Status.State,
})
}
result = append(result, storage)
Expand All @@ -397,8 +396,7 @@ func (r *RedfishBMC) GetStorages(systemUUID string) ([]Storage, error) {
}
for _, s := range simpleStorages {
storage := Storage{
Description: s.Description,
Entity: Entity{ID: s.ID, Name: s.Name},
Entity: Entity{ID: s.ID, Name: s.Name},
}

storage.Drives = make([]Drive, 0, len(s.Devices))
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,17 @@ spec:
device in bytes.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
mediaType:
description: MediaType specifies the media type of the
storage device.
type: string
model:
description: Model specifies the model of the storage
device.
type: string
name:
description: Name is the name of the storage interface.
type: string
rotational:
description: Rotational specifies whether the storage
device is rotational.
type: boolean
state:
description: State specifies the state of the storage
device.
Expand Down
6 changes: 3 additions & 3 deletions docs/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2247,13 +2247,13 @@ string
</tr>
<tr>
<td>
<code>rotational</code><br/>
<code>mediaType</code><br/>
<em>
bool
string
</em>
</td>
<td>
<p>Rotational specifies whether the storage device is rotational.</p>
<p>MediaType specifies the media type of the storage device.</p>
</td>
</tr>
<tr>
Expand Down
14 changes: 7 additions & 7 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ func (r *ServerReconciler) handleDiscoveryState(ctx context.Context, log logr.Lo
}
for _, drive := range storage.Drives {
a1Storage.Drives = append(a1Storage.Drives, metalv1alpha1.StorageDrive{
Name: drive.Name,
Model: drive.Model,
Vendor: drive.Vendor,
Capacity: resource.NewQuantity(drive.SizeBytes, resource.BinarySI),
Type: string(drive.Type),
State: metalv1alpha1.StorageState(drive.State),
Rotational: drive.Rotational,
Name: drive.Name,
Model: drive.Model,
Vendor: drive.Vendor,
Capacity: resource.NewQuantity(drive.SizeBytes, resource.BinarySI),
Type: string(drive.Type),
State: metalv1alpha1.StorageState(drive.State),
MediaType: drive.MediaType,
})
}
a1Storage.Volumes = make([]metalv1alpha1.StorageVolume, 0, len(storage.Volumes))
Expand Down
22 changes: 10 additions & 12 deletions internal/controller/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,18 @@ var _ = Describe("Server Controller", func() {
Name: "Simple Storage Controller",
Drives: []metalv1alpha1.StorageDrive{
{
Name: "SATA Bay 1",
Rotational: false,
Capacity: resource.NewQuantity(8000000000000, resource.BinarySI),
Vendor: "Contoso",
Model: "3000GT8",
State: metalv1alpha1.StorageStateEnabled,
Name: "SATA Bay 1",
Capacity: resource.NewQuantity(8000000000000, resource.BinarySI),
Vendor: "Contoso",
Model: "3000GT8",
State: metalv1alpha1.StorageStateEnabled,
},
{
Name: "SATA Bay 2",
Rotational: false,
Capacity: resource.NewQuantity(4000000000000, resource.BinarySI),
Vendor: "Contoso",
Model: "3000GT7",
State: metalv1alpha1.StorageStateEnabled,
Name: "SATA Bay 22",
Capacity: resource.NewQuantity(4000000000000, resource.BinarySI),
Vendor: "Contoso",
Model: "3000GT7",
State: metalv1alpha1.StorageStateEnabled,
},
{
Name: "SATA Bay 3",
Expand Down

0 comments on commit 4bf66d9

Please sign in to comment.