Add compare header version to create_image_from_server helper
This PS uses `compare_version_header_to_response` in
`api_version_utils` in create_image_from_server to correctly parse
the image_id from the returned image, based on the microversion
in the response body.
According to the Nova docs for this API [0], the image_id is
located in location header for < 2.45 microversion but for
>= 2.45 it is located in resp.response['image_id'].
This PS also removes an unnecessary LOG.debug statement from
`compare_version_header_to_response`, pointed out by last comment in
this other PS [1].
[0] https://developer.openstack.org/api-ref/compute/#create-image-createimage-action
[1] Ib97e65cca468a09bbeaf68fcfe0e8192674a481e
Change-Id: I413a0b79f47ead94a94ac5cf862002eeb0b8543b
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 683d3e9..5c4767c 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -262,7 +262,11 @@
image = cls.compute_images_client.create_image(server_id, name=name,
**kwargs)
- image_id = data_utils.parse_image_id(image.response['location'])
+ if api_version_utils.compare_version_header_to_response(
+ "OpenStack-API-Version", "compute 2.45", image.response, "lt"):
+ image_id = image['image_id']
+ else:
+ image_id = data_utils.parse_image_id(image.response['location'])
cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
cls.compute_images_client.delete_image,
image_id)
diff --git a/tempest/lib/common/api_version_utils.py b/tempest/lib/common/api_version_utils.py
index 98f174d..bcb076b 100644
--- a/tempest/lib/common/api_version_utils.py
+++ b/tempest/lib/common/api_version_utils.py
@@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
import testtools
from tempest.lib.common import api_version_request
@@ -20,7 +19,6 @@
LATEST_MICROVERSION = 'latest'
-LOG = logging.getLogger(__name__)
class BaseMicroversionTest(object):
@@ -166,7 +164,6 @@
if op is None:
msg = ("Operation %s is invalid. Valid options include: lt, eq, gt, "
"le, ne, ge." % operation)
- LOG.debug(msg)
raise exceptions.InvalidParam(invalid_param=msg)
# Remove "volume" from "volume <microversion>", for example, so that the