diff --git a/config_tempest/constants.py b/config_tempest/constants.py index 9dacc1ce..4949c5c5 100644 --- a/config_tempest/constants.py +++ b/config_tempest/constants.py @@ -63,22 +63,6 @@ SERVICE_NAMES = { 'load-balancer': 'octavia', } -# what API versions could the service have and should be enabled/disabled -# depending on whether they get discovered as supported. Services with only one -# version don't need to be here, neither do service versions that are not -# configurable in tempest.conf -# TODO(mkopec) since Queens, there are only image v2, identity v3 and -# volume v3 versions, however, for backward compatibility let's keep -# all versions here -# TODO(mkopec) Move this information about supported versions somewhere else, -# so that we don't have to have this global object, for example move the -# information to service classes -SERVICE_VERSIONS = { - 'image': {'supported_versions': ['v1', 'v2'], 'catalog': 'image'}, - 'identity': {'supported_versions': ['v2', 'v3'], 'catalog': 'identity'}, - 'volume': {'supported_versions': ['v2', 'v3'], 'catalog': 'volumev3'} -} - # Keep track of where the extensions are saved for that service. # This is necessary because the configuration file is inconsistent - it uses # different option names for service extension depending on the service. @@ -86,6 +70,6 @@ SERVICE_EXTENSION_KEY = { 'compute': 'api_extensions', 'object-store': 'discoverable_apis', 'network': 'api_extensions', - 'volume': 'api_extensions', + 'volumev3': 'api_extensions', 'identity': 'api_extensions' } diff --git a/config_tempest/services/base.py b/config_tempest/services/base.py index 272f9c32..864d7d52 100644 --- a/config_tempest/services/base.py +++ b/config_tempest/services/base.py @@ -74,11 +74,52 @@ class Service(object): return self.extensions def get_versions(self): + """Return the versions available for each service. + + This doesn't means tempestconf support all these versions. Only that + the service have these api versions enabled. + """ return self.versions def set_default_tempest_options(self, conf): pass + def get_supported_versions(self): + """Return the versions supported by tempestconf. + + The server might have older or newer versions that could not be + supported by tempestconf. + """ + return [] + + def get_catalog(self): + """Return the catalog name of a service. + + Usually the catalog has the same name of the service, in some cases + this is not true, like in volume, that we have volumev3 and volumev2 + for example. + """ + return self.name + + def get_feature_name(self): + """Return the name of service used in -feature-enabled. + + Some services have the -feature-enabled option in tempest, that + diverges from the service name. The main example is object-store + service where the -feature-enabled is object-storage. + """ + return self.name + + def get_unversioned_service_name(self): + """Return name of service without versions. + + Some services are versioned like volumev2 and volumev3, we try to + discover these services checking the supported versions, so we need + to know the unversioned service name for this. + The default value is the name of the service. + """ + return self.name + class VersionedService(Service): def set_versions(self, top_level=True): diff --git a/config_tempest/services/identity.py b/config_tempest/services/identity.py index f255279c..ca7ab197 100644 --- a/config_tempest/services/identity.py +++ b/config_tempest/services/identity.py @@ -54,6 +54,12 @@ class IdentityService(VersionedService): # rather prefer to set empty list here for now. self.extensions = [] + def get_supported_versions(self): + return ['v2', 'v3'] + + def get_catalog(self): + return 'identity' + def set_identity_v3_extensions(self): """Returns discovered identity v3 extensions diff --git a/config_tempest/services/image.py b/config_tempest/services/image.py index 4e1a05a5..6fafc013 100644 --- a/config_tempest/services/image.py +++ b/config_tempest/services/image.py @@ -62,6 +62,12 @@ class ImageService(VersionedService): # default value conf.set('image', 'http_image', C.DEFAULT_IMAGE) + def get_supported_versions(self): + return ['v1', 'v2'] + + def get_catalog(self): + return 'image' + def set_versions(self): super(ImageService, self).set_versions(top_level=False) diff --git a/config_tempest/services/object_storage.py b/config_tempest/services/object_storage.py index 809dfe65..28fa741c 100644 --- a/config_tempest/services/object_storage.py +++ b/config_tempest/services/object_storage.py @@ -57,6 +57,9 @@ class ObjectStorageService(Service): LOG.info("Role %s already exists", key_value) conf.set('object-storage', 'operator_role', 'admin') + def get_feature_name(self): + return 'object-storage' + def _check_health_check(self, path): try: self.client.accounts.skip_path() diff --git a/config_tempest/services/services.py b/config_tempest/services/services.py index c93b5d72..2beda3eb 100644 --- a/config_tempest/services/services.py +++ b/config_tempest/services/services.py @@ -67,36 +67,29 @@ class Services(object): service.set_extensions() # discover versions of the service service.set_versions() + self.merge_exts_multiversion_service(service) # default tempest options service.set_default_tempest_options(self._conf) self._services.append(service) - service_name = 'volume' - versions = C.SERVICE_VERSIONS[service_name]['supported_versions'] - self.merge_exts_multiversion_service(service_name, versions) - - def merge_exts_multiversion_service(self, name, versions): + def merge_exts_multiversion_service(self, service): """Merges extensions of a service given by its name Looking for extensions from all versions of the service defined by name and merges them to that provided service. - :param name: Name of the service - :type name: string - :param versions: Supported versions - :type versions: list + :param service: Service object """ - if not self.is_service(name): - return - s = self.get_service(name) + versions = service.get_supported_versions() + service_name = service.get_unversioned_service_name() services_lst = [] for v in versions: - if self.is_service(name + v): - services_lst.append(self.get_service(name + v)) - services_lst.append(s) - s.extensions = self.merge_extensions(services_lst) + if self.is_service(service_name + v): + services_lst.append(self.get_service(service_name + v)) + services_lst.append(service) + service.extensions = self.merge_extensions(services_lst) def get_endpoints(self, entry): for ep in entry['endpoints']: @@ -195,7 +188,6 @@ class Services(object): if self._conf.has_option('services', 'volume'): if not self._conf.getboolean('services', 'volume'): C.SERVICE_NAMES.pop('volume') - C.SERVICE_VERSIONS.pop('volume') # check availability of volume backup service volume.check_volume_backup_service(self._conf, self._clients.volume_client, @@ -233,21 +225,16 @@ class Services(object): def set_supported_api_versions(self): # set supported API versions for services with more of them - for service, service_info in C.SERVICE_VERSIONS.iteritems(): - service_object = self.get_service(service_info['catalog']) - if service_object is None: - supported_versions = [] - else: - supported_versions = service_object.get_versions() - # FIXME: object-store config param object-storage needs to be - # handled here In future this should be removed from Services class - if service == 'object-store': - service = 'object-storage' - section = service + '-feature-enabled' - for version in service_info['supported_versions']: - is_supported = any(version in item - for item in supported_versions) - self._conf.set(section, 'api_' + version, str(is_supported)) + for service in self._services: + versions = service.get_versions() + supported_versions = service.get_supported_versions() + if versions: + section = service.get_feature_name() + '-feature-enabled' + for s_version in supported_versions: + is_supported = any(s_version in item + for item in versions) + self._conf.set( + section, 'api_' + s_version, str(is_supported)) def merge_extensions(self, service_objects): """Merges extensions from all provided service objects @@ -268,6 +255,8 @@ class Services(object): if keystone_v3_support: self.get_service('identity').set_identity_v3_extensions() + # TODO(arxcruz): We already have a service.get_feature_name so we + # don't need this special case in object-store for service, ext_key in C.SERVICE_EXTENSION_KEY.iteritems(): if not self.is_service(service): continue @@ -278,4 +267,5 @@ class Services(object): # handled here In future this should be removed from Services class if service == 'object-store': service = 'object-storage' - self._conf.set(service + postfix, ext_key, extensions) + service_name = service_object.get_unversioned_service_name() + self._conf.set(service_name + postfix, ext_key, extensions) diff --git a/config_tempest/services/volume.py b/config_tempest/services/volume.py index 86fe3e4e..f73925b3 100644 --- a/config_tempest/services/volume.py +++ b/config_tempest/services/volume.py @@ -33,6 +33,18 @@ class VolumeService(VersionedService): body = json.loads(body) self.versions = self.deserialize_versions(body) + def get_supported_versions(self): + return ['v2', 'v3'] + + def get_catalog(self): + return 'volumev3' + + def get_feature_name(self): + return 'volume' + + def get_unversioned_service_name(self): + return 'volume' + def check_volume_backup_service(conf, volume_client, is_volumev3): """Verify if the cinder backup service is enabled"""