diff --git a/cmd/metal-api/internal/grpc/boot-service.go b/cmd/metal-api/internal/grpc/boot-service.go index f02f803f1..4f35c4aed 100644 --- a/cmd/metal-api/internal/grpc/boot-service.go +++ b/cmd/metal-api/internal/grpc/boot-service.go @@ -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 diff --git a/cmd/metal-api/internal/metal/machine.go b/cmd/metal-api/internal/metal/machine.go index 6076f8c1c..3a45ab765 100644 --- a/cmd/metal-api/internal/metal/machine.go +++ b/cmd/metal-api/internal/metal/machine.go @@ -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 { diff --git a/cmd/metal-api/internal/service/machine-service.go b/cmd/metal-api/internal/service/machine-service.go index ac1caef44..bf63ff9f2 100644 --- a/cmd/metal-api/internal/service/machine-service.go +++ b/cmd/metal-api/internal/service/machine-service.go @@ -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) @@ -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) @@ -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 { diff --git a/cmd/metal-api/internal/service/v1/machine.go b/cmd/metal-api/internal/service/v1/machine.go index 48e164ec8..3a83c1801 100644 --- a/cmd/metal-api/internal/service/v1/machine.go +++ b/cmd/metal-api/internal/service/v1/machine.go @@ -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 { @@ -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, @@ -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, diff --git a/spec/metal-api.json b/spec/metal-api.json index 581a6782c..dc97a467e 100644 --- a/spec/metal-api.json +++ b/spec/metal-api.json @@ -2538,6 +2538,10 @@ "interface": { "type": "string" }, + "last_updated": { + "format": "date-time", + "type": "string" + }, "mac": { "type": "string" }, @@ -2559,6 +2563,7 @@ "bmcversion", "fru", "interface", + "last_updated", "mac", "password", "powermetric",