From 6c8dad9465af138eb8c8c387af1f42e723310e26 Mon Sep 17 00:00:00 2001
From: Dmitry Tantsur <dtantsur@protonmail.com>
Date: Tue, 2 Feb 2021 11:40:14 +0100
Subject: [PATCH] ilo: do not change deploy_boot_mode in instance_info

instance_info is the input from an operator, we should not change that.
Use driver_internal_info instead.

Change-Id: I12b4bc0d4599ccf5ef6fdca91f54f4294b127f9d
---
 ironic/drivers/modules/ilo/boot.py             |  6 +++---
 ironic/drivers/modules/ilo/common.py           | 12 ++++++------
 .../unit/drivers/modules/ilo/test_boot.py      |  8 +++++---
 .../unit/drivers/modules/ilo/test_common.py    | 18 +++++++++---------
 4 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/ironic/drivers/modules/ilo/boot.py b/ironic/drivers/modules/ilo/boot.py
index c0e0411084..71e34a3117 100644
--- a/ironic/drivers/modules/ilo/boot.py
+++ b/ironic/drivers/modules/ilo/boot.py
@@ -318,9 +318,9 @@ def prepare_node_for_deploy(task):
         # not provided.
         # Since secure boot was disabled, we are in 'uefi' boot mode.
         if boot_mode_utils.get_boot_mode_for_deploy(task.node) is None:
-            instance_info = task.node.instance_info
-            instance_info['deploy_boot_mode'] = 'uefi'
-            task.node.instance_info = instance_info
+            driver_internal_info = task.node.driver_internal_info
+            driver_internal_info['deploy_boot_mode'] = 'uefi'
+            task.node.driver_internal_info = driver_internal_info
             task.node.save()
 
 
diff --git a/ironic/drivers/modules/ilo/common.py b/ironic/drivers/modules/ilo/common.py
index d76d4a04ae..202aa25108 100644
--- a/ironic/drivers/modules/ilo/common.py
+++ b/ironic/drivers/modules/ilo/common.py
@@ -597,9 +597,9 @@ def update_boot_mode(task):
     # No boot mode found. Check if default_boot_mode is defined
     if not boot_mode and (CONF.ilo.default_boot_mode in ['bios', 'uefi']):
         boot_mode = CONF.ilo.default_boot_mode
-        instance_info = node.instance_info
-        instance_info['deploy_boot_mode'] = boot_mode
-        node.instance_info = instance_info
+        driver_internal_info = node.driver_internal_info
+        driver_internal_info['deploy_boot_mode'] = boot_mode
+        node.driver_internal_info = driver_internal_info
         node.save()
 
     # Boot mode is computed, setting it for the deploy
@@ -639,9 +639,9 @@ def update_boot_mode(task):
                   "as pending boot mode is unknown.",
                   {'uuid': node.uuid, 'boot_mode': boot_mode})
 
-    instance_info = node.instance_info
-    instance_info['deploy_boot_mode'] = boot_mode
-    node.instance_info = instance_info
+    driver_internal_info = node.driver_internal_info
+    driver_internal_info['deploy_boot_mode'] = boot_mode
+    node.driver_internal_info = driver_internal_info
     node.save()
 
 
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_boot.py b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
index c598415cf5..6aa698578f 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
@@ -354,7 +354,7 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
                                                            states.POWER_OFF)
             func_disable_secure_boot.assert_called_once_with(task)
             self.assertFalse(func_update_boot_mode.called)
-            ret_boot_mode = task.node.instance_info['deploy_boot_mode']
+            ret_boot_mode = task.node.driver_internal_info['deploy_boot_mode']
             self.assertEqual('uefi', ret_boot_mode)
             bootmode = driver_utils.get_node_capability(task.node, "boot_mode")
             self.assertIsNone(bootmode)
@@ -381,7 +381,8 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
             func_update_boot_mode.assert_called_once_with(task)
             bootmode = driver_utils.get_node_capability(task.node, "boot_mode")
             self.assertIsNone(bootmode)
-            self.assertNotIn('deploy_boot_mode', task.node.instance_info)
+            self.assertNotIn('deploy_boot_mode',
+                             task.node.driver_internal_info)
 
     @mock.patch.object(ilo_common, 'update_boot_mode', spec_set=True,
                        autospec=True)
@@ -404,7 +405,8 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
             self.assertFalse(func_update_boot_mode.called)
             bootmode = driver_utils.get_node_capability(task.node, "boot_mode")
             self.assertIsNone(bootmode)
-            self.assertNotIn('deploy_boot_mode', task.node.instance_info)
+            self.assertNotIn('deploy_boot_mode',
+                             task.node.driver_internal_info)
 
 
 class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_common.py b/ironic/tests/unit/drivers/modules/ilo/test_common.py
index c8adbf93f7..30dad59846 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_common.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_common.py
@@ -540,7 +540,7 @@ class IloCommonMethodsTestCase(BaseIloTest):
                                                    set_boot_mode_mock):
         with task_manager.acquire(self.context, self.node.uuid,
                                   shared=False) as task:
-            task.node.instance_info['deploy_boot_mode'] = 'bios'
+            task.node.driver_internal_info['deploy_boot_mode'] = 'bios'
             ilo_common.update_boot_mode(task)
             set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
 
@@ -563,8 +563,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
                                   shared=False) as task:
             ilo_common.update_boot_mode(task)
             set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
-            self.assertEqual('bios',
-                             task.node.instance_info['deploy_boot_mode'])
+            self.assertEqual(
+                'bios', task.node.driver_internal_info['deploy_boot_mode'])
 
     @mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
                        autospec=True)
@@ -578,8 +578,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
             ilo_common.update_boot_mode(task)
             get_ilo_object_mock.assert_called_once_with(task.node)
             ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
-            self.assertEqual('bios',
-                             task.node.instance_info['deploy_boot_mode'])
+            self.assertEqual(
+                'bios', task.node.driver_internal_info['deploy_boot_mode'])
 
     @mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
                        autospec=True)
@@ -595,8 +595,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
             get_ilo_object_mock.assert_called_once_with(task.node)
             ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
             set_pending_boot_mode_mock.assert_called_once_with('UEFI')
-            self.assertEqual('uefi',
-                             task.node.instance_info['deploy_boot_mode'])
+            self.assertEqual(
+                'uefi', task.node.driver_internal_info['deploy_boot_mode'])
 
     @mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
                        autospec=True)
@@ -628,8 +628,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
             ilo_common.update_boot_mode(task)
             get_ilo_object_mock.assert_called_once_with(task.node)
             ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
-            self.assertEqual('bios',
-                             task.node.instance_info['deploy_boot_mode'])
+            self.assertEqual(
+                'bios', task.node.driver_internal_info['deploy_boot_mode'])
 
     @mock.patch.object(ilo_common, 'set_boot_mode', spec_set=True,
                        autospec=True)