def __init__(self, credentials=None, interface='json', service=None): # Set interface and client type first self.interface = interface # super cares for credentials validation super(Manager, self).__init__(credentials=credentials) self._set_compute_clients() self._set_identity_clients() self._set_volume_clients() self.baremetal_client = BaremetalClientJSON(self.auth_provider) self.network_client = NetworkClientJSON( self.auth_provider, 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, **self.default_params) self.database_flavors_client = DatabaseFlavorsClientJSON( self.auth_provider, CONF.database.catalog_type, CONF.identity.region, **self.default_params_with_timeout_values) self.database_versions_client = DatabaseVersionsClientJSON( self.auth_provider, CONF.database.catalog_type, CONF.identity.region, **self.default_params_with_timeout_values) self.messaging_client = MessagingClientJSON(self.auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientJSON(self.auth_provider) self.negative_client = negative_rest_client.NegativeRestClient( self.auth_provider, service) # TODO(andreaf) EC2 client still do their auth, v2 only ec2_client_args = (self.credentials.username, self.credentials.password, CONF.identity.uri, self.credentials.tenant_name) # common clients self.account_client = AccountClient(self.auth_provider) if CONF.service_available.glance: self.image_client = ImageClientJSON(self.auth_provider) self.image_client_v2 = ImageClientV2JSON(self.auth_provider) self.container_client = ContainerClient(self.auth_provider) self.object_client = ObjectClient(self.auth_provider) self.orchestration_client = OrchestrationClient( self.auth_provider, CONF.orchestration.catalog_type, CONF.orchestration.region or CONF.identity.region, endpoint_type=CONF.orchestration.endpoint_type, build_interval=CONF.orchestration.build_interval, build_timeout=CONF.orchestration.build_timeout, **self.default_params) self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args) self.s3_client = botoclients.ObjectClientS3(*ec2_client_args) self.data_processing_client = DataProcessingClient(self.auth_provider)
def _set_object_storage_clients(self): params = { 'service': CONF.object_storage.catalog_type, 'region': CONF.object_storage.region or CONF.identity.region, 'endpoint_type': CONF.object_storage.endpoint_type } params.update(self.default_params_with_timeout_values) self.account_client = AccountClient(self.auth_provider, **params) self.container_client = ContainerClient(self.auth_provider, **params) self.object_client = ObjectClient(self.auth_provider, **params)
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.identity.username self.password = password or self.config.identity.password self.tenant_name = tenant_name or self.config.identity.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.uri self.auth_url_v3 = self.config.identity.uri_v3 if self.config.identity.strategy == 'keystone': client_args = (self.config, self.username, self.password, self.auth_url, self.tenant_name) if self.auth_url_v3: auth_version = 'v3' client_args_v3_auth = (self.config, self.username, self.password, self.auth_url_v3, self.tenant_name, auth_version) else: client_args_v3_auth = None else: client_args = (self.config, self.username, self.password, self.auth_url) client_args_v3_auth = None 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.quotas_client = QUOTAS_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.snapshots_client = SNAPSHOTS_CLIENTS[interface](*client_args) self.volumes_client = VOLUMES_CLIENTS[interface](*client_args) self.volume_types_client = \ VOLUME_TYPES_CLIENTS[interface](*client_args) self.identity_client = IDENTITY_CLIENT[interface](*client_args) self.identity_v3_client = \ IDENTITY_V3_CLIENT[interface](*client_args) self.token_client = TOKEN_CLIENT[interface](self.config) self.security_groups_client = \ SECURITY_GROUPS_CLIENT[interface](*client_args) self.interfaces_client = INTERFACES_CLIENT[interface](*client_args) self.endpoints_client = ENDPOINT_CLIENT[interface](*client_args) self.fixed_ips_client = FIXED_IPS_CLIENT[interface](*client_args) self.availability_zone_client = \ AVAILABILITY_ZONE_CLIENT[interface](*client_args) self.service_client = SERVICE_CLIENT[interface](*client_args) self.aggregates_client = AGGREGATES_CLIENT[interface](*client_args) self.services_client = SERVICES_CLIENT[interface](*client_args) self.tenant_usages_client = \ TENANT_USAGES_CLIENT[interface](*client_args) self.policy_client = POLICY_CLIENT[interface](*client_args) if client_args_v3_auth: self.servers_client_v3_auth = SERVERS_CLIENTS[interface]( *client_args_v3_auth) else: self.servers_client_v3_auth = None except KeyError: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) self.network_client = NetworkClient(*client_args) self.hosts_client = HostsClientJSON(*client_args) self.account_client = AccountClient(*client_args) self.image_client = ImageClientJSON(*client_args) self.image_client_v2 = ImageClientV2JSON(*client_args) self.container_client = ContainerClient(*client_args) self.object_client = ObjectClient(*client_args) self.orchestration_client = OrchestrationClient(*client_args) self.ec2api_client = botoclients.APIClientEC2(*client_args) self.s3_client = botoclients.ObjectClientS3(*client_args) self.custom_object_client = ObjectClientCustomizedHeader(*client_args) self.custom_account_client = \ AccountClientCustomizedHeader(*client_args)
def __init__(self, credentials=None, interface='json', service=None): # Set interface and client type first self.interface = interface self.client_type = 'tempest' # super cares for credentials validation super(Manager, self).__init__(credentials=credentials) if self.interface == 'xml': self.certificates_client = CertificatesClientXML( self.auth_provider) self.servers_client = ServersClientXML(self.auth_provider) self.limits_client = LimitsClientXML(self.auth_provider) self.images_client = ImagesClientXML(self.auth_provider) self.keypairs_client = KeyPairsClientXML(self.auth_provider) self.quotas_client = QuotasClientXML(self.auth_provider) self.quota_classes_client = QuotaClassesClientXML( self.auth_provider) self.flavors_client = FlavorsClientXML(self.auth_provider) self.extensions_client = ExtensionsClientXML(self.auth_provider) self.volumes_extensions_client = VolumesExtensionsClientXML( self.auth_provider) self.floating_ips_client = FloatingIPsClientXML(self.auth_provider) self.backups_client = BackupsClientXML(self.auth_provider) self.snapshots_client = SnapshotsClientXML(self.auth_provider) self.volumes_client = VolumesClientXML(self.auth_provider) self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider) self.volume_types_client = VolumeTypesClientXML(self.auth_provider) self.identity_client = IdentityClientXML(self.auth_provider) self.identity_v3_client = IdentityV3ClientXML(self.auth_provider) self.security_groups_client = SecurityGroupsClientXML( self.auth_provider) self.interfaces_client = InterfacesClientXML(self.auth_provider) self.endpoints_client = EndPointClientXML(self.auth_provider) self.fixed_ips_client = FixedIPsClientXML(self.auth_provider) self.availability_zone_client = AvailabilityZoneClientXML( self.auth_provider) self.service_client = ServiceClientXML(self.auth_provider) self.volume_services_client = VolumesServicesClientXML( self.auth_provider) self.aggregates_client = AggregatesClientXML(self.auth_provider) self.services_client = ServicesClientXML(self.auth_provider) self.tenant_usages_client = TenantUsagesClientXML( self.auth_provider) self.policy_client = PolicyClientXML(self.auth_provider) self.region_client = RegionClientXML(self.auth_provider) self.hosts_client = HostsClientXML(self.auth_provider) self.hypervisor_client = HypervisorClientXML(self.auth_provider) self.network_client = NetworkClientXML(self.auth_provider) self.credentials_client = CredentialsClientXML(self.auth_provider) self.instance_usages_audit_log_client = \ InstanceUsagesAuditLogClientXML(self.auth_provider) self.volume_hosts_client = VolumeHostsClientXML(self.auth_provider) self.volume_quotas_client = VolumeQuotasClientXML( self.auth_provider) self.volumes_extension_client = VolumeExtensionClientXML( self.auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientXML(self.auth_provider) self.token_client = TokenClientXML() self.token_v3_client = V3TokenClientXML() self.volume_availability_zone_client = \ VolumeAvailabilityZoneClientXML(self.auth_provider) elif self.interface == 'json': self.certificates_client = CertificatesClientJSON( self.auth_provider) self.certificates_v3_client = CertificatesV3ClientJSON( self.auth_provider) self.baremetal_client = BaremetalClientJSON(self.auth_provider) self.servers_client = ServersClientJSON(self.auth_provider) self.servers_v3_client = ServersV3ClientJSON(self.auth_provider) self.limits_client = LimitsClientJSON(self.auth_provider) self.images_client = ImagesClientJSON(self.auth_provider) self.keypairs_v3_client = KeyPairsV3ClientJSON(self.auth_provider) self.keypairs_client = KeyPairsClientJSON(self.auth_provider) self.keypairs_v3_client = KeyPairsV3ClientJSON(self.auth_provider) self.quotas_client = QuotasClientJSON(self.auth_provider) self.quota_classes_client = QuotaClassesClientJSON( self.auth_provider) self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider) self.flavors_client = FlavorsClientJSON(self.auth_provider) self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider) self.extensions_v3_client = ExtensionsV3ClientJSON( self.auth_provider) self.extensions_client = ExtensionsClientJSON(self.auth_provider) self.volumes_extensions_client = VolumesExtensionsClientJSON( self.auth_provider) self.floating_ips_client = FloatingIPsClientJSON( self.auth_provider) self.backups_client = BackupsClientJSON(self.auth_provider) self.snapshots_client = SnapshotsClientJSON(self.auth_provider) self.volumes_client = VolumesClientJSON(self.auth_provider) self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider) self.volume_types_client = VolumeTypesClientJSON( self.auth_provider) self.identity_client = IdentityClientJSON(self.auth_provider) self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider) self.security_groups_client = SecurityGroupsClientJSON( self.auth_provider) self.interfaces_v3_client = InterfacesV3ClientJSON( self.auth_provider) self.interfaces_client = InterfacesClientJSON(self.auth_provider) self.endpoints_client = EndPointClientJSON(self.auth_provider) self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider) self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON( self.auth_provider) self.availability_zone_client = AvailabilityZoneClientJSON( self.auth_provider) self.services_v3_client = ServicesV3ClientJSON(self.auth_provider) self.service_client = ServiceClientJSON(self.auth_provider) self.volume_services_client = VolumesServicesClientJSON( self.auth_provider) self.agents_v3_client = AgentsV3ClientJSON(self.auth_provider) self.aggregates_v3_client = AggregatesV3ClientJSON( self.auth_provider) self.aggregates_client = AggregatesClientJSON(self.auth_provider) self.services_client = ServicesClientJSON(self.auth_provider) self.tenant_usages_client = TenantUsagesClientJSON( self.auth_provider) self.version_v3_client = VersionV3ClientJSON(self.auth_provider) self.migrations_v3_client = MigrationsV3ClientJSON( self.auth_provider) self.policy_client = PolicyClientJSON(self.auth_provider) self.region_client = RegionClientJSON(self.auth_provider) self.hosts_client = HostsClientJSON(self.auth_provider) self.hypervisor_v3_client = HypervisorV3ClientJSON( self.auth_provider) self.hypervisor_client = HypervisorClientJSON(self.auth_provider) self.network_client = NetworkClientJSON(self.auth_provider) self.credentials_client = CredentialsClientJSON(self.auth_provider) self.instance_usages_audit_log_client = \ InstanceUsagesAuditLogClientJSON(self.auth_provider) self.volume_hosts_client = VolumeHostsClientJSON( self.auth_provider) self.volume_quotas_client = VolumeQuotasClientJSON( self.auth_provider) self.volumes_extension_client = VolumeExtensionClientJSON( self.auth_provider) self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider) self.database_flavors_client = DatabaseFlavorsClientJSON( self.auth_provider) self.database_versions_client = DatabaseVersionsClientJSON( self.auth_provider) self.queuing_client = QueuingClientJSON(self.auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientJSON(self.auth_provider) self.token_client = TokenClientJSON() self.token_v3_client = V3TokenClientJSON() self.negative_client = rest_client.NegativeRestClient( self.auth_provider) self.negative_client.service = service self.volume_availability_zone_client = \ VolumeAvailabilityZoneClientJSON(self.auth_provider) else: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) # TODO(andreaf) EC2 client still do their auth, v2 only ec2_client_args = (self.credentials.username, self.credentials.password, CONF.identity.uri, self.credentials.tenant_name) # common clients self.account_client = AccountClient(self.auth_provider) self.agents_client = AgentsClientJSON(self.auth_provider) if CONF.service_available.glance: self.image_client = ImageClientJSON(self.auth_provider) self.image_client_v2 = ImageClientV2JSON(self.auth_provider) self.container_client = ContainerClient(self.auth_provider) self.object_client = ObjectClient(self.auth_provider) self.orchestration_client = OrchestrationClient(self.auth_provider) self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args) self.s3_client = botoclients.ObjectClientS3(*ec2_client_args) self.custom_object_client = ObjectClientCustomizedHeader( self.auth_provider) self.custom_account_client = \ AccountClientCustomizedHeader(self.auth_provider) self.data_processing_client = DataProcessingClient(self.auth_provider) self.migrations_client = MigrationsClientJSON(self.auth_provider)
def set_object_client(self): self.object_client = ObjectClient(self.auth_provider, **self.object_storage_params)
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)
def __init__(self, username=None, password=None, tenant_name=None, interface='json', service=None): """ 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.interface = interface self.auth_version = CONF.identity.auth_version # FIXME(andreaf) Change Manager __init__ to accept a credentials dict if username is None or password is None: # Tenant None is a valid use case self.credentials = self.get_default_credentials() else: self.credentials = dict(username=username, password=password, tenant_name=tenant_name) if self.auth_version == 'v3': self.credentials['domain_name'] = 'Default' # Setup an auth provider auth_provider = self.get_auth_provider(self.credentials) if self.interface == 'xml': self.certificates_client = CertificatesClientXML(auth_provider) self.servers_client = ServersClientXML(auth_provider) self.limits_client = LimitsClientXML(auth_provider) self.images_client = ImagesClientXML(auth_provider) self.keypairs_client = KeyPairsClientXML(auth_provider) self.quotas_client = QuotasClientXML(auth_provider) self.flavors_client = FlavorsClientXML(auth_provider) self.extensions_client = ExtensionsClientXML(auth_provider) self.volumes_extensions_client = VolumesExtensionsClientXML( auth_provider) self.floating_ips_client = FloatingIPsClientXML(auth_provider) self.snapshots_client = SnapshotsClientXML(auth_provider) self.volumes_client = VolumesClientXML(auth_provider) self.volume_types_client = VolumeTypesClientXML(auth_provider) self.identity_client = IdentityClientXML(auth_provider) self.identity_v3_client = IdentityV3ClientXML(auth_provider) self.security_groups_client = SecurityGroupsClientXML( auth_provider) self.interfaces_client = InterfacesClientXML(auth_provider) self.endpoints_client = EndPointClientXML(auth_provider) self.fixed_ips_client = FixedIPsClientXML(auth_provider) self.availability_zone_client = AvailabilityZoneClientXML( auth_provider) self.service_client = ServiceClientXML(auth_provider) self.aggregates_client = AggregatesClientXML(auth_provider) self.services_client = ServicesClientXML(auth_provider) self.tenant_usages_client = TenantUsagesClientXML(auth_provider) self.policy_client = PolicyClientXML(auth_provider) self.hosts_client = HostsClientXML(auth_provider) self.hypervisor_client = HypervisorClientXML(auth_provider) self.network_client = NetworkClientXML(auth_provider) self.credentials_client = CredentialsClientXML(auth_provider) self.instance_usages_audit_log_client = \ InstanceUsagesAuditLogClientXML(auth_provider) self.volume_hosts_client = VolumeHostsClientXML(auth_provider) self.volumes_extension_client = VolumeExtensionClientXML( auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientXML(auth_provider) self.token_client = TokenClientXML() self.token_v3_client = V3TokenClientXML() elif self.interface == 'json': self.certificates_client = CertificatesClientJSON(auth_provider) self.certificates_v3_client = CertificatesV3ClientJSON( auth_provider) self.baremetal_client = BaremetalClientJSON(auth_provider) self.servers_client = ServersClientJSON(auth_provider) self.servers_v3_client = ServersV3ClientJSON(auth_provider) self.limits_client = LimitsClientJSON(auth_provider) self.images_client = ImagesClientJSON(auth_provider) self.keypairs_v3_client = KeyPairsV3ClientJSON(auth_provider) self.keypairs_client = KeyPairsClientJSON(auth_provider) self.keypairs_v3_client = KeyPairsV3ClientJSON(auth_provider) self.quotas_client = QuotasClientJSON(auth_provider) self.quotas_v3_client = QuotasV3ClientJSON(auth_provider) self.flavors_client = FlavorsClientJSON(auth_provider) self.flavors_v3_client = FlavorsV3ClientJSON(auth_provider) self.extensions_v3_client = ExtensionsV3ClientJSON(auth_provider) self.extensions_client = ExtensionsClientJSON(auth_provider) self.volumes_extensions_client = VolumesExtensionsClientJSON( auth_provider) self.floating_ips_client = FloatingIPsClientJSON(auth_provider) self.snapshots_client = SnapshotsClientJSON(auth_provider) self.volumes_client = VolumesClientJSON(auth_provider) self.volume_types_client = VolumeTypesClientJSON(auth_provider) self.identity_client = IdentityClientJSON(auth_provider) self.identity_v3_client = IdentityV3ClientJSON(auth_provider) self.security_groups_client = SecurityGroupsClientJSON( auth_provider) self.interfaces_v3_client = InterfacesV3ClientJSON(auth_provider) self.interfaces_client = InterfacesClientJSON(auth_provider) self.endpoints_client = EndPointClientJSON(auth_provider) self.fixed_ips_client = FixedIPsClientJSON(auth_provider) self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON( auth_provider) self.availability_zone_client = AvailabilityZoneClientJSON( auth_provider) self.services_v3_client = ServicesV3ClientJSON(auth_provider) self.service_client = ServiceClientJSON(auth_provider) self.aggregates_v3_client = AggregatesV3ClientJSON(auth_provider) self.aggregates_client = AggregatesClientJSON(auth_provider) self.services_client = ServicesClientJSON(auth_provider) self.tenant_usages_v3_client = TenantUsagesV3ClientJSON( auth_provider) self.tenant_usages_client = TenantUsagesClientJSON(auth_provider) self.version_v3_client = VersionV3ClientJSON(auth_provider) self.policy_client = PolicyClientJSON(auth_provider) self.hosts_client = HostsClientJSON(auth_provider) self.hypervisor_v3_client = HypervisorV3ClientJSON(auth_provider) self.hypervisor_client = HypervisorClientJSON(auth_provider) self.network_client = NetworkClientJSON(auth_provider) self.credentials_client = CredentialsClientJSON(auth_provider) self.instance_usages_audit_log_client = \ InstanceUsagesAuditLogClientJSON(auth_provider) self.instance_usages_audit_log_v3_client = \ InstanceUsagesAuditLogV3ClientJSON(auth_provider) self.volume_hosts_client = VolumeHostsClientJSON(auth_provider) self.volumes_extension_client = VolumeExtensionClientJSON( auth_provider) self.hosts_v3_client = HostsV3ClientJSON(auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientJSON(auth_provider) self.token_client = TokenClientJSON() self.token_v3_client = V3TokenClientJSON() self.negative_client = NegativeRestClient(auth_provider) self.negative_client.service = service else: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) # TODO(andreaf) EC2 client still do their auth, v2 only ec2_client_args = (self.credentials.get('username'), self.credentials.get('password'), CONF.identity.uri, self.credentials.get('tenant_name')) # common clients self.account_client = AccountClient(auth_provider) if CONF.service_available.glance: self.image_client = ImageClientJSON(auth_provider) self.image_client_v2 = ImageClientV2JSON(auth_provider) self.container_client = ContainerClient(auth_provider) self.object_client = ObjectClient(auth_provider) self.orchestration_client = OrchestrationClient(auth_provider) self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args) self.s3_client = botoclients.ObjectClientS3(*ec2_client_args) self.custom_object_client = ObjectClientCustomizedHeader(auth_provider) self.custom_account_client = \ AccountClientCustomizedHeader(auth_provider) self.data_processing_client = DataProcessingClient(auth_provider)
def __init__(self, credentials=None, interface='json', service=None): # Set interface and client type first self.interface = interface # super cares for credentials validation super(Manager, self).__init__(credentials=credentials) self._set_compute_clients(self.interface) if self.interface == 'xml': self.backups_client = BackupsClientXML(self.auth_provider) self.snapshots_client = SnapshotsClientXML(self.auth_provider) self.snapshots_v2_client = SnapshotsV2ClientXML(self.auth_provider) self.volumes_client = VolumesClientXML(self.auth_provider) self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider) self.volume_types_client = VolumeTypesClientXML(self.auth_provider) self.identity_client = IdentityClientXML(self.auth_provider) self.identity_v3_client = IdentityV3ClientXML(self.auth_provider) self.endpoints_client = EndPointClientXML(self.auth_provider) self.service_client = ServiceClientXML(self.auth_provider) self.volume_services_client = VolumesServicesClientXML( self.auth_provider) self.policy_client = PolicyClientXML(self.auth_provider) self.region_client = RegionClientXML(self.auth_provider) self.network_client = NetworkClientXML(self.auth_provider) self.credentials_client = CredentialsClientXML(self.auth_provider) self.volume_hosts_client = VolumeHostsClientXML(self.auth_provider) self.volume_quotas_client = VolumeQuotasClientXML( self.auth_provider) self.volumes_extension_client = VolumeExtensionClientXML( self.auth_provider) self.volumes_v2_extension_client = VolumeV2ExtensionClientXML( self.auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientXML(self.auth_provider) self.token_client = TokenClientXML() if CONF.identity_feature_enabled.api_v3: self.token_v3_client = V3TokenClientXML() self.volume_availability_zone_client = \ VolumeAvailabilityZoneClientXML(self.auth_provider) self.volume_v2_availability_zone_client = \ VolumeV2AvailabilityZoneClientXML(self.auth_provider) elif self.interface == 'json': self.baremetal_client = BaremetalClientJSON(self.auth_provider) self.backups_client = BackupsClientJSON(self.auth_provider) self.snapshots_client = SnapshotsClientJSON(self.auth_provider) self.snapshots_v2_client = SnapshotsV2ClientJSON( self.auth_provider) self.volumes_client = VolumesClientJSON(self.auth_provider) self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider) self.volume_types_client = VolumeTypesClientJSON( self.auth_provider) self.volume_types_v2_client = VolumeTypesV2ClientJSON( self.auth_provider) self.identity_client = IdentityClientJSON(self.auth_provider) self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider) self.endpoints_client = EndPointClientJSON(self.auth_provider) self.service_client = ServiceClientJSON(self.auth_provider) self.volume_services_client = VolumesServicesClientJSON( self.auth_provider) self.policy_client = PolicyClientJSON(self.auth_provider) self.region_client = RegionClientJSON(self.auth_provider) self.network_client = NetworkClientJSON(self.auth_provider) self.credentials_client = CredentialsClientJSON(self.auth_provider) self.volume_hosts_client = VolumeHostsClientJSON( self.auth_provider) self.volume_quotas_client = VolumeQuotasClientJSON( self.auth_provider) self.volumes_extension_client = VolumeExtensionClientJSON( self.auth_provider) self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON( self.auth_provider) self.database_flavors_client = DatabaseFlavorsClientJSON( self.auth_provider) self.database_versions_client = DatabaseVersionsClientJSON( self.auth_provider) self.messaging_client = MessagingClientJSON(self.auth_provider) if CONF.service_available.ceilometer: self.telemetry_client = TelemetryClientJSON(self.auth_provider) self.token_client = TokenClientJSON() if CONF.identity_feature_enabled.api_v3: self.token_v3_client = V3TokenClientJSON() self.negative_client = rest_client.NegativeRestClient( self.auth_provider) self.negative_client.service = service self.volume_availability_zone_client = \ VolumeAvailabilityZoneClientJSON(self.auth_provider) self.volume_v2_availability_zone_client = \ VolumeV2AvailabilityZoneClientJSON(self.auth_provider) else: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) # TODO(andreaf) EC2 client still do their auth, v2 only ec2_client_args = (self.credentials.username, self.credentials.password, CONF.identity.uri, self.credentials.tenant_name) # common clients self.account_client = AccountClient(self.auth_provider) self.agents_client = AgentsClientJSON(self.auth_provider) if CONF.service_available.glance: self.image_client = ImageClientJSON(self.auth_provider) self.image_client_v2 = ImageClientV2JSON(self.auth_provider) self.container_client = ContainerClient(self.auth_provider) self.object_client = ObjectClient(self.auth_provider) self.orchestration_client = OrchestrationClient(self.auth_provider) self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args) self.s3_client = botoclients.ObjectClientS3(*ec2_client_args) self.custom_object_client = ObjectClientCustomizedHeader( self.auth_provider) self.custom_account_client = \ AccountClientCustomizedHeader(self.auth_provider) self.data_processing_client = DataProcessingClient(self.auth_provider) self.migrations_client = MigrationsClientJSON(self.auth_provider) self.security_group_default_rules_client = ( SecurityGroupDefaultRulesClientJSON(self.auth_provider)) self.networks_client = NetworksClientJSON(self.auth_provider) # NOTE : As XML clients are not implemented for Qos-specs. # So, setting the qos_client here. Once client are implemented, # qos_client would be moved to its respective if/else. # Bug : 1312553 self.volume_qos_client = QosSpecsClientJSON(self.auth_provider) self.volume_qos_v2_client = QosSpecsV2ClientJSON(self.auth_provider)
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.identity.username self.password = password or self.config.identity.password self.tenant_name = tenant_name or self.config.identity.tenant_name if None in (self.username, self.password, self.tenant_name): msg = ("Missing required credentials. " "username: %(u)s, password: %(p)s, " "tenant_name: %(t)s" % { 'u': username, 'p': password, 't': tenant_name }) raise exceptions.InvalidConfiguration(msg) self.auth_url = self.config.identity.uri self.auth_url_v3 = self.config.identity.uri_v3 client_args = (self.config, self.username, self.password, self.auth_url, self.tenant_name) if self.auth_url_v3: auth_version = 'v3' client_args_v3_auth = (self.config, self.username, self.password, self.auth_url_v3, self.tenant_name, auth_version) else: client_args_v3_auth = None self.servers_client_v3_auth = None if interface == 'xml': self.servers_client = ServersClientXML(*client_args) self.limits_client = LimitsClientXML(*client_args) self.images_client = ImagesClientXML(*client_args) self.keypairs_client = KeyPairsClientXML(*client_args) self.quotas_client = QuotasClientXML(*client_args) self.flavors_client = FlavorsClientXML(*client_args) self.extensions_client = ExtensionsClientXML(*client_args) self.volumes_extensions_client = VolumesExtensionsClientXML( *client_args) self.floating_ips_client = FloatingIPsClientXML(*client_args) self.snapshots_client = SnapshotsClientXML(*client_args) self.volumes_client = VolumesClientXML(*client_args) self.volume_types_client = VolumeTypesClientXML(*client_args) self.identity_client = IdentityClientXML(*client_args) self.identity_v3_client = IdentityV3ClientXML(*client_args) self.token_client = TokenClientXML(self.config) self.security_groups_client = SecurityGroupsClientXML(*client_args) self.interfaces_client = InterfacesClientXML(*client_args) self.endpoints_client = EndPointClientXML(*client_args) self.fixed_ips_client = FixedIPsClientXML(*client_args) self.availability_zone_client = AvailabilityZoneClientXML( *client_args) self.service_client = ServiceClientXML(*client_args) self.aggregates_client = AggregatesClientXML(*client_args) self.services_client = ServicesClientXML(*client_args) self.tenant_usages_client = TenantUsagesClientXML(*client_args) self.policy_client = PolicyClientXML(*client_args) self.hypervisor_client = HypervisorClientXML(*client_args) self.token_v3_client = V3TokenClientXML(*client_args) self.network_client = NetworkClientXML(*client_args) self.credentials_client = CredentialsClientXML(*client_args) if client_args_v3_auth: self.servers_client_v3_auth = ServersClientXML( *client_args_v3_auth) elif interface == 'json': self.servers_client = ServersClientJSON(*client_args) self.limits_client = LimitsClientJSON(*client_args) self.images_client = ImagesClientJSON(*client_args) self.keypairs_client = KeyPairsClientJSON(*client_args) self.quotas_client = QuotasClientJSON(*client_args) self.flavors_client = FlavorsClientJSON(*client_args) self.extensions_client = ExtensionsClientJSON(*client_args) self.volumes_extensions_client = VolumesExtensionsClientJSON( *client_args) self.floating_ips_client = FloatingIPsClientJSON(*client_args) self.snapshots_client = SnapshotsClientJSON(*client_args) self.volumes_client = VolumesClientJSON(*client_args) self.volume_types_client = VolumeTypesClientJSON(*client_args) self.identity_client = IdentityClientJSON(*client_args) self.identity_v3_client = IdentityV3ClientJSON(*client_args) self.token_client = TokenClientJSON(self.config) self.security_groups_client = SecurityGroupsClientJSON( *client_args) self.interfaces_client = InterfacesClientJSON(*client_args) self.endpoints_client = EndPointClientJSON(*client_args) self.fixed_ips_client = FixedIPsClientJSON(*client_args) self.availability_zone_client = AvailabilityZoneClientJSON( *client_args) self.service_client = ServiceClientJSON(*client_args) self.aggregates_client = AggregatesClientJSON(*client_args) self.services_client = ServicesClientJSON(*client_args) self.tenant_usages_client = TenantUsagesClientJSON(*client_args) self.policy_client = PolicyClientJSON(*client_args) self.hypervisor_client = HypervisorClientJSON(*client_args) self.token_v3_client = V3TokenClientJSON(*client_args) self.network_client = NetworkClientJSON(*client_args) self.credentials_client = CredentialsClientJSON(*client_args) if client_args_v3_auth: self.servers_client_v3_auth = ServersClientJSON( *client_args_v3_auth) else: msg = "Unsupported interface type `%s'" % interface raise exceptions.InvalidConfiguration(msg) # common clients self.hosts_client = HostsClientJSON(*client_args) self.account_client = AccountClient(*client_args) if self.config.service_available.glance: self.image_client = ImageClientJSON(*client_args) self.image_client_v2 = ImageClientV2JSON(*client_args) self.container_client = ContainerClient(*client_args) self.object_client = ObjectClient(*client_args) self.orchestration_client = OrchestrationClient(*client_args) self.ec2api_client = botoclients.APIClientEC2(*client_args) self.s3_client = botoclients.ObjectClientS3(*client_args) self.custom_object_client = ObjectClientCustomizedHeader(*client_args) self.custom_account_client = \ AccountClientCustomizedHeader(*client_args)