Created
March 26, 2013 16:55
-
-
Save robert-chiniquy/5247066 to your computer and use it in GitHub Desktop.
keystone bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
[ -e ~/.raxrc ] || (echo -e "Please create a ~/.raxrc file with your credentials\nhttps://github.com/racker/rackspace-monitoring-cli#settings-credentials\n" >&2 && exit 1) | |
USERNAME=`grep username ~/.raxrc | awk -F'=' '{print $2}'` | |
API_KEY=`grep api_key ~/.raxrc | awk -F'=' '{print $2}'` | |
[ -z "$USERNAME" ] && (echo -e "No username in ~/.raxrc!" && exit 1) | |
[ -z "$API_KEY" ] && (echo -e "No api_key in ~/.raxrc!" && exit 1) | |
AUTH_TOKEN=`curl -X POST -H 'Host: auth.api.rackspacecloud.com' -H 'Accept-Encoding: gzip,deflate' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json' -H 'User-Agent: maas-in-chains 0.0' --data-binary '{"auth": {"RAX-KSKEY:apiKeyCredentials": {"username": "'$USERNAME'", "apiKey": "'$API_KEY'"}}}' --compress https://auth.api.rackspacecloud.com:443/v2.0/tokens 2>&1 | grep -oe '..token.:..id.:.[^\"]*' | sed -e 's/.*:"//g'` | |
echo $AUTH_TOKEN | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment