def _set_compute_clients(self): 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 } params.update(self.default_params) self.agents_client = AgentsClient(self.auth_provider, **params) self.compute_networks_client = ComputeNetworksClient( self.auth_provider, **params) self.migrations_client = MigrationsClient(self.auth_provider, **params) self.security_group_default_rules_client = ( SecurityGroupDefaultRulesClient(self.auth_provider, **params)) self.certificates_client = CertificatesClient(self.auth_provider, **params) self.servers_client = ServersClient( self.auth_provider, enable_instance_password=CONF.compute_feature_enabled. enable_instance_password, **params) self.server_groups_client = ServerGroupsClient(self.auth_provider, **params) self.limits_client = LimitsClient(self.auth_provider, **params) self.images_client = ImagesClient(self.auth_provider, **params) self.keypairs_client = KeyPairsClient(self.auth_provider, **params) self.quotas_client = QuotasClient(self.auth_provider, **params) self.quota_classes_client = QuotaClassesClient(self.auth_provider, **params) self.flavors_client = FlavorsClient(self.auth_provider, **params) self.extensions_client = ExtensionsClient(self.auth_provider, **params) self.floating_ip_pools_client = FloatingIPPoolsClient( self.auth_provider, **params) self.floating_ips_bulk_client = FloatingIPsBulkClient( self.auth_provider, **params) self.floating_ips_client = FloatingIPsClient(self.auth_provider, **params) self.security_group_rules_client = SecurityGroupRulesClient( self.auth_provider, **params) self.security_groups_client = SecurityGroupsClient( self.auth_provider, **params) self.interfaces_client = InterfacesClient(self.auth_provider, **params) self.fixed_ips_client = FixedIPsClient(self.auth_provider, **params) self.availability_zone_client = AvailabilityZoneClient( self.auth_provider, **params) self.aggregates_client = AggregatesClient(self.auth_provider, **params) self.services_client = ServicesClient(self.auth_provider, **params) self.tenant_usages_client = TenantUsagesClient(self.auth_provider, **params) self.hosts_client = HostsClient(self.auth_provider, **params) self.hypervisor_client = HypervisorClient(self.auth_provider, **params) self.instance_usages_audit_log_client = \ InstanceUsagesAuditLogClient(self.auth_provider, **params) self.tenant_networks_client = \ TenantNetworksClient(self.auth_provider, **params) self.baremetal_nodes_client = BaremetalNodesClient( self.auth_provider, **params) # NOTE: The following client needs special timeout values because # the API is a proxy for the other component. params_volume = copy.deepcopy(params) params_volume.update({ 'build_interval': CONF.volume.build_interval, 'build_timeout': CONF.volume.build_timeout }) self.volumes_extensions_client = ComputeVolumesClient( self.auth_provider, **params_volume) self.compute_versions_client = VersionsClient(self.auth_provider, **params_volume) self.snapshots_extensions_client = ComputeSnapshotsClient( self.auth_provider, **params_volume)
def __init__(self, username=None, password=None, tenant_name=None, interface='json'): """ We allow overriding of the credentials used within the various client classes managed by the Manager object. Left as None, the standard username/password/tenant_name is used. :param username: Override of the username :param password: Override of the password :param tenant_name: Override of the tenant name """ self.config = config.TempestConfig() # If no creds are provided, we fall back on the defaults # in the config file for the Compute API. self.username = username or self.config.compute.username self.password = password or self.config.compute.password self.tenant_name = tenant_name or self.config.compute.tenant_name if None in (self.username, self.password, self.tenant_name): msg = ("Missing required credentials. " "username: %(username)s, password: %(password)s, " "tenant_name: %(tenant_name)s") % locals() raise exceptions.InvalidConfiguration(msg) self.auth_url = self.config.identity.auth_url if self.config.identity.strategy == 'keystone': client_args = (self.config, self.username, self.password, self.auth_url, self.tenant_name) else: client_args = (self.config, self.username, self.password, self.auth_url) try: self.servers_client = SERVERS_CLIENTS[interface](*client_args) self.limits_client = LIMITS_CLIENTS[interface](*client_args) self.images_client = IMAGES_CLIENTS[interface](*client_args) self.keypairs_client = KEYPAIRS_CLIENTS[interface](*client_args) self.flavors_client = FLAVORS_CLIENTS[interface](*client_args) ext_cli = EXTENSIONS_CLIENTS[interface](*client_args) self.extensions_client = ext_cli vol_ext_cli = VOLUMES_EXTENSIONS_CLIENTS[interface](*client_args) self.volumes_extensions_client = vol_ext_cli self.floating_ips_client = FLOAT_CLIENTS[interface](*client_args) self.volumes_client = VOLUMES_CLIENTS[interface](*client_args) self.admin_client = ADMIN_CLIENT[interface](*client_args) self.token_client = TOKEN_CLIENT[interface](self.config) self.security_groups_client = \ SECURITY_GROUPS_CLIENT[interface](*client_args) except KeyError: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) self.console_outputs_client = ConsoleOutputsClient(*client_args) self.quotas_client = QuotasClient(*client_args) self.network_client = NetworkClient(*client_args) self.account_client = AccountClient(*client_args) self.container_client = ContainerClient(*client_args) self.object_client = ObjectClient(*client_args) self.ec2api_client = APIClientEC2(*client_args) self.s3_client = ObjectClientS3(*client_args)