1# OpenBMC REST cheat sheet 2 3This document is intended to provide a set of REST client commands for OpenBMC usage. 4 5## Using CURL commands 6* Establish REST connection session: 7 ``` 8 $ export bmc=xx.xx.xx.xx 9 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://${bmc}/login -d "{\"data\": [ \"root\", \"0penBmc\" ] }" 10 ``` 11 12* List and enumerate: 13 ``` 14 $ curl -c cjar -b cjar -k https://${bmc}/xyz/openbmc_project/list 15 $ curl -c cjar -b cjar -k https://${bmc}/xyz/openbmc_project/enumerate 16 ``` 17 18* List sub-objects: 19 ``` 20 $ curl -c cjar -b cjar -k https://${bmc}/xyz/openbmc_project/ 21 $ curl -c cjar -b cjar -k https://${bmc}/xyz/openbmc_project/state/ 22 ``` 23 24* Host soft power off: 25 ``` 26 $ curl -c cjar -b cjar -k -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 27 ``` 28 29* Host hard power off: 30 ``` 31 $ curl -c cjar -b cjar -k -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 32 ``` 33 34* Host power on: 35 ``` 36 $ curl -c cjar -b cjar -k -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 37 ``` 38 39* Reboot Host: 40 ``` 41 $ curl -c cjar -b cjar -k -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 42 ``` 43 44* Reboot BMC: 45 ``` 46 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data":"xyz.openbmc_project.State.BMC.Transition.Reboot"}' https://${bmc}//xyz/openbmc_project/state/bmc0/attr/RequestedBMCTransition 47 ``` 48 49* Delete logging entries: 50 ``` 51 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X DELETE https://${bmc}/xyz/openbmc_project/logging/entry/<entry_id> 52 $ curl -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/logging/action/DeleteAll 53 ``` 54 55* Delete dump entries: 56 ``` 57 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X DELETE https://${bmc}/xyz/openbmc_project/dump/entry/<entry_id> 58 $ curl -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/dump/action/DeleteAll 59 ``` 60 61* Delete images from system: 62 63 - Delete image: 64 ``` 65 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/software/<image id>/action/Delete 66 ``` 67 68 - Delete all non-running images: 69 ``` 70 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d '{"data": []}' https://${bmc}/xyz/openbmc_project/software/action/DeleteAll 71 ``` 72 73* Clear gard records: 74 ``` 75 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d '{"data":[]}' https://${bmc}/org/open_power/control/gard/action/Reset 76 ``` 77 78* Set boot mode: 79 ``` 80 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT https://${bmc}/xyz/openbmc_project/control/host0/boot/one_time/attr/BootMode -d '{"data": "xy.openbmc_project.Control.Boot.Mode.Modes.Regular"}' 81 ``` 82 83* Set boot source: 84 ``` 85 $ curl -c cjar -b cjar -k -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"} 86 ``` 87 88* Set NTP and Nameserver: 89 90 Examples using public server. 91 - NTP Server: 92 ``` 93 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["pool.ntp.org"] }' https://${bmc}/xyz/openbmc_project/network/eth0/attr/NTPServers 94 ``` 95 96 - Name Server: 97 ``` 98 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": ["time.google.com"] }' https://${bmc}/xyz/openbmc_project/network/eth0/attr/Nameservers 99 ``` 100 101* Configure time ownership and time sync method: 102 103 - Read: 104 ``` 105 $ curl -c cjar -b cjar -k -X GET https://${bmc}/xyz/openbmc_project/time/owner/attr/TimeOwner 106 $ curl -c cjar -b cjar -k -X GET https://${bmc}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod 107 ``` 108 - Write: 109 ``` 110 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Synchronization.Method.NTP" }' https://${bmc}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod 111 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Synchronization.Method.Manual" }' https://${bmc}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod 112 113 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Owner.Owners.BMC" }' https://${bmc}/xyz/openbmc_project/time/owner/attr/TimeOwner 114 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Owner.Owners.Host” }' https://${bmc}/xyz/openbmc_project/time/owner/attr/TimeOwner 115 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Owner.Owners.Split" }' https://${bmc}/xyz/openbmc_project/time/owner/attr/TimeOwner 116 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.Time.Owner.Owners.Both” }' https://${bmc}/xyz/openbmc_project/time/owner/attr/TimeOwner 117 ``` 118 119* Power Supply Redundancy: 120 121 - Read: 122 ``` 123 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://${bmc}/xyz/openbmc_project/sensors/chassis/PowerSupplyRedundancy/action/getValue -d '{"data": []}' 124 ``` 125 126 or 127 128 ``` 129 $ curl -c cjar -b cjar -k -X GET https://${bmc}/xyz/openbmc_project/control/power_supply_redundancy 130 ``` 131 132 - Write (Enable/Disable): 133 ``` 134 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://${bmc}/xyz/openbmc_project/sensors/chassis/PowerSupplyRedundancy/action/setValue -d '{"data": ["Enabled"]}' 135 136 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://${bmc}/xyz/openbmc_project/sensors/chassis/PowerSupplyRedundancy/action/setValue -d '{"data": ["Disabled"]}' 137 ``` 138 or 139 140 ``` 141 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT https://${bmc}/xyz/openbmc_project/control/power_supply_redundancy/attr/PowerSupplyRedundancyEnabled -d '{"data": 1}' 142 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT https://${bmc}/xyz/openbmc_project/control/power_supply_redundancy/attr/PowerSupplyRedundancyEnabled -d '{"data": 0}' 143 ``` 144 145* Update "root" password: 146 147 - Change password from "OpenBmc" to "abc123": 148 ``` 149 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://${bmc}/login -d "{\"data\": [ \"root\", \"0penBmc\" ] }" 150 $ curl -c cjar -b cjar -k -H "Content-Type: application/json" -d "{\"data\": [\"abc123\"] }" -X POST https://${bmc}/xyz/openbmc_project/user/root/action/SetPassword 151 ``` 152 153* Factory Reset: 154 155 - Factory reset host and BMC software: 156 ``` 157 $ curl -c cjar -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/software/action/Reset 158 ``` 159 160 - Factory reset network setting: 161 ``` 162 $ curl -c cjar -b cjar -k -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/network/action/Reset 163 ``` 164 165 - Enable field mode: 166 ``` 167 $ curl -c cjar -b cjar -k -H 'Content-Type: application/json' -X PUT -d '{"data":1}' https://${bmc}/xyz/openbmc_project/software/attr/FieldModeEnabled 168 ``` 169 170 and then reboot BMC. 171