xref: /openbmc/docs/REDFISH-cheatsheet.md (revision 6eb7a424)
1# OpenBMC Redfish cheat sheet
2
3This document is intended to provide a set of [Redfish][1] client
4commands for OpenBMC usage.
5
6## Using CURL commands
7* Query Root
8   ```
9   $ export bmc=xx.xx.xx.xx
10   $ curl -b cjar -k https://${bmc}/redfish/v1
11   ```
12
13* Establish Redfish connection session:
14    ```
15   $ export bmc=xx.xx.xx.xx
16   $ curl --insecure -X POST -D headers.txt https://${bmc}/redfish/v1/SessionService/Sessions -d '{"UserName":"root", "Password":"0penBmc"}'
17    ```
18    A file, headers.txt, will be created. Find the "X-Auth-Token"
19    in that file. Save it away in an env variable like so:
20    ```
21    export bmc_token=<token>
22    ```
23
24* View Redfish Objects
25    ```
26    $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Chassis
27    $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Managers
28    $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems
29    ```
30
31* Host soft power off:
32    ```
33    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulShutdown"}'
34    ```
35
36* Host hard power off:
37    ```
38    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "ForceOff"}'
39    ```
40
41* Host power on:
42    ```
43    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "On"}'
44    ```
45
46* Reboot Host:
47    ```
48    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulRestart"}'
49    ```
50
51* Display logging entries:
52    ```
53    $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
54    ```
55
56* Delete logging entries:
57    ```
58    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.Reset
59    ```
60
61* Firmware ApplyTime:
62    ```
63    $ curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{ "ApplyTime":"Immediate"}' https://${bmc}/redfish/v1/UpdateService
64    ```
65
66    ```
67    $ curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{ "ApplyTime":"OnReset"}' https://${bmc}/redfish/v1/UpdateService
68    ```
69
70* Firmware update:
71    ```
72    $ curl -k -H "X-Auth-Token: $bmc_token" -H "Content-Type: application/octet-stream" -X POST -T <image file path> https://${bmc}/redfish/v1/UpdateService
73    ```
74
75* TFTP Firmware update using TransferProtocol:
76    ```
77    curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"TransferProtocol":"TFTP","ImageURI":"<image file path>"}'
78    ```
79
80* TFTP Firmware update with protocol in ImageURI:
81    ```
82    curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"ImageURI":"tftp://<image file path>"}'
83    ```
84
85[1]: https://www.dmtf.org/standards/redfish
86