Skip to content

Commit

Permalink
Introduce IPMI power state field (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Aug 24, 2021
1 parent 3e12ffc commit 1308e1c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
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 @@ -345,6 +345,7 @@ type IPMI struct {
Interface string `rethinkdb:"interface" json:"interface"`
Fru Fru `rethinkdb:"fru" json:"fru"`
BMCVersion string `rethinkdb:"bmcversion" json:"bmcversion"`
PowerState string `rethinkdb:"powerstate" json:"powerstate"`
}

// BIOS contains machine bios information
Expand Down
4 changes: 4 additions & 0 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,10 @@ func (r machineResource) ipmiReport(request *restful.Request, response *restful.
newMachine.IPMI.BMCVersion = report.BMCVersion
}

if report.PowerState != "" {
newMachine.IPMI.PowerState = report.PowerState
}

err = r.ds.UpdateMachine(&oldMachine, &newMachine)
if err != nil {
logger.Errorf("could not update machine", "id", uuid, "ip", report.BMCIp, "machine", newMachine, "err", err)
Expand Down
4 changes: 4 additions & 0 deletions cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type MachineIPMI struct {
Interface string `json:"interface"`
Fru MachineFru `json:"fru"`
BMCVersion string `json:"bmcversion"`
PowerState string `json:"powerstate"`
}

type MachineFru struct {
Expand Down Expand Up @@ -230,6 +231,7 @@ type MachineIpmiReport struct {
FRU *MachineFru
BIOSVersion string
BMCVersion string
PowerState string
}

type MachineIpmiReports struct {
Expand Down Expand Up @@ -336,6 +338,7 @@ func NewMetalIPMI(r *MachineIPMI) metal.IPMI {
ProductPartNumber: productPartNumber,
ProductSerial: productSerial,
},
PowerState: r.PowerState,
}
}

Expand All @@ -351,6 +354,7 @@ func NewMachineIPMIResponse(m *metal.Machine, s *metal.Size, p *metal.Partition,
Password: m.IPMI.Password,
Interface: m.IPMI.Interface,
BMCVersion: m.IPMI.BMCVersion,
PowerState: m.IPMI.PowerState,
Fru: MachineFru{
ChassisPartNumber: &m.IPMI.Fru.ChassisPartNumber,
ChassisPartSerial: &m.IPMI.Fru.ChassisPartSerial,
Expand Down
10 changes: 9 additions & 1 deletion spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,9 @@
"password": {
"type": "string"
},
"powerstate": {
"type": "string"
},
"user": {
"type": "string"
}
Expand All @@ -2411,6 +2414,7 @@
"interface",
"mac",
"password",
"powerstate",
"user"
]
},
Expand Down Expand Up @@ -2521,13 +2525,17 @@
},
"FRU": {
"$ref": "#/definitions/v1.MachineFru"
},
"PowerState": {
"type": "string"
}
},
"required": [
"BIOSVersion",
"BMCIp",
"BMCVersion",
"FRU"
"FRU",
"PowerState"
]
},
"v1.MachineIpmiReportResponse": {
Expand Down

0 comments on commit 1308e1c

Please sign in to comment.