-
-
Save jgato/accdf3eae749aed97b84e9d034b0700c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
export iLO=192.168. | |
export AUTH="user:pass" | |
export HTTP_ISO="http:/<IP>/iso/<ISO>" | |
bios_status(){ | |
curl -k -s -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-X GET https://"$iLO"/redfish/v1/Systems/1/Bios | |
} | |
server_status(){ | |
curl -k -s -L -u "$AUTH" -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-X GET https://"$iLO"/redfish/v1/Systems/1 | |
} | |
manager_status(){ | |
curl -k -s -L -u "$AUTH" -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-X GET https://"$iLO"/redfish/v1/Managers/1/ | |
} | |
power_status(){ | |
server_status | jq .PowerState | |
} | |
power_off(){ | |
curl -k -s --noproxy "*" -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" --globoff -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-d '{"ResetType": "ForceOff"}' \ | |
-X POST https://$iLO/redfish/v1/Systems/1/Actions/ComputerSystem.Reset | |
} | |
power_on(){ | |
curl -k -s --noproxy "*" -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" --globoff -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-d '{"ResetType": "On"}' \ | |
-X POST https://$iLO/redfish/v1/Systems/1/Actions/ComputerSystem.Reset | |
} | |
media_insert(){ | |
curl -k -s --noproxy "*" -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" --globoff -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-d "{\"Image\": \"$HTTP_ISO\", \"Inserted\":true, \"WriteProtected\":true}" \ | |
-X POST https://$iLO/redfish/v1/Managers/1/VirtualMedia/2/Actions/VirtualMedia.InsertMedia | |
} | |
media_eject() { | |
curl -k -s --noproxy "*" -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" --globoff -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-d '{}' -X POST https://$iLO/redfish/v1/Managers/1/VirtualMedia/2/Actions/VirtualMedia.EjectMedia | |
} | |
media_status(){ | |
curl -k -s -L -u "$AUTH" -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://"$iLO"/redfish/v1/Managers/1/VirtualMedia/2 | jq | |
} | |
boot_status(){ | |
server_status | jq -r '[.Boot.BootSourceOverrideEnabled, .Boot.BootSourceOverrideTarget] | @tsv ' | |
} | |
boot_once() { | |
curl -k -s --noproxy "*" -L -u "$AUTH" -w "%{http_code} %{url_effective}\\n" --globoff -H "Content-Type: application/json" -H "Accept: application/json" \ | |
-d '{"Boot":{ "BootSourceOverrideEnabled": "Once", "BootSourceOverrideTarget": "Cd"}}' \ | |
-X PATCH https://$iLO/redfish/v1/Systems/1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment