Skip to content

Commit 79887a6

Browse files
committed
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 <[email protected]> Change-Id: If4f598c0d3f9e64617beb54450faa04e7d20dd20
1 parent b2ec3cd commit 79887a6

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

doc/notification_samples/common_payloads/ImageMetaPropsPayload.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"hw_architecture": "x86_64"
55
},
66
"nova_object.name": "ImageMetaPropsPayload",
7-
"nova_object.version": "1.8"
7+
"nova_object.version": "1.9"
88
}

nova/notifications/objects/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase):
125125
# Version 1.6: Added 'socket' to hw_pci_numa_affinity_policy
126126
# Version 1.7: Added 'hw_input_bus' field
127127
# Version 1.8: Added 'bochs' as an option to 'hw_video_model'
128-
VERSION = '1.8'
128+
# Version 1.9: Added 'hw_emulation_architecture' field
129+
VERSION = '1.9'
129130

130131
SCHEMA = {
131132
k: ('image_meta_props', k) for k in image_meta.ImageMetaProps.fields}

nova/objects/image_meta.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,17 @@ class ImageMetaProps(base.NovaObject):
187187
# Version 1.28: Added 'socket' to 'hw_pci_numa_affinity_policy'
188188
# Version 1.29: Added 'hw_input_bus' field
189189
# Version 1.30: Added 'bochs' as an option to 'hw_video_model'
190+
# Version 1.31: Added 'hw_emulation_architecture' field
190191
# NOTE(efried): When bumping this version, the version of
191192
# ImageMetaPropsPayload must also be bumped. See its docstring for details.
192-
VERSION = '1.30'
193+
VERSION = '1.31'
193194

194195
def obj_make_compatible(self, primitive, target_version):
195196
super(ImageMetaProps, self).obj_make_compatible(primitive,
196197
target_version)
197198
target_version = versionutils.convert_version_to_tuple(target_version)
199+
if target_version < (1, 31):
200+
primitive.pop('hw_emulation_architecture', None)
198201
if target_version < (1, 30):
199202
video = primitive.get('hw_video_model', None)
200203
if video == fields.VideoModel.BOCHS:
@@ -294,6 +297,10 @@ def obj_make_compatible(self, primitive, target_version):
294297
# name of guest hardware architecture eg i686, x86_64, ppc64
295298
'hw_architecture': fields.ArchitectureField(),
296299

300+
# hw_architecture field is leveraged for checks against physical nodes
301+
# name of desired emulation architecture eg i686, x86_64, ppc64
302+
'hw_emulation_architecture': fields.ArchitectureField(),
303+
297304
# used to decide to expand root disk partition and fs to full size of
298305
# root disk
299306
'hw_auto_disk_config': fields.StringField(),

nova/tests/functional/notification_sample_tests/test_instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ def test_rebuild_server(self):
12311231
'nova_object.data': {},
12321232
'nova_object.name': 'ImageMetaPropsPayload',
12331233
'nova_object.namespace': 'nova',
1234-
'nova_object.version': '1.8',
1234+
'nova_object.version': '1.9',
12351235
},
12361236
'image.size': 58145823,
12371237
'image.tags': [],
@@ -1327,7 +1327,7 @@ def test_rebuild_server_with_trusted_cert(self):
13271327
'nova_object.data': {},
13281328
'nova_object.name': 'ImageMetaPropsPayload',
13291329
'nova_object.namespace': 'nova',
1330-
'nova_object.version': '1.8',
1330+
'nova_object.version': '1.9',
13311331
},
13321332
'image.size': 58145823,
13331333
'image.tags': [],

nova/tests/unit/notifications/objects/test_notification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def test_payload_is_not_generated_if_notification_format_is_unversioned(
386386
# ImageMetaProps, so when you see a fail here for that reason, you must
387387
# *also* bump the version of ImageMetaPropsPayload. See its docstring for
388388
# more information.
389-
'ImageMetaPropsPayload': '1.8-080bdcba9b96122eab57bf39d47348f7',
389+
'ImageMetaPropsPayload': '1.9-24a851511d98e652aebd3536e7e08330',
390390
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
391391
'InstanceActionPayload': '1.8-4fa3da9cbf0761f1f700ae578f36dc2f',
392392
'InstanceActionRebuildNotification':

nova/tests/unit/objects/test_image_meta.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,25 @@ def test_obj_make_compatible(self):
349349
self.assertRaises(exception.ObjectActionError,
350350
obj.obj_to_primitive, '1.0')
351351

352+
def test_obj_make_compatible_hw_emulation(self):
353+
"""Check 'hw_emulation_architecture' compatibility."""
354+
# assert that 'hw_emulation_architecture' is supported
355+
# on a suitably new version
356+
obj = objects.ImageMetaProps(
357+
hw_emulation_architecture=objects.fields.Architecture.AARCH64,
358+
)
359+
primitive = obj.obj_to_primitive('1.31')
360+
self.assertIn('hw_emulation_architecture',
361+
primitive['nova_object.data'])
362+
self.assertEqual(
363+
objects.fields.Architecture.AARCH64,
364+
primitive['nova_object.data']['hw_emulation_architecture'])
365+
366+
# and is absent on older versions
367+
primitive = obj.obj_to_primitive('1.29')
368+
self.assertNotIn('hw_emulation_architecture',
369+
primitive['nova_object.data'])
370+
352371
def test_obj_make_compatible_input_bus(self):
353372
"""Check 'hw_input_bus' compatibility."""
354373
# assert that 'hw_input_bus' is supported on a suitably new version

nova/tests/unit/objects/test_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ def obj_name(cls):
10721072
'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0',
10731073
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
10741074
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
1075-
'ImageMetaProps': '1.30-5bfc3dd01bbfdbb28cb3a096c0b2f383',
1075+
'ImageMetaProps': '1.31-27337af769b0c85b4ba4be8aebc1a65d',
10761076
'Instance': '2.7-d187aec68cad2e4d8b8a03a68e4739ce',
10771077
'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5',
10781078
'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',

0 commit comments

Comments
 (0)