def get_service_clients(self): ironic_config = config.service_client_config( project_config.baremetal_group.name ) baremetal_client = { 'name': 'baremetal', 'service_version': 'baremetal.v1', 'module_path': 'ironic_tempest_plugin.services.baremetal.v1.' 'json.baremetal_client', 'client_names': [ 'BaremetalClient', ], } baremetal_client.update(ironic_config) inspector_config = config.service_client_config( project_config.baremetal_introspection_group.name ) inspector_client = { 'name': 'introspection', 'service_version': 'baremetal_introspection.v1', 'module_path': 'ironic_tempest_plugin.services.' 'introspection_client', 'client_names': [ 'BaremetalIntrospectionClient', ], } inspector_client.update(inspector_config) return [baremetal_client, inspector_client]
def __init__(self, credentials, scope='project'): """Initialization of Manager class. Setup all services clients and make them available for tests cases. :param credentials: type Credentials or TestResources :param scope: default scope for tokens produced by the auth provider """ _, identity_uri = get_auth_provider_class(credentials) super(Manager, self).__init__( credentials=credentials, identity_uri=identity_uri, scope=scope, region=CONF.identity.region) # TODO(andreaf) When clients are initialised without the right # parameters available, the calls below will trigger a KeyError. # We should catch that and raise a better error. self._set_compute_clients() self._set_identity_clients() self._set_volume_clients() self._set_object_storage_clients() self._set_image_clients() self._set_network_clients() self.placement_client = self.placement.PlacementClient() # TODO(andreaf) This is maintained for backward compatibility # with plugins, but it should removed eventually, since it was # never a stable interface and it's not useful anyways self.default_params = config.service_client_config()
def resource_setup(cls): super(FWaaSClientMixin, cls).resource_setup() manager = cls.os_primary default_params = config.service_client_config() cls.firewalls_client = client.FirewallsClient( manager.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, **default_params) cls.firewall_policies_client = client.FirewallPoliciesClient( manager.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, **default_params) cls.firewall_rules_client = client.FirewallRulesClient( manager.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, **default_params)
class Manager(clients.Manager): default_params = config.service_client_config() telemetry_params = { 'service': CONF.telemetry.catalog_type, 'region': CONF.identity.region, 'endpoint_type': CONF.telemetry.endpoint_type, } telemetry_params.update(default_params) def __init__(self, credentials): # TODO(andreaf) Overriding Manager is a workaround. The "proper" way # would it to expose the ceilometer service client via the plugin # interface, use tempest.lib.clients and tempest master. # Then ceilometer service client would be loaded and configured # automatically into ServiceClients. # In any case we're about to declare clients.Manager a stable # interface for plugins and we won't change it, so this code won't # break. super(Manager, self).__init__(credentials=credentials) self.set_telemetry_client() def set_telemetry_client(self): self.telemetry_client = TelemetryClient(self.auth_provider, **self.telemetry_params)
def setUp(self): super(TestPreProvisionedCredentials, self).setUp() self.useFixture(fake_config.ConfigFixture()) self.patchobject(config, 'TempestConfigPrivate', fake_config.FakePrivate) self.patch(self.token_client, side_effect=self.identity_response) self.useFixture(lockutils_fixtures.ExternalLockFixture()) self.test_accounts = self._fake_accounts(cfg.CONF.identity.admin_role) self.accounts_mock = self.useFixture(fixtures.MockPatch( 'tempest.lib.common.preprov_creds.read_accounts_yaml', return_value=self.test_accounts)) self.useFixture(fixtures.MockPatch( 'os.path.isfile', return_value=True)) # NOTE(andreaf) Ensure config is loaded so service clients are # registered in the registry before tests config.service_client_config()
def test_get_configured_admin_credentials_not_fill_valid( self, mock_get_credentials): cfg.CONF.set_default('auth_version', 'v2', 'identity') all_params = [ ('admin_username', 'username', 'my_name'), ('admin_user_domain_name', 'user_domain_name', 'my_dname'), ('admin_password', 'password', 'secret'), ('admin_project_domain_name', 'project_domain_name', 'my_dname'), ('admin_project_name', 'project_name', 'my_pname'), ('admin_domain_name', 'domain_name', 'my_dname'), ('admin_system', 'system', None), ] expected_result = mock.Mock() expected_result.is_valid.return_value = True mock_get_credentials.return_value = expected_result for config_item, _, value in all_params: cfg.CONF.set_default(config_item, value, 'auth') # Build the expected params expected_params = dict([(field, value) for _, field, value in all_params]) expected_params.update(config.service_client_config()) admin_creds = cf.get_configured_admin_credentials( fill_in=False, identity_version='v3') mock_get_credentials.assert_called_once_with(fill_in=False, identity_version='v3', **expected_params) self.assertEqual(expected_result, admin_creds) expected_result.is_valid.assert_called_once()
def get_credentials(fill_in=True, identity_version=None, **kwargs): """Get credentials from dict based on config Wrapper around auth.get_credentials to use the configured identity version if none is specified. :param fill_in: If True, a request to the Token API is submitted, and the credential object is filled in with all names and IDs from the token API response. :param identity_version: The identity version to talk to and the type of credentials object to be created. 'v2' or 'v3'. :param kwargs: Attributes to be used to build the Credentials object. :returns: An object of a sub-type of `auth.Credentials` """ params = dict(config.service_client_config(), **kwargs) identity_version = identity_version or CONF.identity.auth_version # In case of "v3" add the domain from config if not specified # To honour the "default_credentials_domain_name", if not domain # field is specified at all, add it the credential dict. if identity_version == 'v3': domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES if 'domain' in x) if not domain_fields.intersection(kwargs.keys()): domain_name = CONF.auth.default_credentials_domain_name # NOTE(andreaf) Setting domain_name implicitly sets user and # project domain names, if they are None params['domain_name'] = domain_name auth_url = CONF.identity.uri_v3 else: auth_url = CONF.identity.uri return auth.get_credentials(auth_url, fill_in=fill_in, identity_version=identity_version, **params)
def _prepare_configuration(self): """Map values from CONF into Manager parameters This uses `config.service_client_config` for all services to collect most configuration items needed to init the clients. """ # NOTE(andreaf) Configuration items will be passed in future patches # into ClientFactory objects, but for now we update all the # _set_*_client methods to consume them so we can verify that the # configuration collected is correct configuration = {} # Setup the parameters for all Tempest services. # NOTE(andreaf) Since client.py is an internal module of Tempest, # it doesn't have to consider plugin configuration. all_tempest_modules = (set(clients.tempest_modules()) | clients._tempest_internal_modules()) for service in all_tempest_modules: try: # NOTE(andreaf) Use the unversioned service name to fetch # the configuration since configuration is not versioned. service_for_config = service.split('.')[0] if service_for_config not in configuration: configuration[service_for_config] = ( config.service_client_config(service_for_config)) except lib_exc.UnknownServiceClient: LOG.warn( 'Could not load configuration for service %s' % service) return configuration
def setup_clients(cls): super(BaseDatabaseTest, cls).setup_clients() default_params = config.service_client_config() # NOTE: Tempest uses timeout values of compute API if project specific # timeout values don't exist. 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) cls.database_flavors_client = flavors_client.FlavorsClient( cls.os_primary.auth_provider, CONF.database.catalog_type, CONF.identity.region, **default_params_with_timeout_values) cls.os_flavors_client = cls.os_primary.flavors_client cls.database_limits_client = limits_client.LimitsClient( cls.os_primary.auth_provider, CONF.database.catalog_type, CONF.identity.region, **default_params_with_timeout_values) cls.database_versions_client = versions_client.VersionsClient( cls.os_primary.auth_provider, CONF.database.catalog_type, CONF.identity.region, **default_params_with_timeout_values)
def _prepare_configuration(self): """Map values from CONF into Manager parameters This uses `config.service_client_config` for all services to collect most configuration items needed to init the clients. """ # NOTE(andreaf) Once all service clients in Tempest are migrated # to tempest.lib, their configuration will be picked up from the # registry, and this method will become redundant. configuration = {} # Setup the parameters for all Tempest services which are not in lib. # NOTE(andreaf) Since client.py is an internal module of Tempest, # it doesn't have to consider plugin configuration. for service in clients._tempest_internal_modules(): try: # NOTE(andreaf) Use the unversioned service name to fetch # the configuration since configuration is not versioned. service_for_config = service.split('.')[0] if service_for_config not in configuration: configuration[service_for_config] = ( config.service_client_config(service_for_config)) except lib_exc.UnknownServiceClient: LOG.warn( 'Could not load configuration for service %s' % service) return configuration
def __init__(self, credentials, scope='project'): """Initialization of Manager class. Setup all services clients and make them available for tests cases. :param credentials: type Credentials or TestResources :param scope: default scope for tokens produced by the auth provider """ _, identity_uri = get_auth_provider_class(credentials) super(Manager, self).__init__(credentials=credentials, identity_uri=identity_uri, scope=scope, region=CONF.identity.region) # TODO(andreaf) When clients are initialised without the right # parameters available, the calls below will trigger a KeyError. # We should catch that and raise a better error. self._set_compute_clients() self._set_identity_clients() self._set_volume_clients() self._set_object_storage_clients() self._set_image_clients() self._set_network_clients() self._set_placement_clients() # TODO(andreaf) This is maintained for backward compatibility # with plugins, but it should removed eventually, since it was # never a stable interface and it's not useful anyways self.default_params = config.service_client_config()
def get_service_clients(self): dns_config = config.service_client_config('dns') admin_params = { 'name': 'dns_admin', 'service_version': 'dns.admin', 'module_path': 'designate_tempest_plugin.services.dns.admin', 'client_names': ['QuotasClient'] } v2_params = { 'name': 'dns_v2', 'service_version': 'dns.v2', 'module_path': 'designate_tempest_plugin.services.dns.v2', 'client_names': [ 'BlacklistsClient', 'PoolClient', 'QuotasClient', 'RecordsetClient', 'TldClient', 'TransferAcceptClient', 'TransferRequestClient', 'TsigkeyClient', 'ZoneExportsClient', 'ZoneImportsClient', 'ZonesClient' ] } admin_params.update(dns_config) v2_params.update(dns_config) return [admin_params, v2_params]
def _prepare_configuration(self): """Map values from CONF into Manager parameters This uses `config.service_client_config` for all services to collect most configuration items needed to init the clients. """ # NOTE(andreaf) Once all service clients in Tempest are migrated # to tempest.lib, their configuration will be picked up from the # registry, and this method will become redundant. configuration = {} # Setup the parameters for all Tempest services which are not in lib. # NOTE(andreaf) Since client.py is an internal module of Tempest, # it doesn't have to consider plugin configuration. for service in clients._tempest_internal_modules(): try: # NOTE(andreaf) Use the unversioned service name to fetch # the configuration since configuration is not versioned. service_for_config = service.split(".")[0] if service_for_config not in configuration: configuration[service_for_config] = config.service_client_config(service_for_config) except lib_exc.UnknownServiceClient: LOG.warn("Could not load configuration for service %s" % service) return configuration
def setUp(self): super(TestPreProvisionedCredentials, self).setUp() self.useFixture(fake_config.ConfigFixture()) self.patchobject(config, 'TempestConfigPrivate', fake_config.FakePrivate) self.patch(self.token_client, side_effect=self.identity_response) self.useFixture(lockutils_fixtures.ExternalLockFixture()) self.test_accounts = self._fake_accounts(cfg.CONF.identity.admin_role) self.accounts_mock = self.useFixture( fixtures.MockPatch( 'tempest.lib.common.preprov_creds.read_accounts_yaml', return_value=self.test_accounts)) self.useFixture(fixtures.MockPatch('os.path.isfile', return_value=True)) # NOTE(andreaf) Ensure config is loaded so service clients are # registered in the registry before tests config.service_client_config()
def get_service_clients(self): service_config = config.service_client_config('database') service_params = { 'name': 'database', 'service_version': 'database', 'module_path': 'trove_tempest_plugin.services.client', 'client_names': ['TroveClient'] } service_params.update(service_config) return [service_params]
def get_auth_provider(credentials, pre_auth=False, scope="project"): # kwargs for auth provider match the common ones used by service clients default_params = config.service_client_config() if credentials is None: raise exceptions.InvalidCredentials("Credentials must be specified") auth_provider_class, auth_url = get_auth_provider_class(credentials) _auth_provider = auth_provider_class(credentials, auth_url, scope=scope, **default_params) if pre_auth: _auth_provider.set_auth() return _auth_provider
def get_service_clients(self): orchestration_config = config.service_client_config('heat_plugin') params = { 'name': 'orchestration', 'service_version': 'orchestration', 'module_path': 'heat_integrationtests.services.orchestration', 'client_names': ['OrchestrationClient'] } params.update(orchestration_config) return [params]
def get_service_clients(self): qinling_config = config.service_client_config('qinling') params = { 'name': 'qinling', 'service_version': 'qinling', 'module_path': 'qinling_tempest_plugin.services.qinling_client', 'client_names': ['QinlingClient'], } params.update(qinling_config) return [params]
def test_service_client_config_no_service(self): params = config.service_client_config() for param_name in self.expected_common_params: self.assertIn(param_name, params) for param_name in self.expected_extra_params: self.assertNotIn(param_name, params) self.assertEqual(self.CONF.identity.disable_ssl_certificate_validation, params['disable_ssl_certificate_validation']) self.assertEqual(self.CONF.identity.ca_certificates_file, params['ca_certs']) self.assertEqual(self.CONF.debug.trace_requests, params['trace_requests'])
def test_service_client_config_no_service(self): params = config.service_client_config() for param_name in self.expected_common_params: self.assertIn(param_name, params) for param_name in self.expected_extra_params: self.assertNotIn(param_name, params) self.assertEqual( self.CONF.identity.disable_ssl_certificate_validation, params['disable_ssl_certificate_validation']) self.assertEqual(self.CONF.identity.ca_certificates_file, params['ca_certs']) self.assertEqual(self.CONF.debug.trace_requests, params['trace_requests'])
def get_service_clients(self): data_processing_config = ( config.service_client_config('data-processing')) params = { 'name': 'data_processing', 'service_version': 'data_processing.v1_1', 'module_path': 'sahara_tempest_plugin.services.data_processing.v1_1', 'client_names': ['DataProcessingClient'] } params.update(data_processing_config) return [params]
def test_get_credentials_v2(self, mock_auth_get_credentials): expected_uri = 'V2_URI' expected_result = 'my_creds' mock_auth_get_credentials.return_value = expected_result cfg.CONF.set_default('uri', expected_uri, 'identity') params = {'foo': 'bar'} expected_params = params.copy() expected_params.update(config.service_client_config()) result = cf.get_credentials(identity_version='v2', **params) self.assertEqual(expected_result, result) mock_auth_get_credentials.assert_called_once_with( expected_uri, fill_in=True, identity_version='v2', **expected_params)
def get_auth_provider(credentials, pre_auth=False, scope='project'): # kwargs for auth provider match the common ones used by service clients default_params = config.service_client_config() if credentials is None: raise lib_exc.InvalidCredentials('Credentials must be specified') auth_provider_class, auth_url = get_auth_provider_class(credentials) _auth_provider = auth_provider_class(credentials, auth_url, scope=scope, **default_params) if pre_auth: _auth_provider.set_auth() return _auth_provider
def get_service_clients(self): octavia_config = config.service_client_config( project_config.octavia_group.name) params = { 'name': 'load-balancer_v2', 'service_version': 'load-balancer.v2', 'module_path': 'octavia_tempest_plugin.services.load_balancer.v2', 'client_names': ['LoadbalancerClient'], } params.update(octavia_config) return [params]
def _set_object_storage_clients(self): # NOTE(andreaf) Load configuration from config. Once object storage # is in lib, configuration will be pulled directly from the registry # and this will not be required anymore. params = config.service_client_config('object-storage') self.account_client = object_storage.AccountClient(self.auth_provider, **params) self.bulk_client = object_storage.BulkMiddlewareClient( self.auth_provider, **params) self.capabilities_client = object_storage.CapabilitiesClient( self.auth_provider, **params) self.container_client = object_storage.ContainerClient( self.auth_provider, **params) self.object_client = object_storage.ObjectClient(self.auth_provider, **params)
def test_service_client_config_service_minimal(self): params = config.service_client_config( service_client_name='fake-service2') for param_name in self.expected_common_params: self.assertIn(param_name, params) for param_name in self.expected_extra_params: self.assertIn(param_name, params) self.assertEqual(self.CONF.fake_service2.catalog_type, params['service']) self.assertEqual(self.CONF.fake_service2.endpoint_type, params['endpoint_type']) self.assertEqual(self.CONF.identity.region, params['region']) self.assertEqual(self.CONF.compute.build_timeout, params['build_timeout']) self.assertEqual(self.CONF.compute.build_interval, params['build_interval'])
def _set_object_storage_clients(self): # NOTE(andreaf) Load configuration from config. Once object storage # is in lib, configuration will be pulled directly from the registry # and this will not be required anymore. params = config.service_client_config('object-storage') self.account_client = object_storage.AccountClient( self.auth_provider, **params) self.bulk_client = object_storage.BulkMiddlewareClient( self.auth_provider, **params) self.capabilities_client = object_storage.CapabilitiesClient( self.auth_provider, **params) self.container_client = object_storage.ContainerClient( self.auth_provider, **params) self.object_client = object_storage.ObjectClient( self.auth_provider, **params)
def get_extension_client(os, service): params = config.service_client_config('object-storage') extensions_client = { 'nova': os.compute.ExtensionsClient(), 'neutron': os.network.ExtensionsClient(), 'swift': object_storage.CapabilitiesClient(os.auth_provider, **params), # NOTE: Cinder v3 API is current and v2 and v1 are deprecated. # V3 extension API is the same as v2, so we reuse the v2 client # for v3 API also. 'cinder': os.volume_v2.ExtensionsClient(), } if service not in extensions_client: print('No tempest extensions client for %s' % service) sys.exit(1) return extensions_client[service]
def get_service_clients(self): dns_config = config.service_client_config('dns') admin_params = { 'name': 'dns_admin', 'service_version': 'dns.admin', 'module_path': 'designate_tempest_plugin.services.dns.admin', 'client_names': ['QuotasClient'] } v2_params = { 'name': 'dns_v2', 'service_version': 'dns.v2', 'module_path': 'designate_tempest_plugin.services.dns.v2', 'client_names': dns_v2_services.__all__ } admin_params.update(dns_config) v2_params.update(dns_config) return [admin_params, v2_params]
def test_get_credentials_v3_domain(self, mock_auth_get_credentials): expected_uri = 'V3_URI' expected_result = 'my_creds' expected_domain = 'my_domain' mock_auth_get_credentials.return_value = expected_result cfg.CONF.set_default('uri_v3', expected_uri, 'identity') cfg.CONF.set_default('default_credentials_domain_name', expected_domain, 'auth') params = {'foo': 'bar', 'user_domain_name': expected_domain} expected_params = params.copy() expected_params.update(config.service_client_config()) result = cf.get_credentials(fill_in=False, identity_version='v3', **params) self.assertEqual(expected_result, result) mock_auth_get_credentials.assert_called_once_with( expected_uri, fill_in=False, identity_version='v3', **expected_params)
def get_service_clients(self): shares_config = config.service_client_config('share') v1_params = { 'name': 'share_v1', 'service_version': 'share.v1', 'module_path': 'manila_tempest_tests.services.share.json', 'client_names': ['SharesClient'], } v2_params = { 'name': 'share_v2', 'service_version': 'share.v2', 'module_path': 'manila_tempest_tests.services.share.v2', 'client_names': ['SharesV2Client'], } v1_params.update(shares_config) v2_params.update(shares_config) return [v1_params, v2_params]
def setup_clients(cls): super(BaseApplicationCatalogScenarioTest, cls).setup_clients() if not hasattr(cls, "os_primary"): creds = cls.get_configured_isolated_creds(type_of_creds='primary') cls.os_primary = clients.Manager(credentials=creds) cls.services_manager = services_manager(creds) cls.application_catalog_client = \ cls.os_primary.application_catalog_client cls.artifacts_client = cls.os_primary.artifacts_client cls.servers_client = cls.services_manager.servers_client # NOTE(andreaf) The orchestration client is not initialised in Tempest # by default anymore. params = config.service_client_config('orchestration') cls.orchestration_client = orchestration.OrchestrationClient( cls.services_manager.auth_provider, **params) cls.images_client = cls.services_manager.image_client_v2
def test_get_credentials_v3_system(self, mock_auth_get_credentials): expected_uri = 'V3_URI' expected_result = 'my_creds' mock_auth_get_credentials.return_value = expected_result cfg.CONF.set_default('uri_v3', expected_uri, 'identity') cfg.CONF.set_default('admin_system', 'all', 'auth') params = {'system': 'all'} expected_params = params.copy() expected_params.update(config.service_client_config()) result = cf.get_credentials(fill_in=False, identity_version='v3', **params) self.assertEqual(expected_result, result) mock_auth_get_credentials.assert_called_once_with( expected_uri, fill_in=False, identity_version='v3', **expected_params)
def test_get_configured_admin_credentials(self, mock_get_credentials): cfg.CONF.set_default('auth_version', 'v3', 'identity') all_params = [('admin_username', 'username', 'my_name'), ('admin_password', 'password', 'secret'), ('admin_project_name', 'project_name', 'my_pname'), ('admin_domain_name', 'domain_name', 'my_dname')] expected_result = 'my_admin_credentials' mock_get_credentials.return_value = expected_result for config_item, _, value in all_params: cfg.CONF.set_default(config_item, value, 'auth') # Build the expected params expected_params = dict( [(field, value) for _, field, value in all_params]) expected_params.update(config.service_client_config()) admin_creds = cf.get_configured_admin_credentials() mock_get_credentials.assert_called_once_with( fill_in=True, identity_version='v3', **expected_params) self.assertEqual(expected_result, admin_creds)
def get_service_clients(self): # Ignore the ArgsAlreadyParsed error: it means that # the same content is (still) defined in Tempest try: data_processing_config = ( config.service_client_config('data-processing')) except cfg.ArgsAlreadyParsedError: # the service name must be returned with the other params data_processing_config = {'service': 'data-processing'} params = { 'name': 'data_processing', 'service_version': 'data_processing.v1_1', 'module_path': 'sahara_tempest_plugin.services.data_processing.v1_1', 'client_names': ['DataProcessingClient'] } params.update(data_processing_config) return [params]
def get_configured_admin_credentials(fill_in=True, identity_version=None): """Get admin credentials from the config file Read credentials from configuration, builds a Credentials object based on the specified or configured version :param fill_in: If True, a request to the Token API is submitted, and the credential object is filled in with all names and IDs from the token API response. :param identity_version: The identity version to talk to and the type of credentials object to be created. 'v2' or 'v3'. :returns: An object of a sub-type of `auth.Credentials` """ identity_version = identity_version or CONF.identity.auth_version if identity_version not in ('v2', 'v3'): raise exceptions.InvalidConfiguration('Unsupported auth version: %s' % identity_version) conf_attributes = ['username', 'password', 'project_name'] if identity_version == 'v3': conf_attributes.append('domain_name') conf_attributes.append('user_domain_name') conf_attributes.append('project_domain_name') conf_attributes.append('system') # Read the parts of credentials from config params = config.service_client_config() for attr in conf_attributes: params[attr] = getattr(CONF.auth, 'admin_' + attr) # Build and validate credentials. We are reading configured credentials, # so validate them even if fill_in is False credentials = get_credentials(fill_in=fill_in, identity_version=identity_version, **params) if not fill_in: if not credentials.is_valid(): msg = ("The admin credentials are incorrectly set in the config " "file for identity version %s. Double check that all " "required values are assigned.") raise exceptions.InvalidConfiguration(msg % identity_version) return credentials
def get_service_clients(self): dns_config = config.service_client_config('dns') admin_params = { 'name': 'dns_admin', 'service_version': 'dns.admin', 'module_path': 'designate_tempest_plugin.services.dns.admin', 'client_names': ['QuotasClient'] } v2_params = { 'name': 'dns_v2', 'service_version': 'dns.v2', 'module_path': 'designate_tempest_plugin.services.dns.v2', 'client_names': ['BlacklistsClient', 'PoolClient', 'QuotasClient', 'RecordsetClient', 'TldClient', 'TransferAcceptClient', 'TransferRequestClient', 'TsigkeyClient', 'ZoneExportsClient', 'ZoneImportsClient', 'ZonesClient'] } admin_params.update(dns_config) v2_params.update(dns_config) return [admin_params, v2_params]
def get_service_clients(self): gbp_config = config.service_client_config('gbp') v2_params = { 'name': 'gbp_v2', 'service_version': 'gbp.v2', 'module_path': 'gbp_tempest_plugin.services.gbp.v2', 'client_names': [ 'PolicyActionClient', 'PolicyClassifierClient', 'PolicyRuleClient', 'PolicyRuleSetClient', 'L3PolicyClient', 'L2PolicyClient', 'AppPolicyGroupClient', 'PolicyTargetGroupClient', 'PolicyTargetClient', 'NetworkServicePolicyClient', 'ExternalPolicyClient', 'ExternalSegmentClient', 'NATPoolClient', 'ServiceChainSpecClient', 'ServiceProfileClient' ] } v2_params.update(gbp_config) return [v2_params]
def get_configured_admin_credentials(fill_in=True, identity_version=None): """Get admin credentials from the config file Read credentials from configuration, builds a Credentials object based on the specified or configured version :param fill_in: If True, a request to the Token API is submitted, and the credential object is filled in with all names and IDs from the token API response. :param identity_version: The identity version to talk to and the type of credentials object to be created. 'v2' or 'v3'. :returns: An object of a sub-type of `auth.Credentials` """ identity_version = identity_version or CONF.identity.auth_version if identity_version not in ('v2', 'v3'): raise exceptions.InvalidConfiguration( 'Unsupported auth version: %s' % identity_version) conf_attributes = ['username', 'password', 'project_name'] if identity_version == 'v3': conf_attributes.append('domain_name') # Read the parts of credentials from config params = config.service_client_config() for attr in conf_attributes: params[attr] = getattr(CONF.auth, 'admin_' + attr) # Build and validate credentials. We are reading configured credentials, # so validate them even if fill_in is False credentials = get_credentials(fill_in=fill_in, identity_version=identity_version, **params) if not fill_in: if not credentials.is_valid(): msg = ("The admin credentials are incorrectly set in the config " "file for identity version %s. Double check that all " "required values are assigned.") raise exceptions.InvalidConfiguration(msg % identity_version) return credentials
class BaseSenlinTest(test.BaseTestCase): credentials = ['primary'] default_params = config.service_client_config() # NOTE: Tempest uses timeout values of compute API if project specific # timeout values don't exist. 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) @classmethod def skip_checks(cls): super(BaseSenlinTest, cls).skip_checks() if not CONF.service_available.senlin: skip_msg = 'Senlin is disabled' raise cls.skipException(skip_msg) @classmethod def setup_clients(cls): super(BaseSenlinTest, cls).setup_clients()
def test_service_client_config_service_unknown(self): unknown_service = 'unknown_service' with testtools.ExpectedException(exceptions.UnknownServiceClient, '.*' + unknown_service + '.*'): config.service_client_config(service_client_name=unknown_service)