Created
June 12, 2012 16:10
-
-
Save fcharlier/2918442 to your computer and use it in GitHub Desktop.
Two scripts to list all Keystone tenants/users/roles
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
#!/usr/bin/env python | |
import os | |
from keystoneclient.v2_0 import client | |
keystone = client.Client(token=os.environ['SERVICE_TOKEN'], | |
endpoint=os.environ['SERVICE_ENDPOINT']) | |
for tenant in keystone.tenants.list(): | |
print '%s' % tenant.id | |
for user in tenant.list_users(): | |
print u" @ %s" % user.id | |
for role in user.list_roles(tenant): | |
print u" > %s" % role.id |
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 | |
keystone tenant-list|grep -v -- "-----"|egrep -v "id.*\|.*name"|awk '{ print $2 }'|while read TENANT; do | |
echo $TENANT | |
keystone user-list $TENANT|grep -v -- "-----"|egrep -v "id.*\|.*name"|awk '{ print $2 }'|while read USER;do | |
echo " @ $USER" | |
keystone role-list --user $USER --tenant_id $TENANT|grep -v -- "-----"|egrep -v "id.*\|.*name"|awk '{ print $2 }'|while read ROLE; do | |
echo " > $ROLE" | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment