Skip to content

Instantly share code, notes, and snippets.

@masayag
Last active February 18, 2021 13:16
Show Gist options
  • Select an option

  • Save masayag/8872e6303af393a90c132ff95e25b0b4 to your computer and use it in GitHub Desktop.

Select an option

Save masayag/8872e6303af393a90c132ff95e25b0b4 to your computer and use it in GitHub Desktop.
export BM_INVENTORY_SERVER=$(hostname)
# to be run on assisted-test-infra env
alias list-nodes='sudo virsh net-dhcp-leases test-infra-net'
list-clusters() {
curl -s http://$BM_INVENTORY_SERVER:6008/api/assisted-install/v1/clusters/ | jq '.[] | {ID: .id, Name: .name}'
}
list-hosts() {
# expects $1 to be a valid cluster-id
if [ -z "$1" ]
then
echo "list-hosts <cluster-id>"
return 1
fi
curl -s http://$BM_INVENTORY_SERVER:6008/api/assisted-install/v1/clusters/$1/hosts/ | jq '.[] | {ID: .id, Name: .requested_hostname, Status: .status}'
}
get-host() {
# expects $1 to be a valid cluster-id
if [ -z "$2" ]
then
echo "get-host <cluster-id> <host-id>"
return 1
fi
curl -s http://$BM_INVENTORY_SERVER:6008/api/assisted-install/v1/clusters/$1/hosts/$2 | jq
}
get-worker-ignition-encoded() {
if [ -z "$1" ]
then
echo "get-worker-ignition-encoded <ignition-provider-address>"
return 1
fi
curl -s http://$1/worker.ign | base64 -w 0 | xargs
}
install-host() {
if [ -z "$3" ]
then
echo "install-host <cluster-id> <host-id> <worker-ignition>"
return 1
fi
IGNITION=$3
install_body=$(mktemp)
cat <<EOF >> $install_body
{
"worker_ignition": "$IGNITION"
}
EOF
curl -H "Content-Type: application/json" \
-X POST -d @$install_body http://$BM_INVENTORY_SERVER:6008/api/assisted-install/v1/clusters/$1/hosts/$2/actions/install
}
get-host-inventory() {
# expects $1 to be a valid cluster-id
if [ -z "$2" ]
then
echo "get-host <cluster-id> <host-id>"
return 1
fi
curl -s http://$BM_INVENTORY_SERVER:6008/api/assisted-install/v1/clusters/$1/hosts/$2 | jq '.inventory'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment