xref: /openbmc/docs/REDFISH-cheatsheet.md (revision b685fd04)
1# Redfish cheat sheet
2This document is intended to provide a set of [Redfish][1] client commands for OpenBMC usage.
3(Using CURL commands)
4
5## Query Root
6```
7export bmc=xx.xx.xx.xx
8curl -b cjar -k https://${bmc}/redfish/v1
9```
10
11---
12
13## Establish Redfish connection session
14##### Method 1
15```
16export bmc=xx.xx.xx.xx
17curl --insecure -X POST -D headers.txt https://${bmc}/redfish/v1/SessionService/Sessions -d    '{"UserName":"root", "Password":"0penBmc"}'
18```
19A file, headers.txt, will be created. Find the `"X-Auth-Token"`
20in that file. Save it away in an env variable like so:
21
22```
23export bmc_token=<token>
24```
25
26#####  Method 2
27```
28export bmc=xx.xx.xx.xx
29export 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 '"'`
30curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/...
31```
32Note: Method 2 is used in this document.
33
34---
35
36## View Redfish Objects
37```
38curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis
39curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers
40curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems
41```
42
43---
44
45## Host power
46Host soft power off:
47```
48curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulShutdown"}'
49```
50
51Host hard power off:
52```
53curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "ForceOff"}'
54```
55
56Host power on:
57```
58curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "On"}'
59```
60
61Reboot Host:
62```
63curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulRestart"}'
64```
65
66---
67
68## Log entry
69Display logging entries:
70```
71curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
72```
73
74Delete logging entries:
75```
76curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.Reset
77```
78
79---
80
81## Firmware ApplyTime:
82```
83curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"Immediate"}' https://${bmc}/redfish/v1/UpdateService
84```
85
86or
87
88```
89curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"OnReset"}' https://${bmc}/redfish/v1/UpdateService
90```
91
92---
93
94## Firmware update
95Firmware update:
96Note the `<image file path>` must be a tarball.
97
98```
99curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X POST -T <image file path> https://${bmc}/redfish/v1/UpdateService
100```
101TFTP Firmware update using TransferProtocol:
102Note: The `<image file path>` contains the address of the TFTP service: `xx.xx.xx.xx/obmc-phosphor-xxxxx-xxxxxxxxx.static.mtd.tar`
103
104```
105curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"TransferProtocol":"TFTP","ImageURI":"<image file path>"}'
106```
107TFTP Firmware update with protocol in ImageURI:
108```
109curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"ImageURI":"tftp://<image file path>"}'
110```
111
112---
113
114## Update "root" password
115Change password to "0penBmc1":
116```
117curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"Password": "0penBmc1"}' https://${bmc}/redfish/v1/AccountService/Accounts/root
118```
119
120## BIOS firmware boot control
121- Enter into BIOS setup on boot
122  ```
123  $ curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Continuous","BootSourceOverrideTarget": "BiosSetup"}}'
124  ```
125- Fully boot
126  ```
127  $ curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Disabled","BootSourceOverrideTarget": "None"}}'
128  ```
129- Change Legacy/EFI selector (valid only if host is based on the x86 CPU)
130  ```
131  $ curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Once","BootSourceOverrideTarget": "None","BootSourceOverrideMode": "UEFI"}}'
132  ```
133
134[1]: https://www.dmtf.org/standards/redfish
135