def _get_resource_owner_context(self, context): resource_owner_context = context.elevated() resource_owner_context.tenant_id = self.resource_owner_tenant_id user, pwd, _, auth_url = utils.get_keystone_creds() keystoneclient = keyclient.Client(username=user, password=pwd, auth_url=auth_url) resource_owner_context.auth_token = keystoneclient.get_token( self.resource_owner_tenant_id) return resource_owner_context
def _resource_owner_tenant_id(): user, pwd, tenant, auth_url = utils.get_keystone_creds() keystoneclient = keyclient.Client(username=user, password=pwd, auth_url=auth_url) try: tenant = keystoneclient.tenants.find(name=tenant) return tenant.id except k_exceptions.NotFound: with excutils.save_and_reraise_exception(reraise=True): LOG.error(_LE('No tenant with name %s exists.'), tenant) except k_exceptions.NoUniqueMatch: with excutils.save_and_reraise_exception(reraise=True): LOG.error(_LE('Multiple tenants matches found for %s'), tenant)
def _get_resource_owner_tenant_id(self): user, pwd, tenant, auth_url = utils.get_keystone_creds() keystoneclient = keyclient.Client(username=user, password=pwd, auth_url=auth_url) try: tenant = keystoneclient.tenants.find(name=tenant) return tenant.id except k_exceptions.NotFound: with excutils.save_and_reraise_exception(reraise=True): LOG.error('No tenant with name %s exists.', tenant) except k_exceptions.NoUniqueMatch: with excutils.save_and_reraise_exception(reraise=True): LOG.error('Multiple tenants matches found for %s', tenant)
def chain_tenant_keystone_client(): chain_user = cfg.CONF.chain_mapping.chain_owner_user user, pwd, tenant, auth_url = utils.get_keystone_creds() user = (chain_user or user) pwd = (cfg.CONF.chain_mapping.chain_owner_password or (pwd if not chain_user else '')) # Tenant must be configured in the resource_mapping section, provider # owner will be used otherwise. tenant = cfg.CONF.chain_mapping.chain_owner_tenant_name if tenant: return k_client.Client(username=user, password=pwd, auth_url=auth_url)