Skip to content

Instantly share code, notes, and snippets.

@fcharlier
Created June 12, 2012 16:10
Show Gist options
  • Save fcharlier/2918442 to your computer and use it in GitHub Desktop.
Save fcharlier/2918442 to your computer and use it in GitHub Desktop.
Two scripts to list all Keystone tenants/users/roles
#!/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
#!/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