Skip to content

Instantly share code, notes, and snippets.

@boina-n
Created May 23, 2019 13:08
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 boina-n/86324ff55af99bc4578b90fe93ae363c to your computer and use it in GitHub Desktop.
Save boina-n/86324ff55af99bc4578b90fe93ae363c to your computer and use it in GitHub Desktop.
Wrapped Pivotal om command
#!/bin/bash
bosh-creds () {
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/deployed/director/credentials/director_credentials | jq .credential.value
}
director-uaa-creds () {
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/deployed/director/credentials/uaa_admin_user_credentials |jq -r .credential.value
}
uaa-creds () {
productguid=$(om --target $OM_TARGET --skip-ssl-validation --username admin --password $OM_PASSWORD curl --silent -p /api/v0/deployed/products |jq '.[] | select(.type=="cf").guid' | tr -d '"')
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/deployed/products/$productguid/credentials/.uaa.admin_client_credentials |jq .credential.value
}
ops-version () {
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/diagnostic_report |jq -r '.versions'
}
ops-diag () {
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/diagnostic_report
}
latest-products-versions () {
products="$(om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/diagnostic_report | jq '.added_products.deployed | .[].name')"
for p in $products
do
pivnet releases -p $p --format=json | jq --arg p $p --tab ' {($p): [.[0,1] | {version : .version, release_date: .release_date, release_notes_url: .release_notes_url}]}'
done
}
deployed-products-versions () {
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD curl --silent -p /api/v0/diagnostic_report | jq '.added_products.deployed '
}
case "$1" in
"director-uaa-creds")
director-uaa-creds;;
"bosh-creds" )
bosh-creds;;
"uaa-creds" )
uaa-creds;;
"ops-version" )
ops-version;;
"ops-diag" )
ops-diag;;
"latest-products-versions" )
latest-products-versions;;
"deployed-products-versions" )
deployed-products-versions;;
"help" )
echo >&2 "Invalid option: $@ -> bosh-creds, uaa-creds, ops-version, ops-diag, latest-products-versions, deployed-products-versions"; exit 1;;
*)
om --target $OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD $@
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment