From 4ddf50877f34cfd820515043a3047753f467b6f3 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Mon, 30 Sep 2024 13:39:04 +0200 Subject: [PATCH] Report Powersupply state --- cli/main.go | 3 +++ internal/redfish/redfish.go | 24 +++++++++++++++++------- pkg/api/types.go | 36 ++++++++++++++++++++++++------------ 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/cli/main.go b/cli/main.go index c1000d8..9e85e56 100644 --- a/cli/main.go +++ b/cli/main.go @@ -61,6 +61,9 @@ func outband(log logger.Logger) { b := ob.Board() fmt.Printf("Board:\n%#v\n", b) fmt.Printf("Power:\n%#v\n", b.PowerMetric) + fmt.Printf("PowerSupplies:\n%#v\n", b.PowerSupplies) + + os.Exit(0) bmc, err := ob.BMCConnection().BMC() if err != nil { diff --git a/internal/redfish/redfish.go b/internal/redfish/redfish.go index c48fa8b..3b52d76 100644 --- a/internal/redfish/redfish.go +++ b/internal/redfish/redfish.go @@ -107,18 +107,28 @@ func (c *APIClient) BoardInfo() (*api.Board, error) { break } } + var powerSupplies []api.PowerSupply + for _, ps := range power.PowerSupplies { + powerSupplies = append(powerSupplies, api.PowerSupply{ + Status: api.Status{ + Health: string(ps.Status.Health), + State: string(ps.Status.State), + }, + }) + } c.log.Debugw("got chassis", "Manufacturer", manufacturer, "Model", model, "Name", chass.Name, "PartNumber", chass.PartNumber, "SerialNumber", chass.SerialNumber, "BiosVersion", biosVersion, "led", chass.IndicatorLED) return &api.Board{ - VendorString: manufacturer, - Model: model, - PartNumber: chass.PartNumber, - SerialNumber: chass.SerialNumber, - BiosVersion: biosVersion, - IndicatorLED: toMetalLEDState(chass.IndicatorLED), - PowerMetric: powerMetric, + VendorString: manufacturer, + Model: model, + PartNumber: chass.PartNumber, + SerialNumber: chass.SerialNumber, + BiosVersion: biosVersion, + IndicatorLED: toMetalLEDState(chass.IndicatorLED), + PowerMetric: powerMetric, + PowerSupplies: powerSupplies, }, nil } } diff --git a/pkg/api/types.go b/pkg/api/types.go index 1e34122..b8bcb25 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -36,18 +36,19 @@ const ( // Board raw dmi board information type Board struct { - VM bool - VendorString string - Vendor Vendor - Model string - PartNumber string - SerialNumber string - BiosVersion string - BMC *BMC - BIOS *BIOS - Firmware kernel.FirmwareMode - IndicatorLED string - PowerMetric *PowerMetric + VM bool + VendorString string + Vendor Vendor + Model string + PartNumber string + SerialNumber string + BiosVersion string + BMC *BMC + BIOS *BIOS + Firmware kernel.FirmwareMode + IndicatorLED string + PowerMetric *PowerMetric + PowerSupplies []PowerSupply } type PowerMetric struct { @@ -70,6 +71,17 @@ type PowerMetric struct { MinConsumedWatts float32 } +type PowerSupply struct { + // Status shall contain any status or health properties + // of the resource. + Status Status +} + +type Status struct { + Health string + State string +} + // BMCUser holds BMC user details type BMCUser struct { Name string