List all tenants belonging an user
Here is a simple script to list all tenants belonging an user:
#!/bin/bash
echo -n "Username : " ; read usercheck
for userid in $(keystone user-list | grep -w $usercheck | awk '{print$2}')
do
for tenant in $(keystone tenant-list | awk 'NR>3 && /^|/ {print$2}')
do
for tenantid in $(keystone user-role-list --user $userid --tenant $tenant | awk 'NR>3 && /^|/ {print$8}')
do
keystone tenant-list | grep $tenantid | awk '{print$4}'
done
done
doneecho -n "user name "; read usercheck; for userid in $(keystone user-list | grep $usercheck | awk '{print$2}'); do echo $userid | for tenant in $(keystone tenant-list | awk 'NR>3 && /^|/ {print$2}'); do echo $tenant | for tenantid in $(keystone user-role-list --user $userid --tenant $tenant | awk 'NR>3 && /^|/ {print$8}'); do keystone tenant-list | grep $tenantid | awk '{print$4}'; done ; done ; donecurl -i -X GET http://KEYSTONEIP:5000/v2.0/tenants -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: USERTOKEN"curl -i -X GET http://192.168.1.11:5000/v2.0/tenants -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: $OS_TOKEN"Last updated