From 99c08918ff17eab322592976fa75afcda9d6db83 Mon Sep 17 00:00:00 2001 From: Dmitri Fedotov <13087245+defo89@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:34:08 +0300 Subject: [PATCH] Add `Server` model to `.status` (#132) * Add `Server` model to `.status` * fix double printed name type * print model by default --- api/v1alpha1/bmc_types.go | 2 +- api/v1alpha1/server_types.go | 4 ++++ config/crd/bases/metal.ironcore.dev_bmcs.yaml | 2 +- config/crd/bases/metal.ironcore.dev_servers.yaml | 6 ++++++ internal/controller/server_controller.go | 1 + internal/controller/server_controller_test.go | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/bmc_types.go b/api/v1alpha1/bmc_types.go index fd3b6ec..3bb52ee 100644 --- a/api/v1alpha1/bmc_types.go +++ b/api/v1alpha1/bmc_types.go @@ -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 diff --git a/api/v1alpha1/server_types.go b/api/v1alpha1/server_types.go index f319fcf..aac6906 100644 --- a/api/v1alpha1/server_types.go +++ b/api/v1alpha1/server_types.go @@ -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"` @@ -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` diff --git a/config/crd/bases/metal.ironcore.dev_bmcs.yaml b/config/crd/bases/metal.ironcore.dev_bmcs.yaml index 74a18c3..c6ac278 100644 --- a/config/crd/bases/metal.ironcore.dev_bmcs.yaml +++ b/config/crd/bases/metal.ironcore.dev_bmcs.yaml @@ -19,7 +19,7 @@ spec: name: MACAddress type: string - jsonPath: .status.ip - name: MACAddress + name: IP type: string - jsonPath: .status.model name: Model diff --git a/config/crd/bases/metal.ironcore.dev_servers.yaml b/config/crd/bases/metal.ironcore.dev_servers.yaml index 165b186..491c962 100644 --- a/config/crd/bases/metal.ironcore.dev_servers.yaml +++ b/config/crd/bases/metal.ironcore.dev_servers.yaml @@ -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 @@ -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. diff --git a/internal/controller/server_controller.go b/internal/controller/server_controller.go index 7650daf..df9f5b1 100644 --- a/internal/controller/server_controller.go +++ b/internal/controller/server_controller.go @@ -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) diff --git a/internal/controller/server_controller_test.go b/internal/controller/server_controller_test.go index c6f0fe6..865265e 100644 --- a/internal/controller/server_controller_test.go +++ b/internal/controller/server_controller_test.go @@ -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),