Implement set_availability method

By implementing this method we will decrease dependency
on SERVICE_NAMES. python-tempestconf loops over any
service which has a class implementation under
config_tempest/services directory. Therefore we can easily
set service availability in the loop by calling
set_availability method which sets appropriate values in
[service_available] section of tempest.conf.

This review also fixes the problem with not taking
service's versions into account when setting service
availability.

Story: 2002787
Task: 29632

Change-Id: Ica42fe6ae57eaef6bffd28b557f6b178a2ed8fb9
This commit is contained in:
Martin Kopec 2019-02-20 21:20:39 +00:00
parent ea5e1f5638
commit 33e39f3606
11 changed files with 59 additions and 30 deletions

View File

@ -43,22 +43,18 @@ ALL_CREDENTIALS_KEYS = {
"identity.admin_domain_name": [],
}
# services and their codenames
# services, which don't have their own class implemented under
# config_tempest/services, and their codenames
# NOTE: if a service from the dict below gets implementation under
# config_tempest/services it should be removed from the list
SERVICE_NAMES = {
'baremetal': 'ironic',
'compute': 'nova',
'database': 'trove',
'data-processing': 'sahara',
'image': 'glance',
'network': 'neutron',
'object-store': 'swift',
'orchestration': 'heat',
'share': 'manila',
'telemetry': 'ceilometer',
'volume': 'cinder',
'messaging': 'zaqar',
'metric': 'gnocchi',
'event': 'panko',
'workflowv2': 'mistral',
'load-balancer': 'octavia',
}

View File

@ -70,6 +70,18 @@ class Service(object):
def set_versions(self):
self.versions = []
def set_availability(self, conf, available):
"""Sets service's availability.
The services's codename will be set to desired value under
[service_available] section in tempest.conf during the services
discovery process.
"""
try:
conf.set('service_available', self.get_codename(), str(available))
except NotImplementedError:
pass
def get_extensions(self):
return self.extensions
@ -77,7 +89,7 @@ class Service(object):
def get_service_name():
"""Return the service name.
This return a list because you can have different services for the
This returns a list because you can have different services for the
same type, like volume, volumev2, volumev3
"""
return []
@ -85,8 +97,8 @@ class Service(object):
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.
This doesn't mean tempestconf supports all these versions. Only that
the service has these api versions enabled.
"""
return self.versions
@ -101,14 +113,15 @@ class Service(object):
"""
return []
def get_catalog(self):
"""Return the catalog name of a service.
@staticmethod
def get_codename():
"""Return the service_available name of the 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.
This name is used when setting service availability in
set_availability method. If the method is not implemented, service
availability is not set.
"""
return self.name
raise NotImplementedError
def get_feature_name(self):
"""Return the name of service used in <service>-feature-enabled.

View File

@ -60,3 +60,7 @@ class ComputeService(VersionedService):
@staticmethod
def get_service_name():
return ['nova']
@staticmethod
def get_codename():
return 'nova'

View File

@ -64,9 +64,6 @@ class IdentityService(VersionedService):
def get_service_name():
return ['keystone']
def get_catalog(self):
return 'identity'
def set_identity_v3_extensions(self):
"""Returns discovered identity v3 extensions

View File

@ -69,8 +69,9 @@ class ImageService(VersionedService):
def get_service_name():
return ['glance']
def get_catalog(self):
return 'image'
@staticmethod
def get_codename():
return 'glance'
def set_versions(self):
super(ImageService, self).set_versions(top_level=False)

View File

@ -95,3 +95,7 @@ class NetworkService(VersionedService):
@staticmethod
def get_service_name():
return ['neutron']
@staticmethod
def get_codename():
return 'neutron'

View File

@ -108,3 +108,7 @@ class ObjectStorageService(Service):
@staticmethod
def get_service_name():
return ['swift']
@staticmethod
def get_codename():
return 'swift'

View File

@ -30,3 +30,7 @@ class LoadBalancerService(VersionedService):
@staticmethod
def get_service_name():
return ['octavia']
@staticmethod
def get_codename():
return 'octavia'

View File

@ -112,7 +112,15 @@ class Services(object):
# default tempest options
service.set_default_tempest_options(self._conf)
service.set_availability(self._conf, True)
self._services.append(service)
else:
# service is not available
# quickly instantiate a class in order to set
# availability of the service
s = s_class(None, None, None, None)
s.set_availability(self._conf, False)
def merge_exts_multiversion_service(self, service):
"""Merges extensions of a service given by its name
@ -214,10 +222,6 @@ class Services(object):
return True
def set_service_availability(self):
# check if volume service is disabled
if self._conf.has_option('services', 'volume'):
if not self._conf.getboolean('services', 'volume'):
C.SERVICE_NAMES.pop('volume')
# check availability of volume backup service
volume.check_volume_backup_service(self._conf,
self._clients.volume_client,

View File

@ -48,8 +48,9 @@ class ShareService(VersionedService):
def get_unversioned_service_name(self):
return 'share'
def get_catalog(self):
return 'sharev2'
@staticmethod
def get_codename():
return 'manila'
def get_feature_name(self):
return 'share'

View File

@ -62,8 +62,9 @@ class VolumeService(VersionedService):
def get_supported_versions(self):
return ['v2', 'v3']
def get_catalog(self):
return 'volumev3'
@staticmethod
def get_codename():
return 'cinder'
def get_feature_name(self):
return 'volume'