From 7893262d62774f39b27a2314bcb5ef6d295ecf7a Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 6 Aug 2018 11:21:56 +0200 Subject: [PATCH] Switch the "snmp" hardware type to "noop" management Support for "fake" is kept for backward compatibility and is deprecated. Change-Id: Ibee573e660e2ba4204ecb68c8d80ad8d1e0b9a74 Story: #2003203 Task: #23361 --- devstack/lib/ironic | 2 +- doc/source/admin/drivers/snmp.rst | 4 ++-- ironic/drivers/modules/fake.py | 12 +++++++++++- ironic/drivers/snmp.py | 3 ++- ironic/tests/unit/drivers/test_snmp.py | 18 ++++++++++++++++-- .../notes/snmp-noop-mgmt-53e93ac3b6dd8517.yaml | 10 ++++++++++ 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/snmp-noop-mgmt-53e93ac3b6dd8517.yaml diff --git a/devstack/lib/ironic b/devstack/lib/ironic index 877e171748..ba2f088ef4 100644 --- a/devstack/lib/ironic +++ b/devstack/lib/ironic @@ -1249,7 +1249,7 @@ function configure_ironic_conductor { # TODO(lucasagomes): We need to make it easier to configure # specific driver interfaces in DevStack iniset $IRONIC_CONF_FILE DEFAULT enabled_power_interfaces "snmp" - iniset $IRONIC_CONF_FILE DEFAULT enabled_management_interfaces "fake" + iniset $IRONIC_CONF_FILE DEFAULT enabled_management_interfaces "noop" fi if is_ansible_deploy_enabled; then diff --git a/doc/source/admin/drivers/snmp.rst b/doc/source/admin/drivers/snmp.rst index 7ee345908e..242c03457e 100644 --- a/doc/source/admin/drivers/snmp.rst +++ b/doc/source/admin/drivers/snmp.rst @@ -12,7 +12,7 @@ deployment and network-configured boot. .. note:: Unlike most of the other power interfaces, the SNMP power interface does not have a corresponding management interface. The SNMP hardware type uses - the ``fake`` management interface instead. + the ``noop`` management interface instead. List of supported devices ========================= @@ -74,7 +74,7 @@ Enabling the SNMP Hardware Type [DEFAULT] enabled_hardware_types = snmp - enabled_management_interfaces = fake + enabled_management_interfaces = noop enabled_power_interfaces = snmp #. To set the default boot option, update ``default_boot_option`` in diff --git a/ironic/drivers/modules/fake.py b/ironic/drivers/modules/fake.py index 680958f024..9abbe6c247 100644 --- a/ironic/drivers/modules/fake.py +++ b/ironic/drivers/modules/fake.py @@ -24,6 +24,8 @@ functionality between a power interface and a deploy interface, when both rely on separate vendor_passthru methods. """ +from oslo_log import log + from ironic.common import boot_devices from ironic.common import exception from ironic.common.i18n import _ @@ -32,6 +34,9 @@ from ironic.drivers import base from ironic import objects +LOG = log.getLogger(__name__) + + class FakePower(base.PowerInterface): """Example implementation of a simple power interface.""" @@ -189,7 +194,12 @@ class FakeManagement(base.ManagementInterface): return {} def validate(self, task): - pass + # TODO(dtantsur): remove when snmp hardware type no longer supports the + # fake management. + if task.node.driver == 'snmp': + LOG.warning('Using "fake" management with "snmp" hardware type ' + 'is deprecated, use "noop" instead for node %s', + task.node.uuid) def get_supported_boot_devices(self, task): return [boot_devices.PXE] diff --git a/ironic/drivers/snmp.py b/ironic/drivers/snmp.py index d5728f5876..c5ed96658e 100644 --- a/ironic/drivers/snmp.py +++ b/ironic/drivers/snmp.py @@ -18,6 +18,7 @@ SNMP hardware types. from ironic.drivers import generic from ironic.drivers.modules import fake +from ironic.drivers.modules import noop_mgmt from ironic.drivers.modules import snmp @@ -32,4 +33,4 @@ class SNMPHardware(generic.GenericHardware): @property def supported_management_interfaces(self): """List of supported management interfaces.""" - return [fake.FakeManagement] + return [noop_mgmt.NoopManagement, fake.FakeManagement] diff --git a/ironic/tests/unit/drivers/test_snmp.py b/ironic/tests/unit/drivers/test_snmp.py index 5d542fa667..e2b941e488 100644 --- a/ironic/tests/unit/drivers/test_snmp.py +++ b/ironic/tests/unit/drivers/test_snmp.py @@ -13,10 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +import mock + from ironic.conductor import task_manager from ironic.drivers.modules import fake 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.drivers.modules import snmp from ironic.tests.unit.db import base as db_base @@ -28,7 +31,7 @@ class SNMPHardwareTestCase(db_base.DbTestCase): def setUp(self): super(SNMPHardwareTestCase, self).setUp() self.config(enabled_hardware_types=['snmp'], - enabled_management_interfaces=['fake'], + enabled_management_interfaces=['noop'], enabled_power_interfaces=['snmp']) def test_default_interfaces(self): @@ -38,6 +41,17 @@ class SNMPHardwareTestCase(db_base.DbTestCase): self.assertIsInstance(task.driver.boot, pxe.PXEBoot) self.assertIsInstance(task.driver.deploy, iscsi_deploy.ISCSIDeploy) self.assertIsInstance(task.driver.management, - fake.FakeManagement) + noop_mgmt.NoopManagement) self.assertIsInstance(task.driver.console, noop.NoConsole) self.assertIsInstance(task.driver.raid, noop.NoRAID) + + @mock.patch.object(fake.LOG, 'warning', autospec=True) + def test_fake_management(self, mock_warn): + self.config(enabled_management_interfaces=['noop', 'fake']) + node = obj_utils.create_test_node(self.context, driver='snmp', + management_interface='fake') + with task_manager.acquire(self.context, node.id) as task: + self.assertIsInstance(task.driver.management, + fake.FakeManagement) + task.driver.management.validate(task) + self.assertTrue(mock_warn.called) diff --git a/releasenotes/notes/snmp-noop-mgmt-53e93ac3b6dd8517.yaml b/releasenotes/notes/snmp-noop-mgmt-53e93ac3b6dd8517.yaml new file mode 100644 index 0000000000..decf7473c6 --- /dev/null +++ b/releasenotes/notes/snmp-noop-mgmt-53e93ac3b6dd8517.yaml @@ -0,0 +1,10 @@ +--- +upgrade: + - | + The ``snmp`` hardware type now uses the ``noop`` management interface + instead of ``fake`` used previously. Support for ``fake`` is left for + backward compatibility. +deprecations: + - | + Using the ``fake`` management interfaces with the ``snmp`` hardware type + is now deprecated, please use ``noop`` instead.