Skip to content

Commit

Permalink
adds TotalSystemMemory to server status
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhipfel committed Nov 8, 2024
1 parent 8d37e2d commit 80f7dbc
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 19 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ type ServerStatus struct {
// NetworkInterfaces is a list of network interfaces associated with the server.
NetworkInterfaces []NetworkInterface `json:"networkInterfaces,omitempty"`

// TotalSystemMemory is the total amount of memory in bytes available on the server.
TotalSystemMemory *resource.Quantity `json:"totalSystemMemory,omitempty"`

// Storages is a list of storages associated with the server.
Storages []Storage `json:"storages,omitempty"`

Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,17 @@ type Processor struct {

// SystemInfo represents basic information about the system.
type SystemInfo struct {
Manufacturer string
Model string
Status common.Status
PowerState redfish.PowerState
NetworkInterfaces []NetworkInterface
Processors []Processor
SystemUUID string
SerialNumber string
SKU string
IndicatorLED string
Manufacturer string
Model string
Status common.Status
PowerState redfish.PowerState
NetworkInterfaces []NetworkInterface
Processors []Processor
TotalSystemMemoryBytes int64
SystemUUID string
SerialNumber string
SKU string
IndicatorLED string
}

// Manager represents the manager information.
Expand Down
17 changes: 9 additions & 8 deletions bmc/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ func (r *RedfishBMC) GetSystemInfo(systemUUID string) (SystemInfo, error) {
}

return SystemInfo{
SystemUUID: system.UUID,
Manufacturer: system.Manufacturer,
Model: system.Model,
Status: system.Status,
PowerState: system.PowerState,
SerialNumber: system.SerialNumber,
SKU: system.SKU,
IndicatorLED: string(system.IndicatorLED),
SystemUUID: system.UUID,
Manufacturer: system.Manufacturer,
Model: system.Model,
Status: system.Status,
PowerState: system.PowerState,
SerialNumber: system.SerialNumber,
SKU: system.SKU,
IndicatorLED: string(system.IndicatorLED),
TotalSystemMemoryBytes: int64(system.MemorySummary.TotalSystemMemoryGiB) * 1024 * 1024 * 1024,
}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,14 @@ spec:
type: array
type: object
type: array
totalSystemMemory:
anyOf:
- type: integer
- type: string
description: TotalSystemMemory is the total amount of memory in bytes
available on the server.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: object
served: true
Expand Down
13 changes: 13 additions & 0 deletions docs/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,19 @@ ServerState
</tr>
<tr>
<td>
<code>totalSystemMemory</code><br/>
<em>
<a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity">
k8s.io/apimachinery/pkg/api/resource.Quantity
</a>
</em>
</td>
<td>
<p>TotalSystemMemoryBytes is the total amount of memory in bytes available on the server.</p>
</td>
</tr>
<tr>
<td>
<code>storages</code><br/>
<em>
<a href="#metal.ironcore.dev/v1alpha1.Storage">
Expand Down
1 change: 1 addition & 0 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ func (r *ServerReconciler) updateServerStatus(ctx context.Context, log logr.Logg
server.Status.Manufacturer = systemInfo.Manufacturer
server.Status.Model = systemInfo.Model
server.Status.IndicatorLED = metalv1alpha1.IndicatorLED(systemInfo.IndicatorLED)
server.Status.TotalSystemMemory = resource.NewQuantity(systemInfo.TotalSystemMemoryBytes, resource.BinarySI)

currentBiosVersion, err := bmcClient.GetBiosVersion(server.Spec.UUID)
if err != nil {
Expand Down

0 comments on commit 80f7dbc

Please sign in to comment.