xref: /openbmc/docs/REDFISH-cheatsheet.md (revision cb5e5cfa)
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 Redfish Service Root
6```
7export bmc=xx.xx.xx.xx
8curl -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## View sessions
46```
47curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/SessionService/Sessions
48```
49
50---
51
52## Host power
53Host soft power off:
54```
55curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulShutdown"}'
56```
57
58Host hard power off:
59```
60curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "ForceOff"}'
61```
62
63Host power on:
64```
65curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "On"}'
66```
67
68Reboot Host:
69```
70curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulRestart"}'
71```
72
73---
74
75## BMC reboot
76```
77curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Managers/bmc/Actions/Manager.Reset -d '{"ResetType": "GracefulRestart"}'
78```
79
80---
81
82## BMC factory reset
83Proceed with caution:
84```
85curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults -d '{"ResetToDefaultsType": "ResetAll"}'
86```
87
88---
89
90## Log entry
91Display logging entries:
92```
93curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
94```
95
96Delete logging entries:
97```
98curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.Reset
99```
100
101---
102
103## Firmware ApplyTime:
104```
105curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"Immediate"}' https://${bmc}/redfish/v1/UpdateService
106```
107
108or
109
110```
111curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"OnReset"}' https://${bmc}/redfish/v1/UpdateService
112```
113
114---
115
116## Firmware update
117Firmware update:
118Note the `<image file path>` must be a tarball.
119
120```
121curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X POST -T <image file path> https://${bmc}/redfish/v1/UpdateService
122```
123TFTP Firmware update using TransferProtocol:
124Note: The `<image file path>` contains the address of the TFTP service: `xx.xx.xx.xx/obmc-phosphor-xxxxx-xxxxxxxxx.static.mtd.tar`
125
126```
127curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"TransferProtocol":"TFTP","ImageURI":"<image file path>"}'
128```
129TFTP Firmware update with protocol in ImageURI:
130```
131curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"ImageURI":"tftp://<image file path>"}'
132```
133
134---
135
136## Update "root" password
137Change password to "0penBmc1":
138```
139curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"Password": "0penBmc1"}' https://${bmc}/redfish/v1/AccountService/Accounts/root
140```
141
142---
143
144## BIOS firmware boot control
145Enter into BIOS setup on boot
146```
147curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Continuous","BootSourceOverrideTarget": "BiosSetup"}}'
148```
149
150Fully boot
151```
152curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Disabled","BootSourceOverrideTarget": "None"}}'
153```
154
155Change Legacy/EFI selector (valid only if host is based on the x86 CPU)
156```
157curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Once","BootSourceOverrideTarget": "None","BootSourceOverrideMode": "UEFI"}}'
158```
159
160---
161
162## Enable NTP
163Add a NTP Server
164```
165curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol -d '{"NTP":{"NTPServers":["time.nist.gov"]}}'
166```
167
168Now enable NTP
169```
170curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol -d '{"NTP":{"ProtocolEnabled": true}}'
171```
172
173---
174
175## Disable IPMI
176```
177curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol -d '{"IPMI":{"ProtocolEnabled": false}}'
178```
179
180
181[1]: https://www.dmtf.org/standards/redfish
182