Last active
August 25, 2016 09:32
-
-
Save codevulture/9e67202e942087535b4370722ae11026 to your computer and use it in GitHub Desktop.
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
#Source openstack credentials before running | |
$. openrc admin admin | |
#Running script | |
$./keystone_trust_test 1>&2 2>/dev/null | |
#file: keystone_trust_test | |
#!/bin/sh | |
admin_project=$(openstack project list | grep "\<admin\>"| cut -d'|' -f2 | tr -d '[[:space:]]') | |
demo_project=$(openstack project list | grep "\<demo\>"| cut -d'|' -f2 | tr -d '[[:space:]]') | |
admin_user=$(openstack user list | grep "\<admin\>"| cut -d'|' -f2 | tr -d '[[:space:]]') | |
demo_user=$(openstack user list | grep "\<demo\>"| cut -d'|' -f2 | tr -d '[[:space:]]') | |
echo "Admin User:" $admin_user | |
echo "Demo User:" $demo_user | |
auth_json=$(cat << EOF | |
{ "auth": | |
{ "identity": | |
{ "methods": [ "password" ], | |
"password": | |
{ "user": | |
{ "id": "$admin_user", | |
"password": "123" | |
} | |
} | |
} | |
} | |
} | |
EOF | |
) | |
ADMIN_TOKEN=`curl -i -d "$auth_json" -H "Content-type: application/json" http://10.0.2.15:35357/v3/auth/tokens | grep X-Subject-Token | awk '{print $2}' | tr -d '[[:space:]]'` | |
echo "Admin Token" $ADMIN_TOKEN | |
user_auth_json=$(cat << EOF | |
{ "auth": | |
{ "identity": | |
{ "methods": [ "password" ], | |
"password": | |
{ "user": | |
{ "id": "$demo_user", | |
"password": "123" | |
} | |
} | |
} | |
} | |
} | |
EOF | |
) | |
USER_TOKEN=`curl -i -d "$user_auth_json" -H "Content-type: application/json" http://10.0.2.15:35357/v3/auth/tokens | grep X-Subject-Token | awk '{print $2}' | tr -d '[[:space:]]'` | |
echo "User Token:" $USER_TOKEN | |
#########################################trust_id_generation | |
trust_generation_json=$(cat << EOF | |
{ | |
"trust": { | |
"expires_at": "2024-02-27T18:30:59.999999Z", | |
"impersonation": true, | |
"project_id": "$admin_project", | |
"roles": [ { "name": "admin"} ], | |
"trustee_user_id": "$demo_user", | |
"trustor_user_id": "$admin_user" } | |
} | |
EOF | |
) | |
######################################### | |
echo " " | |
echo "trust response:" | |
curl -s -H "X-Auth-Token: $ADMIN_TOKEN" -d "$trust_generation_json" -H "Content-type: application/json" http://10.0.2.15:35357/v3/OS-TRUST/trusts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment