The purpose of this post is to collect in one place set of one-liners that I’ve been using in my day to day work.
- Get a list of VMs across the whole cluster with guest-agent status
# oc get vms -A -o json | jq -r '["Name", "Namespace", "Agent"], (.items[] | select(.status.conditions[] | select(.type == "AgentConnected")) | [.metadata.name, .metadata.namespace, .status.ready]) | @tsv' | column -t Name Namespace Agent fedora-emerald-hornet-13 demo true fedora-harlequin-dingo-62 demo true
- Using curl to access Redfish interface, insert Agent ISO hosted on locally available webserver of all servers matching “rhocp-controller” name.
# curl -sk https://192.168.232.1:8000/redfish/v1/Systems/ | jq -r '.Members[]."@odata.id"' | while read SYSTEM; do curl -sk https://192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match("rhocp-controller"))| .Id' | while read ID; do curl -k -d '{"Image":"http://192.168.232.1/agent.x86_64.iso", "Inserted": true}' -H "Content-Type: application/json" -X POST https://192.168.232.1:8000/redfish/v1/Managers/${ID}/VirtualMedia/Cd/Actions/VirtualMedia.InsertMedia ; done ; done
- Using curl to access Redfish interface, reset all servers matching “rhocp-controller” name.
# curl -sk https://192.168.232.1:8000/redfish/v1/Systems/ | jq -r '.Members[]."@odata.id"' | while read SYSTEM; do curl -sk https://192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match("rhocp-controller"))| .Id' | while read ID; do curl -k -d '{"Action": "Reset", "ResetType": "On"}' -X POST -H "Content-Type: application/json" https://192.168.232.1:8000/redfish/v1/Systems/${ID}/Actions/ComputerSystem.Reset ; done; done
- Using curl to access Redfish interface, get a list of all managed systems by that single Redfish instance.
# curl -sk https://192.168.232.1:8000/redfish/v1/Systems/ | jq -r '.Members[]."@odata.id"' | while read SYSTEM; do curl -sk https://192.168.232.1:8000${SYSTEM} | jq -r 'select(.Name | match("rhocp-")) | [.Id, .Name, .PowerState, .Manufacturer] | @tsv'; done | column -t 513183c9-a472-46ab-97a6-c9e808ccf776 rhocp-controller-2 On Sushy Emulator 7e54fb65-921e-46f4-a1ee-9f3f04a2141a rhocp-bastion On Sushy Emulator 96e1afcb-fddf-42a1-a15f-385b4e811355 rhocp-controller-1 On Sushy Emulator d833bbd6-c0fd-4cb7-843c-ad6a9f0f32ac rhocp-controller-0 On Sushy Emulator 80db3a4f-930c-4f5f-b4d0-cf18356fe9a5 rhocp-compute-0 Off Sushy Emulator