From 1aecb07b6f711dbe50575576f5201fc0f2e8ff66 Mon Sep 17 00:00:00 2001
From: Dmitry Tantsur <divius.inside@gmail.com>
Date: Mon, 19 Nov 2018 18:29:02 +0100
Subject: [PATCH] Add the noop management interface to the manual-management
 hardware type

The current fake management interface fails when setting boot device to
disk, which makes manual-management unusable with boot_option:local.
As always with the noop management, we expect an operator to correctly
configure the boot order (e.g. to PXE with fall back to disk).

Change-Id: I551efa1a23dd3d6b33401610f298f436e8317539
---
 ironic/drivers/generic.py                          |  3 ++-
 ironic/tests/unit/drivers/test_generic.py          |  7 +++++--
 releasenotes/notes/noop-mgmt-a4b1a248492c7638.yaml | 11 +++++++++++
 3 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 releasenotes/notes/noop-mgmt-a4b1a248492c7638.yaml

diff --git a/ironic/drivers/generic.py b/ironic/drivers/generic.py
index 7f9c402815..1e7a83c4b8 100644
--- a/ironic/drivers/generic.py
+++ b/ironic/drivers/generic.py
@@ -27,6 +27,7 @@ from ironic.drivers.modules.network import flat as flat_net
 from ironic.drivers.modules.network import neutron
 from ironic.drivers.modules.network import noop as noop_net
 from ironic.drivers.modules import noop
+from ironic.drivers.modules import noop_mgmt
 from ironic.drivers.modules import pxe
 from ironic.drivers.modules.storage import cinder
 from ironic.drivers.modules.storage import external as external_storage
@@ -96,7 +97,7 @@ class ManualManagementHardware(GenericHardware):
     @property
     def supported_management_interfaces(self):
         """List of supported management interfaces."""
-        return [fake.FakeManagement]
+        return [noop_mgmt.NoopManagement, fake.FakeManagement]
 
     @property
     def supported_power_interfaces(self):
diff --git a/ironic/tests/unit/drivers/test_generic.py b/ironic/tests/unit/drivers/test_generic.py
index 0453eaa680..6eef22d4e6 100644
--- a/ironic/tests/unit/drivers/test_generic.py
+++ b/ironic/tests/unit/drivers/test_generic.py
@@ -23,6 +23,7 @@ from ironic.drivers.modules import fake
 from ironic.drivers.modules import inspector
 from ironic.drivers.modules import iscsi_deploy
 from ironic.drivers.modules import noop
+from ironic.drivers.modules import noop_mgmt
 from ironic.drivers.modules import pxe
 from ironic.tests.unit.db import base as db_base
 from ironic.tests.unit.objects import utils as obj_utils
@@ -34,14 +35,15 @@ class ManualManagementHardwareTestCase(db_base.DbTestCase):
         super(ManualManagementHardwareTestCase, self).setUp()
         self.config(enabled_hardware_types=['manual-management'],
                     enabled_power_interfaces=['fake'],
-                    enabled_management_interfaces=['fake'])
+                    enabled_management_interfaces=['noop', 'fake'])
         self.config(enabled=True, group='inspector')
 
     def test_default_interfaces(self):
         node = obj_utils.create_test_node(self.context,
                                           driver='manual-management')
         with task_manager.acquire(self.context, node.id) as task:
-            self.assertIsInstance(task.driver.management, fake.FakeManagement)
+            self.assertIsInstance(task.driver.management,
+                                  noop_mgmt.NoopManagement)
             self.assertIsInstance(task.driver.power, fake.FakePower)
             self.assertIsInstance(task.driver.boot, pxe.PXEBoot)
             self.assertIsInstance(task.driver.deploy, iscsi_deploy.ISCSIDeploy)
@@ -53,6 +55,7 @@ class ManualManagementHardwareTestCase(db_base.DbTestCase):
                     enabled_raid_interfaces=['agent'])
         node = obj_utils.create_test_node(self.context,
                                           driver='manual-management',
+                                          management_interface='fake',
                                           deploy_interface='direct',
                                           raid_interface='agent')
         with task_manager.acquire(self.context, node.id) as task:
diff --git a/releasenotes/notes/noop-mgmt-a4b1a248492c7638.yaml b/releasenotes/notes/noop-mgmt-a4b1a248492c7638.yaml
new file mode 100644
index 0000000000..82ea219f85
--- /dev/null
+++ b/releasenotes/notes/noop-mgmt-a4b1a248492c7638.yaml
@@ -0,0 +1,11 @@
+---
+deprecations:
+  - |
+    Using the ``fake`` management interface with the ``manual-management``
+    hardware type is deprecated, please use ``noop`` instead. Existing nodes
+    will have to be updated after the upgrade.
+fixes:
+  - |
+    The ``manual-management`` hardware type now defaults to the ``noop``
+    management interface. Unlike the ``fake`` management interface, it does
+    not fail on attempt to set the boot device to the local disk.