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``` 7$ export bmc=xx.xx.xx.xx 8$ curl -b cjar -k https://${bmc}/redfish/v1 9``` 10## Establish Redfish connection session 11- Method 1 12 ``` 13 $ export bmc=xx.xx.xx.xx 14 $ curl --insecure -X POST -D headers.txt https://${bmc}/redfish/v1/SessionService/Sessions -d '{"UserName":"root", "Password":"0penBmc"}' 15 ``` 16 A file, headers.txt, will be created. Find the `"X-Auth-Token"` 17 in that file. Save it away in an env variable like so: 18 19 ``` 20 export bmc_token=<token> 21 ``` 22- Method 2 23 ``` 24 $ export bmc=xx.xx.xx.xx 25 $ export 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 '"'` 26 $ curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/... 27 ``` 28 Note: Method 2 is used in this document. 29## View Redfish Objects 30``` 31$ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis 32$ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers 33$ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems 34``` 35## Host power 36- Host soft power off: 37 ``` 38 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulShutdown"}' 39 ``` 40- Host hard power off: 41 ``` 42 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "ForceOff"}' 43 ``` 44- Host power on: 45 ``` 46 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "On"}' 47 ``` 48- Reboot Host: 49 ``` 50 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/Actions/ComputerSystem.Reset -d '{"ResetType": "GracefulRestart"}' 51 ``` 52## Log entry 53- Display logging entries: 54 ``` 55 $ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries 56 ``` 57- Delete logging entries: 58 ``` 59 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.Reset 60 ``` 61## Firmware ApplyTime: 62 ``` 63$ curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"Immediate"}' https://${bmc}/redfish/v1/UpdateService 64 ``` 65 66or 67 68``` 69$ curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"OnReset"}' https://${bmc}/redfish/v1/UpdateService 70``` 71## Firmware update 72- Firmware update: 73 Note the `<image file path>` must be a tarball. 74 75 ``` 76 $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X POST -T <image file path> https://${bmc}/redfish/v1/UpdateService 77 ``` 78- TFTP Firmware update using TransferProtocol: 79 Note: The `<image file path>` contains the address of the TFTP service: `xx.xx.xx.xx/obmc-phosphor-xxxxx-xxxxxxxxx.static.mtd.tar` 80 81 ``` 82 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"TransferProtocol":"TFTP","ImageURI":"<image file path>"}' 83 ``` 84- TFTP Firmware update with protocol in ImageURI: 85 ``` 86 $ curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"ImageURI":"tftp://<image file path>"}' 87 ``` 88## Update "root" password 89Change password to "0penBmc1": 90``` 91$ curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"Password": "0penBmc1"}' https://${bmc}/redfish/v1/AccountService/Accounts/root 92``` 93 94[1]: https://www.dmtf.org/standards/redfish 95