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
This commit is contained in:
lpiwowar 2021-08-26 15:22:38 +02:00
parent c9dcf15b34
commit 0398f2a6c0
1 changed files with 22 additions and 9 deletions

View File

@ -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)
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
body.pop('swift')
self.extensions = body.keys()
except Exception:
self.extensions = []
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']