Fix getting flavor data for basic ops
As of microversion 2.47 of compute api, there is no flavor
id in instance["flavor"], just dict with data related to
flavor.
Related-Prod: https://mirantis.jira.com/browse/PRODX-28606
Change-Id: I3b6223c24df112bcda21d130cafb3fae0baed66f
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
index 727bc68..c62f3c3 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
@@ -130,9 +130,15 @@
def get_flavor_ephemeral_size(self):
"""Returns size of the ephemeral partition in GiB."""
- f_id = self.instance['flavor']['id']
- flavor = self.flavors_client.show_flavor(f_id)['flavor']
- ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
+ if (api_version_request.APIVersionRequest(
+ self.compute_min_microversion)
+ >= api_version_request.APIVersionRequest('2.47')):
+ flavor = self.instance['flavor']
+ ephemeral = flavor.get('ephemeral')
+ else:
+ f_id = self.instance['flavor']['id']
+ flavor = self.flavors_client.show_flavor(f_id)['flavor']
+ ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
if not ephemeral or ephemeral == 'N/A':
return None
return int(ephemeral)
@@ -159,9 +165,17 @@
"""
node = self.get_node(instance_id=self.instance['id'],
api_version='1.37')
- f_id = self.instance['flavor']['id']
- extra_specs = self.flavors_client.list_flavor_extra_specs(f_id)
- extra_specs = extra_specs['extra_specs']
+ # As of microversion 2.47 flavor field in instance is
+ # a subset of the actual flavor information used to create
+ # the server instance, represented as a nested dictionary.
+ if (api_version_request.APIVersionRequest(
+ self.compute_min_microversion)
+ >= api_version_request.APIVersionRequest('2.47')):
+ extra_specs = self.instance['flavor']['extra_specs']
+ else:
+ f_id = self.instance['flavor']['id']
+ extra_specs = self.flavors_client.list_flavor_extra_specs(f_id)
+ extra_specs = extra_specs['extra_specs']
# Pull the requested resource class and traits from the flavor.
resource_class = None