Merge "Removing dependence from SERVICE_VERSIONS"
This commit is contained in:
commit
a56bc21424
@ -63,22 +63,6 @@ SERVICE_NAMES = {
|
|||||||
'load-balancer': 'octavia',
|
'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.
|
# Keep track of where the extensions are saved for that service.
|
||||||
# This is necessary because the configuration file is inconsistent - it uses
|
# This is necessary because the configuration file is inconsistent - it uses
|
||||||
# different option names for service extension depending on the service.
|
# different option names for service extension depending on the service.
|
||||||
@ -86,6 +70,6 @@ SERVICE_EXTENSION_KEY = {
|
|||||||
'compute': 'api_extensions',
|
'compute': 'api_extensions',
|
||||||
'object-store': 'discoverable_apis',
|
'object-store': 'discoverable_apis',
|
||||||
'network': 'api_extensions',
|
'network': 'api_extensions',
|
||||||
'volume': 'api_extensions',
|
'volumev3': 'api_extensions',
|
||||||
'identity': 'api_extensions'
|
'identity': 'api_extensions'
|
||||||
}
|
}
|
||||||
|
@ -74,11 +74,52 @@ class Service(object):
|
|||||||
return self.extensions
|
return self.extensions
|
||||||
|
|
||||||
def get_versions(self):
|
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
|
return self.versions
|
||||||
|
|
||||||
def set_default_tempest_options(self, conf):
|
def set_default_tempest_options(self, conf):
|
||||||
pass
|
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 <service>-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 <service>-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):
|
class VersionedService(Service):
|
||||||
def set_versions(self, top_level=True):
|
def set_versions(self, top_level=True):
|
||||||
|
@ -54,6 +54,12 @@ class IdentityService(VersionedService):
|
|||||||
# rather prefer to set empty list here for now.
|
# rather prefer to set empty list here for now.
|
||||||
self.extensions = []
|
self.extensions = []
|
||||||
|
|
||||||
|
def get_supported_versions(self):
|
||||||
|
return ['v2', 'v3']
|
||||||
|
|
||||||
|
def get_catalog(self):
|
||||||
|
return 'identity'
|
||||||
|
|
||||||
def set_identity_v3_extensions(self):
|
def set_identity_v3_extensions(self):
|
||||||
"""Returns discovered identity v3 extensions
|
"""Returns discovered identity v3 extensions
|
||||||
|
|
||||||
|
@ -62,6 +62,12 @@ class ImageService(VersionedService):
|
|||||||
# default value
|
# default value
|
||||||
conf.set('image', 'http_image', C.DEFAULT_IMAGE)
|
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):
|
def set_versions(self):
|
||||||
super(ImageService, self).set_versions(top_level=False)
|
super(ImageService, self).set_versions(top_level=False)
|
||||||
|
|
||||||
|
@ -57,6 +57,9 @@ class ObjectStorageService(Service):
|
|||||||
LOG.info("Role %s already exists", key_value)
|
LOG.info("Role %s already exists", key_value)
|
||||||
conf.set('object-storage', 'operator_role', 'admin')
|
conf.set('object-storage', 'operator_role', 'admin')
|
||||||
|
|
||||||
|
def get_feature_name(self):
|
||||||
|
return 'object-storage'
|
||||||
|
|
||||||
def _check_health_check(self, path):
|
def _check_health_check(self, path):
|
||||||
try:
|
try:
|
||||||
self.client.accounts.skip_path()
|
self.client.accounts.skip_path()
|
||||||
|
@ -67,36 +67,29 @@ class Services(object):
|
|||||||
service.set_extensions()
|
service.set_extensions()
|
||||||
# discover versions of the service
|
# discover versions of the service
|
||||||
service.set_versions()
|
service.set_versions()
|
||||||
|
self.merge_exts_multiversion_service(service)
|
||||||
|
|
||||||
# default tempest options
|
# default tempest options
|
||||||
service.set_default_tempest_options(self._conf)
|
service.set_default_tempest_options(self._conf)
|
||||||
|
|
||||||
self._services.append(service)
|
self._services.append(service)
|
||||||
|
|
||||||
service_name = 'volume'
|
def merge_exts_multiversion_service(self, service):
|
||||||
versions = C.SERVICE_VERSIONS[service_name]['supported_versions']
|
|
||||||
self.merge_exts_multiversion_service(service_name, versions)
|
|
||||||
|
|
||||||
def merge_exts_multiversion_service(self, name, versions):
|
|
||||||
"""Merges extensions of a service given by its name
|
"""Merges extensions of a service given by its name
|
||||||
|
|
||||||
Looking for extensions from all versions of the service
|
Looking for extensions from all versions of the service
|
||||||
defined by name and merges them to that provided service.
|
defined by name and merges them to that provided service.
|
||||||
|
|
||||||
:param name: Name of the service
|
:param service: Service object
|
||||||
:type name: string
|
|
||||||
:param versions: Supported versions
|
|
||||||
:type versions: list
|
|
||||||
"""
|
"""
|
||||||
if not self.is_service(name):
|
versions = service.get_supported_versions()
|
||||||
return
|
service_name = service.get_unversioned_service_name()
|
||||||
s = self.get_service(name)
|
|
||||||
services_lst = []
|
services_lst = []
|
||||||
for v in versions:
|
for v in versions:
|
||||||
if self.is_service(name + v):
|
if self.is_service(service_name + v):
|
||||||
services_lst.append(self.get_service(name + v))
|
services_lst.append(self.get_service(service_name + v))
|
||||||
services_lst.append(s)
|
services_lst.append(service)
|
||||||
s.extensions = self.merge_extensions(services_lst)
|
service.extensions = self.merge_extensions(services_lst)
|
||||||
|
|
||||||
def get_endpoints(self, entry):
|
def get_endpoints(self, entry):
|
||||||
for ep in entry['endpoints']:
|
for ep in entry['endpoints']:
|
||||||
@ -195,7 +188,6 @@ class Services(object):
|
|||||||
if self._conf.has_option('services', 'volume'):
|
if self._conf.has_option('services', 'volume'):
|
||||||
if not self._conf.getboolean('services', 'volume'):
|
if not self._conf.getboolean('services', 'volume'):
|
||||||
C.SERVICE_NAMES.pop('volume')
|
C.SERVICE_NAMES.pop('volume')
|
||||||
C.SERVICE_VERSIONS.pop('volume')
|
|
||||||
# check availability of volume backup service
|
# check availability of volume backup service
|
||||||
volume.check_volume_backup_service(self._conf,
|
volume.check_volume_backup_service(self._conf,
|
||||||
self._clients.volume_client,
|
self._clients.volume_client,
|
||||||
@ -233,21 +225,16 @@ class Services(object):
|
|||||||
|
|
||||||
def set_supported_api_versions(self):
|
def set_supported_api_versions(self):
|
||||||
# set supported API versions for services with more of them
|
# set supported API versions for services with more of them
|
||||||
for service, service_info in C.SERVICE_VERSIONS.iteritems():
|
for service in self._services:
|
||||||
service_object = self.get_service(service_info['catalog'])
|
versions = service.get_versions()
|
||||||
if service_object is None:
|
supported_versions = service.get_supported_versions()
|
||||||
supported_versions = []
|
if versions:
|
||||||
else:
|
section = service.get_feature_name() + '-feature-enabled'
|
||||||
supported_versions = service_object.get_versions()
|
for s_version in supported_versions:
|
||||||
# FIXME: object-store config param object-storage needs to be
|
is_supported = any(s_version in item
|
||||||
# handled here In future this should be removed from Services class
|
for item in versions)
|
||||||
if service == 'object-store':
|
self._conf.set(
|
||||||
service = 'object-storage'
|
section, 'api_' + s_version, str(is_supported))
|
||||||
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))
|
|
||||||
|
|
||||||
def merge_extensions(self, service_objects):
|
def merge_extensions(self, service_objects):
|
||||||
"""Merges extensions from all provided service objects
|
"""Merges extensions from all provided service objects
|
||||||
@ -272,6 +259,8 @@ class Services(object):
|
|||||||
if keystone_v3_support:
|
if keystone_v3_support:
|
||||||
self.get_service('identity').set_identity_v3_extensions()
|
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():
|
for service, ext_key in C.SERVICE_EXTENSION_KEY.iteritems():
|
||||||
if not self.is_service(service):
|
if not self.is_service(service):
|
||||||
continue
|
continue
|
||||||
@ -282,4 +271,5 @@ class Services(object):
|
|||||||
# handled here In future this should be removed from Services class
|
# handled here In future this should be removed from Services class
|
||||||
if service == 'object-store':
|
if service == 'object-store':
|
||||||
service = 'object-storage'
|
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)
|
||||||
|
@ -33,6 +33,18 @@ class VolumeService(VersionedService):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.versions = self.deserialize_versions(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):
|
def check_volume_backup_service(conf, volume_client, is_volumev3):
|
||||||
"""Verify if the cinder backup service is enabled"""
|
"""Verify if the cinder backup service is enabled"""
|
||||||
|
Loading…
Reference in New Issue
Block a user