Skip to content

Commit d6f21b0

Browse files
committed
Adds script to manage sushy BMCs
Signed-off-by: Alberto Losada <alosadag@redhat.com>
1 parent 80e33b0 commit d6f21b0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

sushy/mount-sushy-iso.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
HTTP_SERVER=10.19.138.94
2+
HTTP_SERVER_PORT=80
3+
NODE=$1
4+
ISO=$2
5+
VM_HOST="10.19.33.6:8888"
6+
7+
read -p "Spin up ${ISO} ISO in ${NODE} VM node [y/N]: " SPIN_UP
8+
9+
if [ "$SPIN_UP" == "y" ]; then
10+
VM_ID=$(kcli info vm $NODE -f id -v)
11+
#curl -ks ${VM_HOST}/redfish/v1/Managers/${VM_ID} | jq
12+
curl -ks ${VM_HOST}/redfish/v1/Systems/${VM_ID} | jq .Boot
13+
14+
curl -ks -X PATCH -H 'Content-Type: application/json' -d '{
15+
"Boot": {
16+
"BootSourceOverrideTarget": "Cd",
17+
"BootSourceOverrideEnabled": "Continuous"
18+
}
19+
}' "${VM_HOST}/redfish/v1/Systems/${VM_ID}"
20+
21+
curl -ks ${VM_HOST}/redfish/v1/Systems/${VM_ID} | jq .Boot
22+
23+
# Check inserted ISO:
24+
curl -ks ${VM_HOST}/redfish/v1/Managers/${VM_ID}/VirtualMedia/Cd/ | jq '[{iso_connected: .Inserted}]'
25+
26+
BOOTSTRAP_ISO="http://${HTTP_SERVER}:${HTTP_SERVER_PORT}/${ISO}"
27+
############################
28+
29+
curl -ks -d '{
30+
"Image":"'"${BOOTSTRAP_ISO}"'",
31+
"Inserted": true
32+
}' -H "Content-Type: application/json" \
33+
-X POST ${VM_HOST}/redfish/v1/Managers/${VM_ID}/VirtualMedia/Cd/Actions/VirtualMedia.InsertMedia
34+
35+
curl -ks ${VM_HOST}/redfish/v1/Managers/${VM_ID}/VirtualMedia/Cd/ | jq '[{iso_connected: .Inserted}]'
36+
37+
#Start VM
38+
curl -s -d '{"ResetType":"ForceOff"}' -H "Content-Type: application/json" -X POST http://${VM_HOST}/redfish/v1/Systems/$VM_ID/Actions/ComputerSystem.Reset
39+
curl -ks -H "Content-Type: application/json" -X POST ${VM_HOST}/redfish/v1/Systems/${VM_ID}/Actions/ComputerSystem.Reset -d '{"ResetType": "ForceOn"}'
40+
41+
fi

0 commit comments

Comments
 (0)