object/notification for Adds Pick guest CPU architecture based on host

arch in libvirt driver support

This is split 1 of 3 for the architecture emulation feature.

This adds the 'hw_emulation_architecture' property to the image meta
properties, allowing for operator to define whether they will use
emulation or not.

This adds the capability as a feature to ensure no impact to normal
operations or functionality.

Account for object versioning has been added to raise exceptions and
handle proper

Implements: blueprint pick-guest-arch-based-on-host-arch-in-libvirt-driver
Signed-off-by: Jonathan Race <jrace@augusta.edu>
Change-Id: If4f598c0d3f9e64617beb54450faa04e7d20dd20
This commit is contained in:
Jonathan Race 2022-02-08 10:36:36 -05:00
parent b2ec3cd921
commit 79887a610b
7 changed files with 34 additions and 7 deletions

View File

@ -4,5 +4,5 @@
"hw_architecture": "x86_64"
},
"nova_object.name": "ImageMetaPropsPayload",
"nova_object.version": "1.8"
"nova_object.version": "1.9"
}

View File

@ -125,7 +125,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase):
# Version 1.6: Added 'socket' to hw_pci_numa_affinity_policy
# Version 1.7: Added 'hw_input_bus' field
# Version 1.8: Added 'bochs' as an option to 'hw_video_model'
VERSION = '1.8'
# Version 1.9: Added 'hw_emulation_architecture' field
VERSION = '1.9'
SCHEMA = {
k: ('image_meta_props', k) for k in image_meta.ImageMetaProps.fields}

View File

@ -187,14 +187,17 @@ class ImageMetaProps(base.NovaObject):
# Version 1.28: Added 'socket' to 'hw_pci_numa_affinity_policy'
# Version 1.29: Added 'hw_input_bus' field
# Version 1.30: Added 'bochs' as an option to 'hw_video_model'
# Version 1.31: Added 'hw_emulation_architecture' field
# NOTE(efried): When bumping this version, the version of
# ImageMetaPropsPayload must also be bumped. See its docstring for details.
VERSION = '1.30'
VERSION = '1.31'
def obj_make_compatible(self, primitive, target_version):
super(ImageMetaProps, self).obj_make_compatible(primitive,
target_version)
target_version = versionutils.convert_version_to_tuple(target_version)
if target_version < (1, 31):
primitive.pop('hw_emulation_architecture', None)
if target_version < (1, 30):
video = primitive.get('hw_video_model', None)
if video == fields.VideoModel.BOCHS:
@ -294,6 +297,10 @@ class ImageMetaProps(base.NovaObject):
# name of guest hardware architecture eg i686, x86_64, ppc64
'hw_architecture': fields.ArchitectureField(),
# hw_architecture field is leveraged for checks against physical nodes
# name of desired emulation architecture eg i686, x86_64, ppc64
'hw_emulation_architecture': fields.ArchitectureField(),
# used to decide to expand root disk partition and fs to full size of
# root disk
'hw_auto_disk_config': fields.StringField(),

View File

@ -1231,7 +1231,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': '1.8',
'nova_object.version': '1.9',
},
'image.size': 58145823,
'image.tags': [],
@ -1327,7 +1327,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': '1.8',
'nova_object.version': '1.9',
},
'image.size': 58145823,
'image.tags': [],

View File

@ -386,7 +386,7 @@ notification_object_data = {
# ImageMetaProps, so when you see a fail here for that reason, you must
# *also* bump the version of ImageMetaPropsPayload. See its docstring for
# more information.
'ImageMetaPropsPayload': '1.8-080bdcba9b96122eab57bf39d47348f7',
'ImageMetaPropsPayload': '1.9-24a851511d98e652aebd3536e7e08330',
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'InstanceActionPayload': '1.8-4fa3da9cbf0761f1f700ae578f36dc2f',
'InstanceActionRebuildNotification':

View File

@ -349,6 +349,25 @@ class TestImageMetaProps(test.NoDBTestCase):
self.assertRaises(exception.ObjectActionError,
obj.obj_to_primitive, '1.0')
def test_obj_make_compatible_hw_emulation(self):
"""Check 'hw_emulation_architecture' compatibility."""
# assert that 'hw_emulation_architecture' is supported
# on a suitably new version
obj = objects.ImageMetaProps(
hw_emulation_architecture=objects.fields.Architecture.AARCH64,
)
primitive = obj.obj_to_primitive('1.31')
self.assertIn('hw_emulation_architecture',
primitive['nova_object.data'])
self.assertEqual(
objects.fields.Architecture.AARCH64,
primitive['nova_object.data']['hw_emulation_architecture'])
# and is absent on older versions
primitive = obj.obj_to_primitive('1.29')
self.assertNotIn('hw_emulation_architecture',
primitive['nova_object.data'])
def test_obj_make_compatible_input_bus(self):
"""Check 'hw_input_bus' compatibility."""
# assert that 'hw_input_bus' is supported on a suitably new version

View File

@ -1072,7 +1072,7 @@ object_data = {
'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0',
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
'ImageMetaProps': '1.30-5bfc3dd01bbfdbb28cb3a096c0b2f383',
'ImageMetaProps': '1.31-27337af769b0c85b4ba4be8aebc1a65d',
'Instance': '2.7-d187aec68cad2e4d8b8a03a68e4739ce',
'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5',
'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',