Browse Source

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
changes/79/806179/3
lpiwowar 9 months ago
parent
commit
0398f2a6c0
  1. 31
      config_tempest/services/object_storage.py

31
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']

Loading…
Cancel
Save