Skip to content

Commit

Permalink
Add Server model to .status (#132)
Browse files Browse the repository at this point in the history
* Add `Server` model to `.status`

* fix double printed name type

* print model by default
  • Loading branch information
defo89 authored Sep 19, 2024
1 parent 846ff6f commit 99c0891
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/bmc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const (
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:printcolumn:name="MACAddress",type=string,JSONPath=`.status.macAddress`
// +kubebuilder:printcolumn:name="MACAddress",type=string,JSONPath=`.status.ip`
// +kubebuilder:printcolumn:name="IP",type=string,JSONPath=`.status.ip`
// +kubebuilder:printcolumn:name="Model",type=string,JSONPath=`.status.model`
// +kubebuilder:printcolumn:name="SKU",type=string,JSONPath=`.status.sku`,priority=100
// +kubebuilder:printcolumn:name="SerialNumber",type=string,JSONPath=`.status.serialNumber`,priority=100
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ type ServerStatus struct {
// Manufacturer is the name of the server manufacturer.
Manufacturer string `json:"manufacturer,omitempty"`

// Model is the model of the server.
Model string `json:"model,omitempty"`

// SKU is the stock keeping unit identifier for the server.
SKU string `json:"sku,omitempty"`

Expand Down Expand Up @@ -194,6 +197,7 @@ type NetworkInterface struct {
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:printcolumn:name="UUID",type=string,JSONPath=`.spec.uuid`
//+kubebuilder:printcolumn:name="Manufacturer",type=string,JSONPath=`.status.manufacturer`
//+kubebuilder:printcolumn:name="Model",type=string,JSONPath=`.status.model`
//+kubebuilder:printcolumn:name="SKU",type=string,JSONPath=`.status.sku`,priority=100
//+kubebuilder:printcolumn:name="SerialNumber",type=string,JSONPath=`.status.serialNumber`,priority=100
//+kubebuilder:printcolumn:name="PowerState",type=string,JSONPath=`.status.powerState`
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_bmcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
name: MACAddress
type: string
- jsonPath: .status.ip
name: MACAddress
name: IP
type: string
- jsonPath: .status.model
name: Model
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
- jsonPath: .status.manufacturer
name: Manufacturer
type: string
- jsonPath: .status.model
name: Model
type: string
- jsonPath: .status.sku
name: SKU
priority: 100
Expand Down Expand Up @@ -358,6 +361,9 @@ spec:
manufacturer:
description: Manufacturer is the name of the server manufacturer.
type: string
model:
description: Model is the model of the server.
type: string
networkInterfaces:
description: NetworkInterfaces is a list of network interfaces associated
with the server.
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 @@ -383,6 +383,7 @@ func (r *ServerReconciler) updateServerStatus(ctx context.Context, log logr.Logg
server.Status.SerialNumber = systemInfo.SerialNumber
server.Status.SKU = systemInfo.SKU
server.Status.Manufacturer = systemInfo.Manufacturer
server.Status.Model = systemInfo.Model
server.Status.IndicatorLED = metalv1alpha1.IndicatorLED(systemInfo.IndicatorLED)

currentBiosVersion, err := bmcClient.GetBiosVersion(server.Spec.UUID)
Expand Down
1 change: 1 addition & 0 deletions internal/controller/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var _ = Describe("Server Controller", func() {
HaveField("Spec.IndicatorLED", metalv1alpha1.IndicatorLED("")),
HaveField("Spec.ServerClaimRef", BeNil()),
HaveField("Status.Manufacturer", "Contoso"),
HaveField("Status.Model", "3500"),
HaveField("Status.SKU", "8675309"),
HaveField("Status.SerialNumber", "437XR1138R2"),
HaveField("Status.IndicatorLED", metalv1alpha1.OffIndicatorLED),
Expand Down

0 comments on commit 99c0891

Please sign in to comment.