def user_role_list(user_id=None, tenant_id=None, user_name=None,
                   tenant_name=None, profile=None, project_id=None, project_name=None, **connection_args):
    '''
    Return a list of available user_roles (keystone user-roles-list)

    CLI Examples:

    .. code-block:: bash

        salt '*' keystone.user_role_list \
user_id=298ce377245c4ec9b70e1c639c89e654 \
tenant_id=7167a092ece84bae8cead4bf9d15bb3b
        salt '*' keystone.user_role_list user_name=admin tenant_name=admin
    '''
    kstone = auth(profile, **connection_args)
    ret = {}

    if project_id and not tenant_id:
        tenant_id = project_id
    elif project_name and not tenant_name:
        tenant_name = project_name

    if user_name:
        for user in kstone.users.list():
            if user.name == user_name:
                user_id = user.id
                break
    if tenant_name:
        for tenant in getattr(kstone, _TENANTS, None).list():
            if tenant.name == tenant_name:
                tenant_id = tenant.id
                break
    if not user_id or not tenant_id:
        return {'Error': 'Unable to resolve user or tenant/project id'}

    if _OS_IDENTITY_API_VERSION > 2:
        for role in kstone.roles.list(user=user_id, project=tenant_id):
            ret[role.name] = dict((value, getattr(role, value)) for value in dir(role)
                                  if not value.startswith('_') and
                                  isinstance(getattr(role, value), (six.string_types, dict, bool)))
    else:
        for role in kstone.roles.roles_for_user(user=user_id, tenant=tenant_id):
            ret[role.name] = {'id': role.id,
                              'name': role.name,
                              'user_id': user_id,
                              'tenant_id': tenant_id}
    return ret
def user_role_list ( user_id = None , tenant_id = None , user_name = None , tenant_name = None , profile = None , project_id = None , project_name = None , ** connection_args ) : kstone = auth ( profile , ** connection_args ) ret = { } if project_id and not tenant_id : tenant_id = project_id elif project_name and not tenant_name : tenant_name = project_name if user_name : for user in kstone . users . list ( ) : if user . name == user_name : user_id = user . id break if tenant_name : for tenant in getattr ( kstone , _TENANTS , None ) . list ( ) : if tenant . name == tenant_name : tenant_id = tenant . id break if not user_id or not tenant_id : return { 'Error' : 'Unable to resolve user or tenant/project id' } if _OS_IDENTITY_API_VERSION > 2 : for role in kstone . roles . list ( user = user_id , project = tenant_id ) : ret [ role . name ] = dict ( ( value , getattr ( role , value ) ) for value in dir ( role ) if not value . startswith ( '_' ) and isinstance ( getattr ( role , value ) , ( six . string_types , dict , bool ) ) ) else : for role in kstone . roles . roles_for_user ( user = user_id , tenant = tenant_id ) : ret [ role . name ] = { 'id' : role . id , 'name' : role . name , 'user_id' : user_id , 'tenant_id' : tenant_id } return ret
Return a list of available user_roles (keystone user-roles-list)

    CLI Examples:

    .. code-block:: bash

        salt '*' keystone.user_role_list \
user_id=298ce377245c4ec9b70e1c639c89e654 \
tenant_id=7167a092ece84bae8cead4bf9d15bb3b
        salt '*' keystone.user_role_list user_name=admin tenant_name=admin