Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
Last active August 4, 2017 01:46
Show Gist options
  • Save sturadnidge/f3e17bd9a89c800655421acbb805fe57 to your computer and use it in GitHub Desktop.
Save sturadnidge/f3e17bd9a89c800655421acbb805fe57 to your computer and use it in GitHub Desktop.
Upload File to Ops Manager
#!/bin/bash
# uaac is an alias set in .profile of ops manager user
shopt -s expand_aliases
source ~/.profile
function usage {
printf "Usage: ${0##*/} <file-to-upload.pivotal>\n"
exit 1
}
if [ $# -eq 0 ]
then
usage
fi
UAA_ACCESS_TOKEN=$(uaac context | awk -F access_token: '{print $2}' | tr -d '\n' | tr -d '[[:space:]]')
curl -k "https://localhost/api/v0/available_products" -X POST -H "Authorization: Bearer ${UAA_ACCESS_TOKEN}" -F "product[file]=@$1"
@sturadnidge
Copy link
Author

sturadnidge commented Apr 10, 2017

First, get an access token:

$uaac target localhost/uaa --skip-ssl-validation

$uaac token owner get
Client ID:  opsman
Client secret:  
User name:  <username from opsman initial setup>
Password:  <password from opsman initial setup>

Successfully fetched token via owner password grant.
Target: https://localhost/uaa
Context: admin, from client opsman

$ uaac token refresh

Then, export the access token (only) as UAA_ACCESS_TOKEN

export UAA_ACCESS_TOKEN=$(uaac context | awk -F access_token: '{print $2}' | tr -d '\n' | tr -d '[[:space:]]')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment