Skip to content

Instantly share code, notes, and snippets.

@karampok
Last active January 13, 2023 09:25
Show Gist options
  • Save karampok/a47793b5844495e6b37bbcf5f177e206 to your computer and use it in GitHub Desktop.
Save karampok/a47793b5844495e6b37bbcf5f177e206 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
export AUTH="user:pass"
# bios_status https://192.168.X.Y
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 "$1"/redfish/v1/Systems/1/Bios
}
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 "$1"/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 "$1"/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://192.168.18.10/iso/agent-hpe181.iso"}' \
-X POST "$1"/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 "$1"/redfish/v1/Managers/1/VirtualMedia/2/Actions/VirtualMedia.EjectMedia
}
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 "$1"/redfish/v1/Systems/1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment