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## 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## BMC reboot 69``` 70curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Managers/bmc/Actions/Manager.Reset -d '{"ResetType": "GracefulRestart"}' 71``` 72 73--- 74 75## Log entry 76Display logging entries: 77``` 78curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries 79``` 80 81Delete logging entries: 82``` 83curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.Reset 84``` 85 86--- 87 88## Firmware ApplyTime: 89``` 90curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"Immediate"}' https://${bmc}/redfish/v1/UpdateService 91``` 92 93or 94 95``` 96curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "ApplyTime":"OnReset"}' https://${bmc}/redfish/v1/UpdateService 97``` 98 99--- 100 101## Firmware update 102Firmware update: 103Note the `<image file path>` must be a tarball. 104 105``` 106curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X POST -T <image file path> https://${bmc}/redfish/v1/UpdateService 107``` 108TFTP Firmware update using TransferProtocol: 109Note: The `<image file path>` contains the address of the TFTP service: `xx.xx.xx.xx/obmc-phosphor-xxxxx-xxxxxxxxx.static.mtd.tar` 110 111``` 112curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"TransferProtocol":"TFTP","ImageURI":"<image file path>"}' 113``` 114TFTP Firmware update with protocol in ImageURI: 115``` 116curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate -d '{"ImageURI":"tftp://<image file path>"}' 117``` 118 119--- 120 121## Update "root" password 122Change password to "0penBmc1": 123``` 124curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"Password": "0penBmc1"}' https://${bmc}/redfish/v1/AccountService/Accounts/root 125``` 126 127--- 128 129## BIOS firmware boot control 130Enter into BIOS setup on boot 131``` 132curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Continuous","BootSourceOverrideTarget": "BiosSetup"}}' 133``` 134 135Fully boot 136``` 137curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Disabled","BootSourceOverrideTarget": "None"}}' 138``` 139 140Change Legacy/EFI selector (valid only if host is based on the x86 CPU) 141``` 142curl -k -H "X-Auth-Token: $token" -X PATCH https://${bmc}/redfish/v1/Systems/system -d '{"Boot":{"BootSourceOverrideEnabled": "Once","BootSourceOverrideTarget": "None","BootSourceOverrideMode": "UEFI"}}' 143``` 144 145[1]: https://www.dmtf.org/standards/redfish 146