Skip to content

Instantly share code, notes, and snippets.

@openstacker
Created December 21, 2017 10:29
Show Gist options
  • Select an option

  • Save openstacker/42905eb70a839cc4c99284b1d97a2dae to your computer and use it in GitHub Desktop.

Select an option

Save openstacker/42905eb70a839cc4c99284b1d97a2dae to your computer and use it in GitHub Desktop.
#!/bin/sh
auth_json=$(cat << EOF
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"id": "af0f32b9117d4985a8ef44e44623ff40",
"password": "HLQzFmds8kTEPbRyAK"
}
}
}
}
}
EOF
)
content_type='Content-Type: application/json'
url="https://feilong-dev-epxy1.openstacklocal:5000/v3/auth/tokens"
USER_TOKEN=`curl -k -s -i -X POST -H "$content_type" -d "$auth_json" $url \
| grep X-Subject-Token | awk '{print $2}' | tr -d '[[:space:]]'`
echo $USER_TOKEN
MAGNUM_URL='https://feilong-dev-api1.openstacklocal:9511/v1'
CLUSTER_UUID='e0fecc1d-4621-4c9f-9fa4-582daa8332ad'
CA_CERT=/home/fedora/ca.crt
curl -k -X GET \
-H "X-Auth-Token: $USER_TOKEN" \
-H "OpenStack-API-Version: container-infra latest" \
$MAGNUM_URL/certificates/$CLUSTER_UUID | python -c 'import sys, json; print json.load(sys.stdin)["pem"]' > ${CA_CERT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment