diff --git a/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json b/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json index dac82f92d4e0..33e71ec36a01 100644 --- a/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json +++ b/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json @@ -4,5 +4,5 @@ "hw_architecture": "x86_64" }, "nova_object.name": "ImageMetaPropsPayload", - "nova_object.version": "1.2" + "nova_object.version": "1.3" } diff --git a/nova/notifications/objects/image.py b/nova/notifications/objects/image.py index 3971a5f1b0ea..107500c5b01b 100644 --- a/nova/notifications/objects/image.py +++ b/nova/notifications/objects/image.py @@ -107,7 +107,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): # Version 1.0: Initial version # Version 1.1: Added 'gop', 'virtio' and 'none' to hw_video_model field # Version 1.2: Added hw_pci_numa_affinity_policy field - VERSION = '1.2' + # Version 1.3: Added hw_mem_encryption, hw_pmu and hw_time_hpet fields + VERSION = '1.3' SCHEMA = { 'hw_architecture': ('image_meta_props', 'hw_architecture'), @@ -130,12 +131,14 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): 'hw_firmware_type': ('image_meta_props', 'hw_firmware_type'), 'hw_ipxe_boot': ('image_meta_props', 'hw_ipxe_boot'), 'hw_machine_type': ('image_meta_props', 'hw_machine_type'), + 'hw_mem_encryption': ('image_meta_props', 'hw_mem_encryption'), 'hw_mem_page_size': ('image_meta_props', 'hw_mem_page_size'), 'hw_numa_nodes': ('image_meta_props', 'hw_numa_nodes'), 'hw_numa_cpus': ('image_meta_props', 'hw_numa_cpus'), 'hw_numa_mem': ('image_meta_props', 'hw_numa_mem'), 'hw_pci_numa_affinity_policy': ('image_meta_props', 'hw_pci_numa_affinity_policy'), + 'hw_pmu': ('image_meta_props', 'hw_pmu'), 'hw_pointer_model': ('image_meta_props', 'hw_pointer_model'), 'hw_qemu_guest_agent': ('image_meta_props', 'hw_qemu_guest_agent'), 'hw_rescue_bus': ('image_meta_props', 'hw_rescue_bus'), @@ -143,6 +146,7 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): 'hw_rng_model': ('image_meta_props', 'hw_rng_model'), 'hw_serial_port_count': ('image_meta_props', 'hw_serial_port_count'), 'hw_scsi_model': ('image_meta_props', 'hw_scsi_model'), + 'hw_time_hpet': ('image_meta_props', 'hw_time_hpet'), 'hw_video_model': ('image_meta_props', 'hw_video_model'), 'hw_video_ram': ('image_meta_props', 'hw_video_ram'), 'hw_vif_model': ('image_meta_props', 'hw_vif_model'), @@ -209,11 +213,13 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): 'hw_firmware_type': fields.FirmwareTypeField(), 'hw_ipxe_boot': fields.FlexibleBooleanField(), 'hw_machine_type': fields.StringField(), + 'hw_mem_encryption': fields.FlexibleBooleanField(), 'hw_mem_page_size': fields.StringField(), 'hw_numa_nodes': fields.IntegerField(), 'hw_numa_cpus': fields.ListOfSetsOfIntegersField(), 'hw_numa_mem': fields.ListOfIntegersField(), 'hw_pci_numa_affinity_policy': fields.PCINUMAAffinityPolicyField(), + 'hw_pmu': fields.FlexibleBooleanField(), 'hw_pointer_model': fields.PointerModelField(), 'hw_qemu_guest_agent': fields.FlexibleBooleanField(), 'hw_rescue_bus': fields.DiskBusField(), @@ -221,6 +227,7 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): 'hw_rng_model': fields.RNGModelField(), 'hw_serial_port_count': fields.IntegerField(), 'hw_scsi_model': fields.SCSIModelField(), + 'hw_time_hpet': fields.FlexibleBooleanField(), 'hw_video_model': fields.VideoModelField(), 'hw_video_ram': fields.IntegerField(), 'hw_vif_model': fields.VIFModelField(), diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index c3d560019e53..5a9347d79cb4 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -1262,7 +1262,7 @@ class TestInstanceNotificationSample( 'nova_object.data': {}, 'nova_object.name': 'ImageMetaPropsPayload', 'nova_object.namespace': 'nova', - 'nova_object.version': u'1.2'}, + 'nova_object.version': u'1.3'}, 'image.size': 58145823, 'image.tags': [], 'scheduler_hints': {'_nova_check_type': ['rebuild']}, @@ -1359,7 +1359,7 @@ class TestInstanceNotificationSample( 'nova_object.data': {}, 'nova_object.name': 'ImageMetaPropsPayload', 'nova_object.namespace': 'nova', - 'nova_object.version': u'1.2'}, + 'nova_object.version': u'1.3'}, 'image.size': 58145823, 'image.tags': [], 'scheduler_hints': {'_nova_check_type': ['rebuild']}, diff --git a/nova/tests/unit/notifications/objects/test_notification.py b/nova/tests/unit/notifications/objects/test_notification.py index 4dbcf23b4946..f67806ddbbc8 100644 --- a/nova/tests/unit/notifications/objects/test_notification.py +++ b/nova/tests/unit/notifications/objects/test_notification.py @@ -20,6 +20,7 @@ from oslo_versionedobjects import fixture from nova import exception from nova.notifications.objects import base as notification +from nova.notifications.objects.image import ImageMetaPropsPayload from nova import objects from nova.objects import base from nova.objects import fields @@ -383,7 +384,7 @@ notification_object_data = { 'FlavorNotification': '1.0-a73147b93b520ff0061865849d3dfa56', 'FlavorPayload': '1.4-2e7011b8b4e59167fe8b7a0a81f0d452', 'ImageMetaPayload': '1.0-0e65beeacb3393beed564a57bc2bc989', - 'ImageMetaPropsPayload': '1.2-f237f65e1f14f05a73481dc4192df3ba', + 'ImageMetaPropsPayload': '1.3-9c200c895932163a4e14e6bb385fa1e0', 'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56', 'InstanceActionPayload': '1.8-4fa3da9cbf0761f1f700ae578f36dc2f', 'InstanceActionRebuildNotification': @@ -479,6 +480,33 @@ class TestNotificationObjectVersions(test.NoDBTestCase): self.assertNotEqual(old_hash, new_hash) +class TestImageMetaPropsPayloadNotifications(test.NoDBTestCase): + def setUp(self): + super().setUp() + base.NovaObjectRegistry.register_notification_objects() + + def test_object_field_sync(self): + """Assert the fields of the ImageMetaPropsPayload object are + in sync with the fields of the ImageMetaProps object. + """ + self.assertEqual( + ImageMetaPropsPayload.fields.keys(), + objects.image_meta.ImageMetaProps.fields.keys()) + + def test_schema_field_sync(self): + """Assert the fields of the ImageMetaPropsPayload object are + in sync with schema definition. + """ + self.assertEqual( + ImageMetaPropsPayload.fields.keys(), + ImageMetaPropsPayload.SCHEMA.keys()) + + def test_schema(self): + """Assert the schema is generated correctly""" + for key, value in ImageMetaPropsPayload.SCHEMA.items(): + self.assertEqual(('image_meta_props', key), value) + + def get_extra_data(obj_class): extra_data = tuple()