xref: /openbmc/docs/REDFISH-cheatsheet.md (revision 876953d3)
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/1/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/1/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/1/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/1/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/1/LogServices/SEL/Entries
54    ```
55
56* Delete logging entries:
57    ```
58    $ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/1/LogServices/SEL/Actions/LogService.Reset
59    ```
60[1]: https://www.dmtf.org/standards/redfish
61