Removing dependence of SERVICE_EXTENSION_KEY

Remove this constant, and implement get_service_extension_key method to
get this information from the services.

Story: 2002787
Task: 22730
Change-Id: I7d395a3b864f9f06f5d266eb356af990c4f00a6c
This commit is contained in:
Arx Cruz 2018-08-08 11:29:05 +02:00
parent b0b8a9a6bb
commit 78ef76e09e
8 changed files with 25 additions and 25 deletions

View File

@ -62,14 +62,3 @@ SERVICE_NAMES = {
'workflowv2': 'mistral',
'load-balancer': 'octavia',
}
# 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.
SERVICE_EXTENSION_KEY = {
'compute': 'api_extensions',
'object-store': 'discoverable_apis',
'network': 'api_extensions',
'volumev3': 'api_extensions',
'identity': 'api_extensions'
}

View File

@ -110,6 +110,10 @@ class Service(object):
"""
return self.name
def get_service_extension_key(self):
"""Return the extension key for a particular service"""
return None
def get_unversioned_service_name(self):
"""Return name of service without versions.

View File

@ -43,6 +43,9 @@ class ComputeService(VersionedService):
if self._get_number_of_hosts() >= 2:
conf.set('compute-feature-enabled', 'resize', 'True')
def get_service_extension_key(self):
return 'api_extensions'
def _get_number_of_hosts(self):
# Right now the client returned is hosts, in the future
# change it to a dict, and get the client as requested

View File

@ -54,6 +54,9 @@ class IdentityService(VersionedService):
# rather prefer to set empty list here for now.
self.extensions = []
def get_service_extension_key(self):
return 'api_extensions'
def get_supported_versions(self):
return ['v2', 'v3']

View File

@ -50,6 +50,9 @@ class NetworkService(VersionedService):
conf.set('network', 'floating_network_name',
self._public_network_name)
def get_service_extension_key(self):
return 'api_extensions'
def _supplied_network(self):
LOG.info("Looking for existing network id: {0}"
"".format(self._public_network_id))

View File

@ -60,6 +60,9 @@ class ObjectStorageService(Service):
def get_feature_name(self):
return 'object-storage'
def get_service_extension_key(self):
return 'discoverable_apis'
def _check_health_check(self, path):
try:
self.client.accounts.skip_path()

View File

@ -259,17 +259,9 @@ 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
service_object = self.get_service(service)
if service_object is not None:
extensions = ','.join(service_object.get_extensions())
# 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'
service_name = service_object.get_unversioned_service_name()
self._conf.set(service_name + postfix, ext_key, extensions)
for service in self._services:
ext_key = service.get_service_extension_key()
if ext_key:
extensions = ','.join(service.get_extensions())
service_name = service.get_feature_name()
self._conf.set(service_name + postfix, ext_key, extensions)

View File

@ -33,6 +33,9 @@ class VolumeService(VersionedService):
body = json.loads(body)
self.versions = self.deserialize_versions(body)
def get_service_extension_key(self):
return 'api_extensions'
def get_supported_versions(self):
return ['v2', 'v3']