From 0398f2a6c01de0079b4d7ab747876749e73685a8 Mon Sep 17 00:00:00 2001 From: lpiwowar Date: Thu, 26 Aug 2021 15:22:38 +0200 Subject: [PATCH] Fix extension discovery for object_storage Python-tempestconf assumed that swift's /info endpoint is always the same. But it may happen that the endpoint is renamed to /swift/info in certain situations (e.g.: when swift is on ceph). This patch fixes the issue by trying to access the /info endpoint first. When the connection to /info endpoint is unsuccessful then /swift/info endpoint is used as a fallback. Story: 43092 Change-Id: I4447e1527eae8ec75acb4fb96047c894db75620d --- config_tempest/services/object_storage.py | 31 ++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/config_tempest/services/object_storage.py b/config_tempest/services/object_storage.py index 7fec4011..7907c19e 100644 --- a/config_tempest/services/object_storage.py +++ b/config_tempest/services/object_storage.py @@ -25,18 +25,31 @@ from config_tempest.services.base import Service class ObjectStorageService(Service): def set_extensions(self): if 'v3' not in self.service_url: # it's not a v3 url - try: - body = self.do_get(self.service_url, top_level=True, - top_level_path="info") - body = json.loads(body) - # Remove Swift general information from extensions list - body.pop('swift') - self.extensions = body.keys() - except Exception: - self.extensions = [] + capabilities = self.get_capabilities('info') + if not capabilities: + # Certain deploynments have /info API endpoint for + # listing active capabilities at /swift/info instead + # (e.g.: when ceph is on swift) + capabilities = self.get_capabilities('swift/info') + + capabilities = json.loads(capabilities) + # Remove Swift general information from extensions list + capabilities.pop('swift', {}) + self.extensions = capabilities.keys() else: self.extensions = [] + def get_capabilities(self, path): + try: + body = self.do_get(self.service_url, top_level=True, + top_level_path=path) + except Exception as e: + body = '{}' + LOG.warning('Object storage %s API endpoint not discovered. ' + 'Error message: %s', path, e) + + return body + def list_create_roles(self, conf, client): try: roles = client.list_roles()['roles']