Skip to content

Commit

Permalink
Read the BMC firmware version where available
Browse files Browse the repository at this point in the history
  • Loading branch information
5kt committed Nov 9, 2023
1 parent d237e16 commit 585d371
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v1alpha1/oob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ type OOBStatus struct {

//+optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`

//+optional
//+kubebuilder:validation:MinLength=1
FWVersion string `json:"fwVersion,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
1 change: 1 addition & 0 deletions bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Info struct {
OS string
OSReason string
Console string
FWVersion string
}

func must(ctx context.Context, err error) {
Expand Down
8 changes: 8 additions & 0 deletions bmc/ipmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ func (b *IPMIBMC) ReadInfo(ctx context.Context) (Info, error) {
}
outputmap(out, &info)

out, serr, err = ipmiExecuteCommand(ctx, b.host, b.port, b.creds, "ipmitool", "bmc", "info")
if err != nil {
return Info{}, fmt.Errorf("cannot get bmc info, stderr: %s: %w", serr, err)
}
outputmap(out, &info)

uuid, ok := info["System GUID"]
if !ok {
return Info{}, fmt.Errorf("cannot determine uuid for machine")
Expand All @@ -194,6 +200,7 @@ func (b *IPMIBMC) ReadInfo(ctx context.Context) (Info, error) {
//TODO: currently we can't handle this correctly as we can't read the state on most hardware
//led, ok := info["Chassis Identify State"]
led := ""
fw := info["Firmware Revision"]

//TODO: properly detect if sol is supported
return Info{
Expand All @@ -206,6 +213,7 @@ func (b *IPMIBMC) ReadInfo(ctx context.Context) (Info, error) {
LocatorLED: led,
Power: cases.Title(language.English).String(powerstate),
Console: "ipmi",
FWVersion: fw,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions bmc/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ func (b *RedfishBMC) ReadInfo(ctx context.Context) (Info, error) {
manufacturer := systems[0].Manufacturer
capabilities := []string{"credentials", "power", "led"}
console := ""
fw := ""

mgr, err := c.Service.Managers()
if err != nil {
Expand All @@ -652,6 +653,7 @@ func (b *RedfishBMC) ReadInfo(ctx context.Context) (Info, error) {
capabilities = append(capabilities, "console")
console = "ipmi"
}
fw = mgr[0].FirmwareVersion
}
}

Expand All @@ -667,6 +669,7 @@ func (b *RedfishBMC) ReadInfo(ctx context.Context) (Info, error) {
OS: os,
OSReason: osReason,
Console: console,
FWVersion: fw,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/onmetal.de_oobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ spec:
type: array
console:
type: string
fwVersion:
minLength: 1
type: string
ip:
pattern: ((^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$))
type: string
Expand Down
4 changes: 3 additions & 1 deletion controllers/oob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func (r *OOBReconciler) reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
OSReason: oob.Status.OSReason,
OSReadDeadline: oob.Status.OSReadDeadline,
Console: oob.Status.Console,
FWVersion: oob.Status.FWVersion,
},
}

Expand Down Expand Up @@ -1018,10 +1019,11 @@ func (r *OOBReconciler) setStatusFields(oob *oobv1alpha1.OOB, info *bmc.Info, re
}

// Update the status fields to their actual state
if oob.Status.LocatorLED != info.LocatorLED || oob.Status.Power != info.Power || oob.Status.OSReason != info.OSReason {
if oob.Status.LocatorLED != info.LocatorLED || oob.Status.Power != info.Power || oob.Status.OSReason != info.OSReason || oob.Status.FWVersion != info.FWVersion {
oob.Status.LocatorLED = info.LocatorLED
oob.Status.Power = info.Power
oob.Status.OSReason = info.OSReason
oob.Status.FWVersion = info.FWVersion
statusChanged = true
}

Expand Down

0 comments on commit 585d371

Please sign in to comment.