Work around missing microversion headers on /
In get_min_max_api_microversions, we issue a request against the root
endpoint / to get the available microversions. This endpoint does return
them in the body but due to an issue in Ironic does not return the
microversion headers. Unfortunately, our implementation of request()
makes Tempest expected these headers and fail if they're absent.
Until Ironic is fixed, use /v1 to get the required information.
Change-Id: I7003e0c90ce764c903d870d739786a8a97d5f0af
Related-Bug: #2079023
diff --git a/ironic_tempest_plugin/services/baremetal/base.py b/ironic_tempest_plugin/services/baremetal/base.py
index f2cffd5..a4277b2 100644
--- a/ironic_tempest_plugin/services/baremetal/base.py
+++ b/ironic_tempest_plugin/services/baremetal/base.py
@@ -79,8 +79,18 @@
def get_min_max_api_microversions(self):
"""Returns a tuple of minimum and remote microversions."""
- _, resp_body = self._show_request(None, uri='/')
- version = resp_body.get('default_version', {})
+ if '/v1' in self.base_url:
+ root_uri = '/'
+ else:
+ # NOTE(dtantsur): we should just use / here but due to a bug in
+ # Ironic, / does not contain the microversion headers. See
+ # https://bugs.launchpad.net/ironic/+bug/2079023
+ root_uri = '/v1'
+ _, resp_body = self._show_request(None, uri=root_uri)
+ try:
+ version = resp_body['default_version']
+ except KeyError:
+ version = resp_body['version']
api_min = version.get('min_version')
api_max = version.get('version')
return (api_min, api_max)