def _set_identity_clients(self): params = { 'service': CONF.identity.catalog_type, 'region': CONF.identity.region } params.update(self.default_params_with_timeout_values) params_v2_admin = params.copy() params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type # Client uses admin endpoint type of Keystone API v2 self.tenants_client = tenants_client.TenantsClient( self.auth_provider, **params_v2_admin)
def __init__(self, conf, admin): self.identity_version = self.get_identity_version(conf) if admin: username = conf.get_defaulted('identity', 'admin_username') password = conf.get_defaulted('identity', 'admin_password') tenant_name = conf.get_defaulted('identity', 'admin_tenant_name') else: username = conf.get_defaulted('identity', 'username') password = conf.get_defaulted('identity', 'password') tenant_name = conf.get_defaulted('identity', 'tenant_name') self.identity_region = conf.get_defaulted('identity', 'region') default_params = { 'disable_ssl_certificate_validation': conf.get_defaulted('identity', 'disable_ssl_certificate_validation'), 'ca_certs': conf.get_defaulted('identity', 'ca_certificates_file') } compute_params = { 'service': conf.get_defaulted('compute', 'catalog_type'), 'region': self.identity_region, 'endpoint_type': conf.get_defaulted('compute', 'endpoint_type') } compute_params.update(default_params) if self.identity_version == "v2": _creds = self.get_credentials(conf, username, tenant_name, password) else: _creds = self.get_credentials( conf, username, tenant_name, password, identity_version=self.identity_version) _auth = self.get_auth_provider(conf, _creds) self.auth_provider = _auth if "v2.0" in conf.get("identity", "uri"): self.identity = identity_client.IdentityClient( _auth, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, endpoint_type='adminURL', **default_params) else: self.identity = identity_v3_client.IdentityV3Client( _auth, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, endpoint_type='adminURL', **default_params) self.tenants = tenants_client.TenantsClient( _auth, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, endpoint_type='adminURL', **default_params) self.roles = roles_client.RolesClient( _auth, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, endpoint_type='adminURL', **default_params) self.users = users_client.UsersClient( _auth, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, endpoint_type='adminURL', **default_params) self.images = images_client.ImagesClient( _auth, conf.get_defaulted('image', 'catalog_type'), self.identity_region, **default_params) self.servers = servers_client.ServersClient(_auth, **compute_params) self.flavors = flavors_client.FlavorsClient(_auth, **compute_params) self.networks = None def create_nova_network_client(): if self.networks is None: self.networks = nova_net_client.NetworksClient( _auth, **compute_params) return self.networks def create_neutron_client(): if self.networks is None: self.networks = networks_client.NetworksClient( _auth, conf.get_defaulted('network', 'catalog_type'), self.identity_region, endpoint_type=conf.get_defaulted('network', 'endpoint_type'), **default_params) return self.networks self.get_nova_net_client = create_nova_network_client self.get_neutron_client = create_neutron_client # Set admin tenant id needed for keystone v3 tests. if admin: tenant_id = identity.get_tenant_by_name(self.tenants, tenant_name)['id'] conf.set('identity', 'admin_tenant_id', tenant_id)
def setUp(self): super(TestTenantsClient, self).setUp() fake_auth = fake_auth_provider.FakeAuthProvider() self.client = tenants_client.TenantsClient(fake_auth, 'identity', 'regionOne')