Skip to content

Commit

Permalink
Report Powersupply state
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Sep 30, 2024
1 parent cb149f2 commit 4ddf508
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
3 changes: 3 additions & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 17 additions & 7 deletions internal/redfish/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
36 changes: 24 additions & 12 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 4ddf508

Please sign in to comment.