Skip to content

Instantly share code, notes, and snippets.

@glennswest
Created July 8, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennswest/35eb04fff0382f72fb823cb3be357c0c to your computer and use it in GitHub Desktop.
Save glennswest/35eb04fff0382f72fb823cb3be357c0c to your computer and use it in GitHub Desktop.
ASSISTED_SERVICE_API="api.openshift.com"
export CLUSTER_ID=`cat .clusterid`
export OFFLINE_ACCESS_TOKEN=`cat .ocmapitoken.txt`
export TOKEN=`curl \
--silent \
--data-urlencode "grant_type=refresh_token" \
--data-urlencode "client_id=cloud-services" \
--data-urlencode "refresh_token=${OFFLINE_ACCESS_TOKEN}" \
https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token | \
jq -r .access_token`
cat .nodes | grep cp > .masters
cat .masters | while read line
do
# do something with $line here
NODENAME=`echo $line | awk '{print $1}'`
NODEID=`echo $line | awk '{print $3}'`
curl --silent \
-H "Authorization: Bearer $TOKEN" \
-L "http://$ASSISTED_SERVICE_API/api/assisted-install/v1/clusters/$CLUSTER_ID/hosts/$NODEID" > .nodestatus
cat .nodestatus | jq -r ".role"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment