Search code examples
pythonopenstack

How to list openstack user groups of a different domain?


I am connecting with an admin account on the Default domain and I am attempting to list all of the user groups of a non-Default domain, but I cannot figure out how to do this and there is no list_groups() equivalent that I can find in the OpenStack API documentation.

This code sample only returns the groups that the 'admin' user belongs to, not a list of ALL the user groups in the cloud.

conn = openstack.connect(cloudname)
pprint(conn.identity.groups())

I am looking to accomplish something similar in python code to what the cli command accomplishes:

openstack group list --domain nonDefault

Solution

  • I can only test this with users against my local OpenStack installation, but it looks as if you can provide a domain_id attribute. E.g:

    >>> len(list(conn.identity.users(domain_id='default')))
    300
    >>> len(list(conn.identity.users(domain_id='13b2c494c91842a5a698ce51aace2c94')))
    517
    

    Notet that this requires the domain id, not the domain name. You can ask conn.identity.domains() for a list of domains if you want to map names to ids.