'Get the domain_id for a v3 list call.
If we running with multiple domain drivers, then the caller must
specify a domain_id either as a filter or as part of the token scope.'

def _get_domain_id_for_list_request(self, request):

    if (not CONF.identity.domain_specific_drivers_enabled):
        return
    domain_id = request.params.get('domain_id')
    if domain_id:
        return domain_id
    token_ref = authorization.get_token_ref(request.context_dict)
    if token_ref.domain_scoped:
        return token_ref.domain_id
    elif token_ref.project_scoped:
        return token_ref.project_domain_id
    else:
        msg = _('No    domain    information    specified    as    part    of    list    request')
        LOG.warning(msg)
        raise exception.Unauthorized(msg)
