4
# Redfish commands related to Virtual Media.
5
# Redfish doc reference: https://www.supermicro.com/manuals/other/RedfishRefGuide.pdf
8
export ISO_IMAGE=http://192.168.117.9:8080/ocp4-rwn-1-small.iso
9
export username_password='Administrator:superuser'
11
REDFISH_PATH=$( curl -sku ${username_password} https://$BMC_ADDRESS/redfish/v1/Systems | jq '.Members[0]."@odata.id"' )
12
"/redfish/v1/Systems/Self"
15
server_secureboot_delete_keys() {
16
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
17
-H "Content-Type: application/json" -H "Accept: application/json" \
18
-d '{"ResetKeysType":"DeleteAllKeys"}' \
19
-X POST https://$BMC_ADDRESS/redfish/v1/Systems/Self/SecureBoot/Actions/SecureBoot.ResetKeys
22
server_get_bios_config(){
23
# Retrieve BIOS config over Redfish
24
curl -sku ${username_password} https://$BMC_ADDRESS/redfish/v1/Systems/Self/Bios
29
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
30
-H "Content-Type: application/json" -H "Accept: application/json" \
31
-d '{"ResetType": "ForceRestart"}' \
32
-X POST https://$BMC_ADDRESS/redfish/v1/Systems/Self/Actions/ComputerSystem.Reset
37
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
38
-H "Content-Type: application/json" -H "Accept: application/json" \
39
-d '{"ResetType": "ForceOff"}' -X POST https://$BMC_ADDRESS/redfish/v1/Systems/Self/Actions/ComputerSystem.Reset
44
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
45
-H "Content-Type: application/json" -H "Accept: application/json" \
46
-d '{"ResetType": "On"}' -X POST https://$BMC_ADDRESS/redfish/v1/Systems/Self/Actions/ComputerSystem.Reset
49
server_virtual_media_eject() {
51
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
52
-H "Content-Type: application/json" -H "Accept: application/json" \
53
-d '{}' -X POST https://$BMC_ADDRESS/redfish/v1/Managers/Self/VirtualMedia/1/Actions/VirtualMedia.EjectMedia
56
server_virtual_media_status(){
58
curl -s --globoff -H "Content-Type: application/json" -H "Accept: application/json" \
59
-k -X GET --user ${username_password} \
60
https://$BMC_ADDRESS/redfish/v1/Managers/Self/VirtualMedia/1 | jq '.MediaStatus'
63
server_virtual_media_insert(){
64
# Insert Media from http server and iso file
65
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
66
-H "Content-Type: application/json" -H "Accept: application/json" \
67
-d '{"Image": "$ISO_IMAGE"}' \
68
-X POST https://$BMC_ADDRESS/redfish/v1/Managers/Self/VirtualMedia/1/Actions/VirtualMedia.InsertMedia
71
server_set_boot_once_from_cd() {
73
curl --globoff -L -w "%{http_code} %{url_effective}\\n" -ku ${username_password} \
74
-H "Content-Type: application/json" -H "Accept: application/json" \
75
-d '{"Boot":{ "BootSourceOverrideEnabled": "Once", "BootSourceOverrideTarget": "Cd", "BootSourceOverrideMode": "UEFI"}}' \
76
-X PATCH http://$BMC_ADDRESS/redfish/v1/Systems/Self