/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Administration/Server/BMC/redfish/samples/redfish-commands.sh

  • Committer: Suren A. Chilingaryan
  • Date: 2023-01-22 13:43:11 UTC
  • Revision ID: csa@suren.me-20230122134311-zqe3ft10p33wqgfv
BMC/IPMI, smarthome, multicast-routing

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
set -euoE pipefail
 
3
 
 
4
# Redfish commands related to Virtual Media.
 
5
# Redfish doc reference: https://www.supermicro.com/manuals/other/RedfishRefGuide.pdf
 
6
 
 
7
export BMC_ADDRESS=''
 
8
export ISO_IMAGE=http://192.168.117.9:8080/ocp4-rwn-1-small.iso
 
9
export username_password='Administrator:superuser'
 
10
 
 
11
REDFISH_PATH=$( curl -sku ${username_password}  https://$BMC_ADDRESS/redfish/v1/Systems | jq '.Members[0]."@odata.id"' )
 
12
"/redfish/v1/Systems/Self"
 
13
 
 
14
 
 
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 
 
20
}
 
21
 
 
22
server_get_bios_config(){
 
23
    # Retrieve BIOS config over Redfish
 
24
    curl -sku ${username_password}  https://$BMC_ADDRESS/redfish/v1/Systems/Self/Bios
 
25
}
 
26
 
 
27
server_restart() {
 
28
    # Restart 
 
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
 
33
}
 
34
 
 
35
server_power_off() {
 
36
    # Power off
 
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
 
40
}
 
41
 
 
42
server_power_on() {
 
43
    # Power on
 
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
 
47
}
 
48
 
 
49
server_virtual_media_eject() {
 
50
    # Eject Media
 
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
 
54
}
 
55
 
 
56
server_virtual_media_status(){
 
57
    # 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'
 
61
}
 
62
 
 
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
 
69
}
 
70
 
 
71
server_set_boot_once_from_cd() {
 
72
    # Set boot order
 
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
 
77
}
 
78