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

Store last updated time for IPMI #462

Merged
merged 7 commits into from
Sep 13, 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
15 changes: 8 additions & 7 deletions cmd/metal-api/internal/grpc/boot-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ func (b *BootService) Register(ctx context.Context, req *v1.BootServiceRegisterR
i := req.Ipmi

ipmi = metal.IPMI{
Address: i.Address,
MacAddress: i.Mac,
User: i.User,
Password: i.Password,
Interface: i.Interface,
BMCVersion: i.BmcVersion,
PowerState: i.PowerState,
Address: i.Address,
MacAddress: i.Mac,
User: i.User,
Password: i.Password,
Interface: i.Interface,
BMCVersion: i.BmcVersion,
PowerState: i.PowerState,
LastUpdated: time.Now(),
}
if i.Fru != nil {
f := i.Fru
Expand Down
1 change: 1 addition & 0 deletions cmd/metal-api/internal/metal/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ type IPMI struct {
BMCVersion string `rethinkdb:"bmcversion" json:"bmcversion"`
PowerState string `rethinkdb:"powerstate" json:"powerstate"`
PowerMetric *PowerMetric `rethinkdb:"powermetric" json:"powermetric"`
LastUpdated time.Time `rethinkdb:"last_updated" json:"last_updated"`
}

type PowerMetric struct {
Expand Down
5 changes: 4 additions & 1 deletion cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ func (r *machineResource) findIPMIMachines(request *restful.Request, response *r
r.send(request, response, http.StatusOK, resp)
}

// FIXME move to grpc as well
func (r *machineResource) ipmiReport(request *restful.Request, response *restful.Response) {
var requestPayload v1.MachineIpmiReports
logger := r.logger(request)
Expand Down Expand Up @@ -706,7 +707,8 @@ func (r *machineResource) ipmiReport(request *restful.Request, response *restful
},
PartitionID: p.ID,
IPMI: metal.IPMI{
Address: report.BMCIp + ":" + defaultIPMIPort,
Address: report.BMCIp + ":" + defaultIPMIPort,
LastUpdated: time.Now(),
},
}
ledstate, err := metal.LEDStateFrom(report.IndicatorLEDState)
Expand Down Expand Up @@ -789,6 +791,7 @@ func (r *machineResource) ipmiReport(request *restful.Request, response *restful
} else {
logger.Errorw("unable to decode ledstate", "id", uuid, "ledstate", report.IndicatorLEDState, "error", err)
}
newMachine.IPMI.LastUpdated = time.Now()

err = r.ds.UpdateMachine(&oldMachine, &newMachine)
if err != nil {
Expand Down
15 changes: 9 additions & 6 deletions cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type MachineIPMI struct {
BMCVersion string `json:"bmcversion"`
PowerState string `json:"powerstate"`
PowerMetric *PowerMetric `json:"powermetric"`
LastUpdated time.Time `json:"last_updated"`
}

type PowerMetric struct {
Expand Down Expand Up @@ -353,12 +354,13 @@ func NewMetalIPMI(r *MachineIPMI) metal.IPMI {
}

return metal.IPMI{
Address: r.Address,
MacAddress: r.MacAddress,
User: r.User,
Password: r.Password,
Interface: r.Interface,
BMCVersion: r.BMCVersion,
Address: r.Address,
MacAddress: r.MacAddress,
User: r.User,
Password: r.Password,
Interface: r.Interface,
BMCVersion: r.BMCVersion,
LastUpdated: r.LastUpdated,
Fru: metal.Fru{
ChassisPartNumber: chassisPartNumber,
ChassisPartSerial: chassisPartSerial,
Expand Down Expand Up @@ -399,6 +401,7 @@ func NewMachineIPMIResponse(m *metal.Machine, s *metal.Size, p *metal.Partition,
BMCVersion: m.IPMI.BMCVersion,
PowerState: m.IPMI.PowerState,
PowerMetric: powerMetric,
LastUpdated: m.IPMI.LastUpdated,
Fru: MachineFru{
ChassisPartNumber: &m.IPMI.Fru.ChassisPartNumber,
ChassisPartSerial: &m.IPMI.Fru.ChassisPartSerial,
Expand Down
5 changes: 5 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,10 @@
"interface": {
"type": "string"
},
"last_updated": {
"format": "date-time",
"type": "string"
},
"mac": {
"type": "string"
},
Expand All @@ -2559,6 +2563,7 @@
"bmcversion",
"fru",
"interface",
"last_updated",
"mac",
"password",
"powermetric",
Expand Down