From 1b295f2f95974d1f16dcbf11a84a52a63ad7f29c Mon Sep 17 00:00:00 2001 From: Zenghui Shi Date: Thu, 21 Jun 2018 16:27:15 +0800 Subject: [PATCH] BIOS Settings: add bios_interface field in NodePayload This patch also increments the object versions for all objects that inherit the NodePayload object. Change-Id: I9d986b5a40b185abd6fc694dc26395e8b5da7b72 --- doc/source/admin/notifications.rst | 6 ++++-- ironic/objects/node.py | 22 ++++++++++++---------- ironic/tests/unit/objects/test_node.py | 1 + ironic/tests/unit/objects/test_objects.py | 10 +++++----- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/source/admin/notifications.rst b/doc/source/admin/notifications.rst index 4304f5097c..04a87db18a 100644 --- a/doc/source/admin/notifications.rst +++ b/doc/source/admin/notifications.rst @@ -359,7 +359,7 @@ node maintenance notification:: "payload":{ "ironic_object.namespace":"ironic", "ironic_object.name":"NodePayload", - "ironic_object.version":"1.7", + "ironic_object.version":"1.8", "ironic_object.data":{ "clean_step": None, "console_enabled": False, @@ -374,6 +374,7 @@ node maintenance notification:: "maintenance": True, "maintenance_reason": "hw upgrade", "fault": None, + "bios_interface": "no-bios", "boot_interface": "pxe", "console_interface": "no-console", "deploy_interface": "iscsi", @@ -439,7 +440,7 @@ level, "error" has ERROR. Example of node console notification:: "payload":{ "ironic_object.namespace":"ironic", "ironic_object.name":"NodePayload", - "ironic_object.version":"1.7", + "ironic_object.version":"1.8", "ironic_object.data":{ "clean_step": None, "console_enabled": True, @@ -454,6 +455,7 @@ level, "error" has ERROR. Example of node console notification:: "maintenance": False, "maintenance_reason": None, "fault": None, + "bios_interface": "no-bios", "boot_interface": "pxe", "console_interface": "no-console", "deploy_interface": "iscsi", diff --git a/ironic/objects/node.py b/ironic/objects/node.py index 4c942be248..46f129053d 100644 --- a/ironic/objects/node.py +++ b/ironic/objects/node.py @@ -574,6 +574,7 @@ class NodePayload(notification.NotificationPayloadBase): 'maintenance_reason': ('node', 'maintenance_reason'), 'fault': ('node', 'fault'), 'name': ('node', 'name'), + 'bios_interface': ('node', 'bios_interface'), 'boot_interface': ('node', 'boot_interface'), 'console_interface': ('node', 'console_interface'), 'deploy_interface': ('node', 'deploy_interface'), @@ -596,11 +597,6 @@ class NodePayload(notification.NotificationPayloadBase): 'uuid': ('node', 'uuid') } - # TODO(zshi): At a later point in time, once bios_interface is able - # to be leveraged, we need to add the bios_interface field to payload - # and increment the object versions for all objects that inherit the - # NodePayload object. - # Version 1.0: Initial version, based off of Node version 1.18. # Version 1.1: Type of network_interface changed to just nullable string # similar to version 1.20 of Node. @@ -610,7 +606,8 @@ class NodePayload(notification.NotificationPayloadBase): # Version 1.5: Add rescue interface field exposed via API. # Version 1.6: Add traits field exposed via API. # Version 1.7: Add fault field exposed via API. - VERSION = '1.7' + # Version 1.8: Add bios interface field exposed via API. + VERSION = '1.8' fields = { 'clean_step': object_fields.FlexibleDictField(nullable=True), 'console_enabled': object_fields.BooleanField(nullable=True), @@ -624,6 +621,7 @@ class NodePayload(notification.NotificationPayloadBase): 'maintenance': object_fields.BooleanField(nullable=True), 'maintenance_reason': object_fields.StringField(nullable=True), 'fault': object_fields.StringField(nullable=True), + 'bios_interface': object_fields.StringField(nullable=True), 'boot_interface': object_fields.StringField(nullable=True), 'console_interface': object_fields.StringField(nullable=True), 'deploy_interface': object_fields.StringField(nullable=True), @@ -681,7 +679,8 @@ class NodeSetPowerStatePayload(NodePayload): # Version 1.5: Parent NodePayload version 1.5 # Version 1.6: Parent NodePayload version 1.6 # Version 1.7: Parent NodePayload version 1.7 - VERSION = '1.7' + # Version 1.8: Parent NodePayload version 1.8 + VERSION = '1.8' fields = { # "to_power" indicates the future target_power_state of the node. A @@ -729,7 +728,8 @@ class NodeCorrectedPowerStatePayload(NodePayload): # Version 1.5: Parent NodePayload version 1.5 # Version 1.6: Parent NodePayload version 1.6 # Version 1.7: Parent NodePayload version 1.7 - VERSION = '1.7' + # Version 1.8: Parent NodePayload version 1.8 + VERSION = '1.8' fields = { 'from_power': object_fields.StringField(nullable=True) @@ -761,7 +761,8 @@ class NodeSetProvisionStatePayload(NodePayload): # Version 1.4: Parent NodePayload version 1.4 # Version 1.6: Parent NodePayload version 1.6 # Version 1.7: Parent NodePayload version 1.7 - VERSION = '1.7' + # Version 1.8: Parent NodePayload version 1.8 + VERSION = '1.8' SCHEMA = dict(NodePayload.SCHEMA, **{'instance_info': ('node', 'instance_info')}) @@ -800,7 +801,8 @@ class NodeCRUDPayload(NodePayload): # Version 1.3: Parent NodePayload version 1.5 # Version 1.4: Parent NodePayload version 1.6 # Version 1.5: Parent NodePayload version 1.7 - VERSION = '1.5' + # Version 1.6: Parent NodePayload version 1.8 + VERSION = '1.6' SCHEMA = dict(NodePayload.SCHEMA, **{'instance_info': ('node', 'instance_info'), diff --git a/ironic/tests/unit/objects/test_node.py b/ironic/tests/unit/objects/test_node.py index 731857655d..29f7d14621 100644 --- a/ironic/tests/unit/objects/test_node.py +++ b/ironic/tests/unit/objects/test_node.py @@ -637,6 +637,7 @@ class TestNodePayloads(db_base.DbTestCase): self.assertEqual(self.node.maintenance_reason, payload.maintenance_reason) self.assertEqual(self.node.fault, payload.fault) + self.assertEqual(self.node.bios_interface, payload.bios_interface) self.assertEqual(self.node.boot_interface, payload.boot_interface) self.assertEqual(self.node.console_interface, payload.console_interface) diff --git a/ironic/tests/unit/objects/test_objects.py b/ironic/tests/unit/objects/test_objects.py index ca6ab14644..77f7d643bb 100644 --- a/ironic/tests/unit/objects/test_objects.py +++ b/ironic/tests/unit/objects/test_objects.py @@ -672,21 +672,21 @@ expected_object_fingerprints = { 'Conductor': '1.2-5091f249719d4a465062a1b3dc7f860d', 'EventType': '1.1-aa2ba1afd38553e3880c267404e8d370', 'NotificationPublisher': '1.0-51a09397d6c0687771fb5be9a999605d', - 'NodePayload': '1.7-92b1f4f4a51da73a7c0e3315c0323a92', + 'NodePayload': '1.8-2c327dfc77ce8c7a28b02eafaed509f0', 'NodeSetPowerStateNotification': '1.0-59acc533c11d306f149846f922739c15', - 'NodeSetPowerStatePayload': '1.7-bc9a66836bb4148430195f06de0f793a', + 'NodeSetPowerStatePayload': '1.8-916c39939609254de1f8050a1c8da7d1', 'NodeCorrectedPowerStateNotification': '1.0-59acc533c11d306f149846f922739c15', - 'NodeCorrectedPowerStatePayload': '1.7-64862912ca81c0f8de5500503d41213d', + 'NodeCorrectedPowerStatePayload': '1.8-1afef2b5c0538941defa00232302cd89', 'NodeSetProvisionStateNotification': '1.0-59acc533c11d306f149846f922739c15', - 'NodeSetProvisionStatePayload': '1.7-9623c21aef3bff2f85de925396a2318b', + 'NodeSetProvisionStatePayload': '1.8-d4aa7eb5a449e9f8271b3127a2d2b6ea', 'VolumeConnector': '1.0-3e0252c0ab6e6b9d158d09238a577d97', 'VolumeTarget': '1.0-0b10d663d8dae675900b2c7548f76f5e', 'ChassisCRUDNotification': '1.0-59acc533c11d306f149846f922739c15', 'ChassisCRUDPayload': '1.0-dce63895d8186279a7dd577cffccb202', 'NodeCRUDNotification': '1.0-59acc533c11d306f149846f922739c15', - 'NodeCRUDPayload': '1.5-40579bb4bb159b6cc4f3d9fdd24ef919', + 'NodeCRUDPayload': '1.6-3ab7db0fc4574999fca91a1f04b4998f', 'PortCRUDNotification': '1.0-59acc533c11d306f149846f922739c15', 'PortCRUDPayload': '1.2-233d259df442eb15cc584fae1fe81504', 'NodeMaintenanceNotification': '1.0-59acc533c11d306f149846f922739c15',