Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read the BMC firmware version where available #94

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1007,13 +1008,14 @@ func (r *OOBReconciler) setStatusFields(oob *oobv1alpha1.OOB, info *bmc.Info, re
statusChanged := false

// Fill in all non-modifiable fields
if oob.Status.Type != info.Type || !slices.Equal(oob.Status.Capabilities, info.Capabilities) || oob.Status.Manufacturer != info.Manufacturer || oob.Status.SerialNumber != info.SerialNumber || oob.Status.SKU != info.SKU || oob.Status.Console != info.Console {
if oob.Status.Type != info.Type || !slices.Equal(oob.Status.Capabilities, info.Capabilities) || oob.Status.Manufacturer != info.Manufacturer || oob.Status.SerialNumber != info.SerialNumber || oob.Status.SKU != info.SKU || oob.Status.Console != info.Console || oob.Status.FWVersion != info.FWVersion {
oob.Status.Type = info.Type
oob.Status.Capabilities = info.Capabilities
oob.Status.Manufacturer = info.Manufacturer
oob.Status.SKU = info.SKU
oob.Status.SerialNumber = info.SerialNumber
oob.Status.Console = info.Console
oob.Status.FWVersion = info.FWVersion
statusChanged = true
}

Expand Down