def setUp(self): super(TestFlavorsClient, self).setUp() fake_auth = fake_auth_provider.FakeAuthProvider() self.client = flavors_client.FlavorsClient(fake_auth, 'compute', 'regionOne')
def set_flavors_client(self): self.flavors_client = flavor_cli.FlavorsClient( self.auth_provider, **self.compute_params)
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 __init__(self, user, pw, tenant): default_params = { 'disable_ssl_certificate_validation': CONF.identity.disable_ssl_certificate_validation, 'ca_certs': CONF.identity.ca_certificates_file, 'trace_requests': CONF.debug.trace_requests } default_params_with_timeout_values = { 'build_interval': CONF.compute.build_interval, 'build_timeout': CONF.compute.build_timeout } default_params_with_timeout_values.update(default_params) compute_params = { 'service': CONF.compute.catalog_type, 'region': CONF.compute.region or CONF.identity.region, 'endpoint_type': CONF.compute.endpoint_type, 'build_interval': CONF.compute.build_interval, 'build_timeout': CONF.compute.build_timeout } compute_params.update(default_params) object_storage_params = { 'service': CONF.object_storage.catalog_type, 'region': CONF.object_storage.region or CONF.identity.region, 'endpoint_type': CONF.object_storage.endpoint_type } object_storage_params.update(default_params) _creds = auth.KeystoneV2Credentials(username=user, password=pw, tenant_name=tenant) auth_provider_params = { 'disable_ssl_certificate_validation': CONF.identity.disable_ssl_certificate_validation, 'ca_certs': CONF.identity.ca_certificates_file, 'trace_requests': CONF.debug.trace_requests } _auth = auth.KeystoneV2AuthProvider(_creds, CONF.identity.uri, **auth_provider_params) self.identity = identity_client.IdentityClient( _auth, CONF.identity.catalog_type, CONF.identity.region, endpoint_type='adminURL', **default_params_with_timeout_values) self.tenants = tenants_client.TenantsClient( _auth, CONF.identity.catalog_type, CONF.identity.region, endpoint_type='adminURL', **default_params_with_timeout_values) self.roles = roles_client.RolesClient( _auth, CONF.identity.catalog_type, CONF.identity.region, endpoint_type='adminURL', **default_params_with_timeout_values) self.users = users_client.UsersClient( _auth, CONF.identity.catalog_type, CONF.identity.region, endpoint_type='adminURL', **default_params_with_timeout_values) self.servers = servers_client.ServersClient(_auth, **compute_params) self.flavors = flavors_client.FlavorsClient(_auth, **compute_params) self.floating_ips = floating_ips_client.FloatingIPsClient( _auth, **compute_params) self.secgroups = security_groups_client.SecurityGroupsClient( _auth, **compute_params) self.secrules = security_group_rules_client.SecurityGroupRulesClient( _auth, **compute_params) self.objects = object_client.ObjectClient(_auth, **object_storage_params) self.containers = container_client.ContainerClient( _auth, **object_storage_params) self.images = images_client.ImagesClientV2( _auth, CONF.image.catalog_type, CONF.image.region or CONF.identity.region, endpoint_type=CONF.image.endpoint_type, build_interval=CONF.image.build_interval, build_timeout=CONF.image.build_timeout, **default_params) self.volumes = volumes_client.VolumesClient( _auth, CONF.volume.catalog_type, CONF.volume.region or CONF.identity.region, endpoint_type=CONF.volume.endpoint_type, build_interval=CONF.volume.build_interval, build_timeout=CONF.volume.build_timeout, **default_params) self.networks = networks_client.NetworksClient( _auth, CONF.network.catalog_type, CONF.network.region or CONF.identity.region, endpoint_type=CONF.network.endpoint_type, build_interval=CONF.network.build_interval, build_timeout=CONF.network.build_timeout, **default_params) self.ports = ports_client.PortsClient( _auth, CONF.network.catalog_type, CONF.network.region or CONF.identity.region, endpoint_type=CONF.network.endpoint_type, build_interval=CONF.network.build_interval, build_timeout=CONF.network.build_timeout, **default_params) self.routers = routers_client.RoutersClient( _auth, CONF.network.catalog_type, CONF.network.region or CONF.identity.region, endpoint_type=CONF.network.endpoint_type, build_interval=CONF.network.build_interval, build_timeout=CONF.network.build_timeout, **default_params) self.subnets = subnets_client.SubnetsClient( _auth, CONF.network.catalog_type, CONF.network.region or CONF.identity.region, endpoint_type=CONF.network.endpoint_type, build_interval=CONF.network.build_interval, build_timeout=CONF.network.build_timeout, **default_params)
def __init__(self, conf, creds): """Init method of ClientManager. :param conf: TempestConf object :param creds: Credentials object """ self.identity_region = creds.identity_region self.auth_provider = creds.get_auth_provider() default_params = self._get_default_params(conf) compute_params = self._get_compute_params(conf) compute_params.update(default_params) catalog_type = conf.get_defaulted('identity', 'catalog_type') self.identity = self.get_identity_client(creds.identity_version, catalog_type, default_params) self.projects = ProjectsClient( self.auth_provider, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, 'publicURL', creds.identity_version, **default_params) self.set_roles_client(auth=self.auth_provider, identity_version=creds.identity_version, catalog_type=catalog_type, endpoint_type='publicURL', default_params=default_params) self.hosts_client = hosts_client.HostsClient( self.auth_provider, conf.get_defaulted('compute', 'catalog_type'), self.identity_region, **default_params) self.accounts = account_client.AccountClient( self.auth_provider, conf.get_defaulted('object-storage', 'catalog_type'), self.identity_region, **default_params) self.set_users_client(auth=self.auth_provider, identity_version=creds.identity_version, catalog_type=catalog_type, endpoint_type='publicURL', default_params=default_params) self.images = images_client.ImagesClient( self.auth_provider, conf.get_defaulted('image', 'catalog_type'), self.identity_region, **default_params) self.servers = servers_client.ServersClient(self.auth_provider, **compute_params) self.flavors = flavors_client.FlavorsClient(self.auth_provider, **compute_params) self.service_client = s_client.ServicesClient( self.auth_provider, conf.get_defaulted('identity', 'catalog_type'), self.identity_region, **default_params) self.volume_client = services_client.ServicesClient( self.auth_provider, conf.get_defaulted('volume', 'catalog_type'), self.identity_region, **default_params) self.networks = None def create_neutron_client(): if self.networks is None: self.networks = networks_client.NetworksClient( self.auth_provider, conf.get_defaulted('network', 'catalog_type'), self.identity_region, endpoint_type=conf.get_defaulted('network', 'endpoint_type'), **default_params) return self.networks self.get_neutron_client = create_neutron_client # Set admin project id needed for keystone v3 tests. if creds.admin: project = self.projects.get_project_by_name(creds.project_name) conf.set('auth', 'admin_project_id', project['id'])