1b41aff0fSXiaochao Ma# Host Management with OpenBMC 298100205SJeremy Kerr 398100205SJeremy KerrThis document describes the host-management interfaces of the OpenBMC object 498100205SJeremy Kerrstructure, accessible over REST. 598100205SJeremy Kerr 6b41aff0fSXiaochao MaNote: Authentication 7b41aff0fSXiaochao Ma 8b41aff0fSXiaochao MaSee the details on authentication at [REST-cheatsheet](https://github.com/openbmc/docs/blob/master/REST-cheatsheet.md#establish-rest-connection-session). 9b41aff0fSXiaochao Ma 10b41aff0fSXiaochao MaThis document uses token based authentication method: 11b41aff0fSXiaochao Ma 12b41aff0fSXiaochao Ma``` 13b41aff0fSXiaochao Ma$ export bmc=xx.xx.xx.xx 14b41aff0fSXiaochao Ma$ export token=`curl -k -H "Content-Type: application/json" -X POST https://${bmc}/login -d '{"username" : "root", "password" : "0penBmc"}' | grep token | awk '{print $2;}' | tr -d '"'` 15b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/... 16b41aff0fSXiaochao Ma``` 17b41aff0fSXiaochao Ma 18b41aff0fSXiaochao Ma## Inventory 1998100205SJeremy Kerr 206ba5cff0SGunnar MillsThe system inventory structure is under the `/xyz/openbmc_project/inventory` hierarchy. 2198100205SJeremy Kerr 2298100205SJeremy KerrIn OpenBMC the inventory is represented as a path which is hierarchical to the 2398100205SJeremy Kerrphysical system topology. Items in the inventory are referred to as inventory 246ba5cff0SGunnar Millsitems and are not necessarily FRUs (field-replaceable units). If the system 256ba5cff0SGunnar Millscontains one chassis, a motherboard, and a CPU on the motherboard, then the 266ba5cff0SGunnar Millspath to that inventory item would be: 2798100205SJeremy Kerr 28b41aff0fSXiaochao Ma `inventory/system/chassis0/motherboard0/cpu0` 2998100205SJeremy Kerr 306ba5cff0SGunnar MillsThe properties associated with an inventory item are specific to that item. 316ba5cff0SGunnar MillsSome common properties are: 3298100205SJeremy Kerr 336ba5cff0SGunnar Mills * `Version`: A code version associated with this item. 346ba5cff0SGunnar Mills * `Present`: Indicates whether this item is present in the system (True/False). 356ba5cff0SGunnar Mills * `Functional`: Indicates whether this item is functioning in the system (True/False). 3698100205SJeremy Kerr 3798100205SJeremy KerrThe usual `list` and `enumerate` REST queries allow the system inventory 3898100205SJeremy Kerrstructure to be accessed. For example, to enumerate all inventory items and 3998100205SJeremy Kerrtheir properties: 4098100205SJeremy Kerr 41b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/inventory/enumerate 4298100205SJeremy Kerr 4398100205SJeremy KerrTo list the properties of one item: 4498100205SJeremy Kerr 45b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/inventory/system/chassis/motherboard 4698100205SJeremy Kerr 47b41aff0fSXiaochao Ma## Sensors 4898100205SJeremy Kerr 491781f86bSAndrew GeisslerThe system sensor structure is under the `/xyz/openbmc_project/sensors` 501781f86bSAndrew Geisslerhierarchy. 5198100205SJeremy Kerr 5298100205SJeremy KerrThis interface allows monitoring of system attributes like temperature or 5398100205SJeremy Kerraltitude, and are represented similar to the inventory, by object paths under 5498100205SJeremy Kerrthe top-level `sensors` object name. The path categorizes the sensor and shows 5598100205SJeremy Kerrwhat the sensor represents, but does not necessarily represent the physical 5698100205SJeremy Kerrtopology of the system. 5798100205SJeremy Kerr 5898100205SJeremy KerrFor example, all temperature sensors are under `sensors/temperature`. CPU 5998100205SJeremy Kerrtemperature sensors would be `sensors/temperature/cpu[n]`. 6098100205SJeremy Kerr 616ba5cff0SGunnar MillsThese are some common properties: 6298100205SJeremy Kerr 636ba5cff0SGunnar Mills * `Value`: Current value of the sensor 646ba5cff0SGunnar Mills * `Unit`: Unit of the value and "Critical" and "Warning" values 656ba5cff0SGunnar Mills * `Scale`: The scale of the value and "Critical" and "Warning" values 661781f86bSAndrew Geissler * `CriticalHigh` & `CriticalLow`: Sensor device upper/lower critical threshold 671781f86bSAndrew Geisslerbound 686ba5cff0SGunnar Mills * `CriticalAlarmHigh` & `CriticalAlarmLow`: True if the sensor has exceeded the 696ba5cff0SGunnar Millscritical threshold bound 701781f86bSAndrew Geissler * `WarningHigh` & `WarningLow`: Sensor device upper/lower warning threshold 711781f86bSAndrew Geisslerbound 726ba5cff0SGunnar Mills * `WarningAlarmHigh` & `WarningAlarmLow`: True if the sensor has exceeded the 736ba5cff0SGunnar Millswarning threshold bound 746ba5cff0SGunnar Mills 756ba5cff0SGunnar MillsA temperature sensor might look like: 766ba5cff0SGunnar Mills 77b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/sensors/temperature/ocp_zone 786ba5cff0SGunnar Mills { 796ba5cff0SGunnar Mills "data": { 80b41aff0fSXiaochao Ma "CriticalAlarmHigh": false, 81b41aff0fSXiaochao Ma "CriticalAlarmLow": false, 82b41aff0fSXiaochao Ma "CriticalHigh": 65000, 836ba5cff0SGunnar Mills "CriticalLow": 0, 84b41aff0fSXiaochao Ma "Functional": true, 85b41aff0fSXiaochao Ma "MaxValue": 0, 86b41aff0fSXiaochao Ma "MinValue": 0, 876ba5cff0SGunnar Mills "Scale": -3, 886ba5cff0SGunnar Mills "Unit": "xyz.openbmc_project.Sensor.Value.Unit.DegreesC", 89b41aff0fSXiaochao Ma "Value": 34625, 90b41aff0fSXiaochao Ma "WarningAlarmHigh": false, 91b41aff0fSXiaochao Ma "WarningAlarmLow": false, 92b41aff0fSXiaochao Ma "WarningHigh": 63000, 936ba5cff0SGunnar Mills "WarningLow": 0 946ba5cff0SGunnar Mills }, 956ba5cff0SGunnar Mills "message": "200 OK", 966ba5cff0SGunnar Mills "status": "ok" 976ba5cff0SGunnar Mills } 986ba5cff0SGunnar Mills 99b41aff0fSXiaochao MaNote the value of this sensor is 34.625C (34625 * 10^-3). 10098100205SJeremy Kerr 10198100205SJeremy KerrUnlike IPMI, there are no "functional" sensors in OpenBMC; functional states are 10298100205SJeremy Kerrrepresented in the inventory. 10398100205SJeremy Kerr 10498100205SJeremy KerrTo enumerate all sensors in the system: 10598100205SJeremy Kerr 106b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/sensors/enumerate 10798100205SJeremy Kerr 10898100205SJeremy KerrList properties of one inventory item: 10998100205SJeremy Kerr 110b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/sensors/temperature/outlet 11198100205SJeremy Kerr 112b41aff0fSXiaochao Ma## Event Logs 11398100205SJeremy Kerr 1141781f86bSAndrew GeisslerThe event log structure is under the `/xyz/openbmc_project/logging/entry` 1151781f86bSAndrew Geisslerhierarchy. Each event is a separate object under this structure, referenced by 1161781f86bSAndrew Geisslernumber. 11798100205SJeremy Kerr 1186ba5cff0SGunnar MillsBMC and host firmware on POWER-based servers can report event logs to the BMC. 1191781f86bSAndrew GeisslerTypically, these event logs are reported in cases where host firmware cannot 1201781f86bSAndrew Geisslerstart the OS, or cannot reliably log to the OS. 12198100205SJeremy Kerr 1226ba5cff0SGunnar MillsThe properties associated with an event log are as follows: 12398100205SJeremy Kerr 1246ba5cff0SGunnar Mills * `Message`: The type of event log (e.g. "xyz.openbmc_project.Inventory.Error.NotPresent"). 1256ba5cff0SGunnar Mills * `Resolved` : Indicates whether the event has been resolved. 1266ba5cff0SGunnar Mills * `Severity`: The level of problem ("Info", "Error", etc.). 1276ba5cff0SGunnar Mills * `Timestamp`: The date of the event log in epoch time. 128b41aff0fSXiaochao Ma * `Associations`: A URI to the failing inventory part. 12998100205SJeremy Kerr 1306ba5cff0SGunnar MillsTo list all reported event logs: 13198100205SJeremy Kerr 132b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/logging/entry 13398100205SJeremy Kerr { 13498100205SJeremy Kerr "data": [ 1356ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/3", 1366ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/2", 1376ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/1", 1386ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/7", 1396ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/6", 1406ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/5", 1416ba5cff0SGunnar Mills "/xyz/openbmc_project/logging/entry/4" 14298100205SJeremy Kerr ], 14398100205SJeremy Kerr "message": "200 OK", 14498100205SJeremy Kerr "status": "ok" 14598100205SJeremy Kerr } 14698100205SJeremy Kerr 14798100205SJeremy KerrTo read a specific event log: 14898100205SJeremy Kerr 149b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/logging/entry/1 15098100205SJeremy Kerr { 15198100205SJeremy Kerr "data": { 1526ba5cff0SGunnar Mills "AdditionalData": [ 153b41aff0fSXiaochao Ma "_PID=183" 1546ba5cff0SGunnar Mills ], 1556ba5cff0SGunnar Mills "Id": 1, 156b41aff0fSXiaochao Ma "Message": "xyz.openbmc_project.Common.Error.InternalFailure", 157b41aff0fSXiaochao Ma "Purpose": "xyz.openbmc_project.Software.Version.VersionPurpose.BMC", 158b41aff0fSXiaochao Ma "Resolved": false, 1596ba5cff0SGunnar Mills "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error", 160b41aff0fSXiaochao Ma "Timestamp": 1563191362822, 161b41aff0fSXiaochao Ma "Version": "2.8.0-dev-132-gd1c1b74-dirty", 162b41aff0fSXiaochao Ma "associations": [] 16398100205SJeremy Kerr }, 16498100205SJeremy Kerr "message": "200 OK", 16598100205SJeremy Kerr "status": "ok" 16698100205SJeremy Kerr } 16798100205SJeremy Kerr 168b41aff0fSXiaochao MaTo delete an event log (log 1 in this example), call the `Delete` method on the event: 16998100205SJeremy Kerr 170b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X POST -d '{"data" : []}' https://${bmc}/xyz/openbmc_project/logging/entry/1/action/Delete 17198100205SJeremy Kerr 172c8529037SGunnar MillsTo clear all event logs, call the top-level `DeleteAll` method: 17398100205SJeremy Kerr 174b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X POST -d '{"data" : []}' https://${bmc}/xyz/openbmc_project/logging/action/DeleteAll 17598100205SJeremy Kerr 176b41aff0fSXiaochao Ma## Host Boot Options 17798100205SJeremy Kerr 1786ba5cff0SGunnar MillsWith OpenBMC, the Host boot options are stored as D-Bus properties under the 179a6ea0d09SGunnar Mills`control/host0/boot` path. Properties include 180*2bc8dac0SKonstantin Aladyshev[`BootMode`](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Control/Boot/Mode.interface.yaml) 181a6ea0d09SGunnar Millsand 182*2bc8dac0SKonstantin Aladyshev[`BootSource`](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Control/Boot/Source.interface.yaml). 18398100205SJeremy Kerr 184b41aff0fSXiaochao Ma * Set boot mode: 1854cd993e2SJoel Stanley 186b41aff0fSXiaochao Ma ``` 187b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT https://${bmc}/xyz/openbmc_project/control/host0/boot/one_time/attr/BootMode -d '{"data": "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"}' 188b41aff0fSXiaochao Ma ``` 189b41aff0fSXiaochao Ma 190b41aff0fSXiaochao Ma * Set boot source: 191b41aff0fSXiaochao Ma 192b41aff0fSXiaochao Ma ``` 193b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT https://${bmc}/xyz/openbmc_project/control/host0/boot/one_time/attr/BootSource -d '{"data": "xyz.openbmc_project.Control.Boot.Source.Sources.Default"}' 194b41aff0fSXiaochao Ma ``` 195b41aff0fSXiaochao Ma 196b41aff0fSXiaochao Ma## Host State Control 1974cd993e2SJoel Stanley 1981781f86bSAndrew GeisslerThe host can be controlled through the `host` object. The object implements a 1991781f86bSAndrew Geisslernumber of actions including power on and power off. These correspond to the IPMI 2006ba5cff0SGunnar Mills`power on` and `power off` commands. 2014cd993e2SJoel Stanley 2026ba5cff0SGunnar MillsAssuming you have logged in, the following will power on the host: 2034cd993e2SJoel Stanley 2044cd993e2SJoel Stanley``` 205b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -d '{"data": "xyz.openbmc_project.State.Host.Transition.On"}' -X PUT https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition 2064cd993e2SJoel Stanley``` 2074cd993e2SJoel Stanley 2086ba5cff0SGunnar MillsTo power off the host: 2094cd993e2SJoel Stanley 2106ba5cff0SGunnar Mills``` 211b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -d '{"data": "xyz.openbmc_project.State.Host.Transition.Off"}' -X PUT https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition 2126ba5cff0SGunnar Mills``` 2136ba5cff0SGunnar Mills 2146ba5cff0SGunnar MillsTo issue a hard power off (accomplished by powering off the chassis): 2156ba5cff0SGunnar Mills 2166ba5cff0SGunnar Mills``` 217b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -d '{"data":"xyz.openbmc_project.State.Chassis.Transition.Off"}' https://${bmc}//xyz/openbmc_project/state/chassis0/attr/RequestedPowerTransition 2186ba5cff0SGunnar Mills``` 2196ba5cff0SGunnar Mills 2206ba5cff0SGunnar MillsTo reboot the host: 2216ba5cff0SGunnar Mills 2226ba5cff0SGunnar Mills``` 223b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -d '{"data":"xyz.openbmc_project.State.Host.Transition.Reboot"}' https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition 2246ba5cff0SGunnar Mills``` 2256ba5cff0SGunnar Mills 2266ba5cff0SGunnar Mills 2276ba5cff0SGunnar MillsMore information about Host State Management can be found here: 228*2bc8dac0SKonstantin Aladyshevhttps://github.com/openbmc/phosphor-dbus-interfaces/tree/master/yaml/xyz/openbmc_project/State 2297b31010eSMichael Tritz 230b41aff0fSXiaochao Ma## Host Clear GARD 2317b31010eSMichael Tritz 2327b31010eSMichael TritzOn OpenPOWER systems, the host maintains a record of bad or non-working 2337b31010eSMichael Tritzcomponents on the GARD partition. This record is referenced by the host on 2347b31010eSMichael Tritzsubsequent boots to determine which parts should be ignored. 2357b31010eSMichael Tritz 2367b31010eSMichael TritzThe BMC implements a function that simply clears this partition. This function 2377b31010eSMichael Tritzcan be called as follows: 2387b31010eSMichael Tritz 2397b31010eSMichael Tritz * Method 1: From the BMC command line: 2407b31010eSMichael Tritz 2417b31010eSMichael Tritz ``` 2427b31010eSMichael Tritz busctl call org.open_power.Software.Host.Updater \ 2437b31010eSMichael Tritz /org/open_power/control/gard \ 2447b31010eSMichael Tritz xyz.openbmc_project.Common.FactoryReset Reset 2457b31010eSMichael Tritz ``` 2467b31010eSMichael Tritz 2477b31010eSMichael Tritz * Method 2: Using the REST API: 2487b31010eSMichael Tritz 2497b31010eSMichael Tritz ``` 250b41aff0fSXiaochao Ma $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X POST -d '{"data":[]}' https://${bmc}/org/open_power/control/gard/action/Reset 2517b31010eSMichael Tritz ``` 2527b31010eSMichael Tritz 2537b31010eSMichael TritzImplementation: https://github.com/openbmc/openpower-pnor-code-mgmt 25484c1704bSAndrew Geissler 255b41aff0fSXiaochao Ma## Host Watchdog 25684c1704bSAndrew Geissler 25784c1704bSAndrew GeisslerThe host watchdog service is responsible for ensuring the host starts and boots 25884c1704bSAndrew Geisslerwithin a reasonable time. On host start, the watchdog is started and it is 25984c1704bSAndrew Geisslerexpected that the host will ping the watchdog via the inband interface 26084c1704bSAndrew Geisslerperiodically as it boots. If the host fails to ping the watchdog within the 26184c1704bSAndrew Geisslertimeout then the host watchdog will start a systemd target to go to the quiesce 26284c1704bSAndrew Geisslertarget. System settings will then determine the recovery behavior from that 26384c1704bSAndrew Geisslerstate, for example, attempting to reboot the system. 26484c1704bSAndrew Geissler 26584c1704bSAndrew GeisslerThe host watchdog utilizes the generic [phosphor-watchdog][1] repository. The 26684c1704bSAndrew Geisslerhost watchdog service provides 2 files as configuration options into 26784c1704bSAndrew Geisslerphosphor-watchdog: 26884c1704bSAndrew Geissler 26984c1704bSAndrew Geissler /lib/systemd/system/phosphor-watchdog@poweron.service.d/poweron.conf 27084c1704bSAndrew Geissler /etc/default/obmc/watchdog/poweron 27184c1704bSAndrew Geissler 27284c1704bSAndrew Geissler`poweron.conf` contains the "Conflicts" relationships to ensure the watchdog 27384c1704bSAndrew Geisslerservice is stopped at the correct times. `poweron` contains the required 27484c1704bSAndrew Geisslerinformation for phosphor-watchdog (more information on these can be found in the 27584c1704bSAndrew Geissler[phosphor-watchdog][1] repository). 27684c1704bSAndrew Geissler 27784c1704bSAndrew GeisslerThe 2 service files involved with the host watchdog are: 27884c1704bSAndrew Geissler 27984c1704bSAndrew Geissler phosphor-watchdog@poweron.service 28084c1704bSAndrew Geissler obmc-enable-host-watchdog@0.service 28184c1704bSAndrew Geissler 28284c1704bSAndrew Geissler`phosphor-watchdog@poweron` starts the host watchdog service and 28384c1704bSAndrew Geissler`obmc-enable-host-watchdog` starts the watchdog timer. Both are run as a part 28484c1704bSAndrew Geisslerof the `obmc-host-startmin@.target`. Service dependencies ensure the service is 28584c1704bSAndrew Geisslerstarted before the enable is called. 28684c1704bSAndrew Geissler 28784c1704bSAndrew GeisslerThe default watchdog timeout can be found within the [dbus interface 28884c1704bSAndrew Geisslerspecification][2] (Interval property). 28984c1704bSAndrew Geissler 29084c1704bSAndrew GeisslerThe host controls the watchdog timeout and enable/disable once it starts. 29184c1704bSAndrew Geissler 29284c1704bSAndrew Geissler[1]: https://github.com/openbmc/phosphor-watchdog 293*2bc8dac0SKonstantin Aladyshev[2]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Watchdog.interface.yaml 294