Skip to content

Instantly share code, notes, and snippets.

@dofinn
Last active June 26, 2020 08:15
Show Gist options
  • Save dofinn/71ac69bdf8f32947ebd8585825495731 to your computer and use it in GitHub Desktop.
Save dofinn/71ac69bdf8f32947ebd8585825495731 to your computer and use it in GitHub Desktop.
Get state of target cluster to trigger reminders of action.
#!/bin/bash
clusterIdentifier=$1
OCM=~/go/bin/ocm
/usr/local/bin/ocm-stg-login
clusterInfo=$(${OCM} cluster list --managed | grep ${clusterIdentifier})
clusterId=$(echo ${clusterInfo} | awk '{print $1}')
clusterName=$(echo ${clusterInfo} | awk '{print $2}')
expiration=$(${OCM} get https://api.stage.openshift.com/api/clusters_mgmt/v1/clusters/"${clusterId}" | jq -r '.expiration_timestamp' | xargs -I{} date -d '{}')
notify-send "Cluster: ${clusterName} Expires: ${expiration}" \
"Delete? ocm delete https://api.stage.openshift.com/api/clusters_mgmt/v1/clusters/${clusterId}" \
-i /usr/share/pixmaps/fedora-logo-sprite.png \
-t 20000 \
-u normal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment