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
This commit is contained in:
Dmitry Tantsur 2018-08-06 11:21:56 +02:00
parent d42bd9a77b
commit 7893262d62
6 changed files with 42 additions and 7 deletions

View File

@ -1249,7 +1249,7 @@ function configure_ironic_conductor {
# TODO(lucasagomes): We need to make it easier to configure # TODO(lucasagomes): We need to make it easier to configure
# specific driver interfaces in DevStack # specific driver interfaces in DevStack
iniset $IRONIC_CONF_FILE DEFAULT enabled_power_interfaces "snmp" 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 fi
if is_ansible_deploy_enabled; then if is_ansible_deploy_enabled; then

View File

@ -12,7 +12,7 @@ deployment and network-configured boot.
.. note:: .. note::
Unlike most of the other power interfaces, the SNMP power interface does Unlike most of the other power interfaces, the SNMP power interface does
not have a corresponding management interface. The SNMP hardware type uses 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 List of supported devices
========================= =========================
@ -74,7 +74,7 @@ Enabling the SNMP Hardware Type
[DEFAULT] [DEFAULT]
enabled_hardware_types = snmp enabled_hardware_types = snmp
enabled_management_interfaces = fake enabled_management_interfaces = noop
enabled_power_interfaces = snmp enabled_power_interfaces = snmp
#. To set the default boot option, update ``default_boot_option`` in #. To set the default boot option, update ``default_boot_option`` in

View File

@ -24,6 +24,8 @@ functionality between a power interface and a deploy interface, when both rely
on separate vendor_passthru methods. on separate vendor_passthru methods.
""" """
from oslo_log import log
from ironic.common import boot_devices from ironic.common import boot_devices
from ironic.common import exception from ironic.common import exception
from ironic.common.i18n import _ from ironic.common.i18n import _
@ -32,6 +34,9 @@ from ironic.drivers import base
from ironic import objects from ironic import objects
LOG = log.getLogger(__name__)
class FakePower(base.PowerInterface): class FakePower(base.PowerInterface):
"""Example implementation of a simple power interface.""" """Example implementation of a simple power interface."""
@ -189,7 +194,12 @@ class FakeManagement(base.ManagementInterface):
return {} return {}
def validate(self, task): 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): def get_supported_boot_devices(self, task):
return [boot_devices.PXE] return [boot_devices.PXE]

View File

@ -18,6 +18,7 @@ SNMP hardware types.
from ironic.drivers import generic from ironic.drivers import generic
from ironic.drivers.modules import fake from ironic.drivers.modules import fake
from ironic.drivers.modules import noop_mgmt
from ironic.drivers.modules import snmp from ironic.drivers.modules import snmp
@ -32,4 +33,4 @@ class SNMPHardware(generic.GenericHardware):
@property @property
def supported_management_interfaces(self): def supported_management_interfaces(self):
"""List of supported management interfaces.""" """List of supported management interfaces."""
return [fake.FakeManagement] return [noop_mgmt.NoopManagement, fake.FakeManagement]

View File

@ -13,10 +13,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
from ironic.conductor import task_manager from ironic.conductor import task_manager
from ironic.drivers.modules import fake from ironic.drivers.modules import fake
from ironic.drivers.modules import iscsi_deploy from ironic.drivers.modules import iscsi_deploy
from ironic.drivers.modules import noop from ironic.drivers.modules import noop
from ironic.drivers.modules import noop_mgmt
from ironic.drivers.modules import pxe from ironic.drivers.modules import pxe
from ironic.drivers.modules import snmp from ironic.drivers.modules import snmp
from ironic.tests.unit.db import base as db_base from ironic.tests.unit.db import base as db_base
@ -28,7 +31,7 @@ class SNMPHardwareTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(SNMPHardwareTestCase, self).setUp() super(SNMPHardwareTestCase, self).setUp()
self.config(enabled_hardware_types=['snmp'], self.config(enabled_hardware_types=['snmp'],
enabled_management_interfaces=['fake'], enabled_management_interfaces=['noop'],
enabled_power_interfaces=['snmp']) enabled_power_interfaces=['snmp'])
def test_default_interfaces(self): 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.boot, pxe.PXEBoot)
self.assertIsInstance(task.driver.deploy, iscsi_deploy.ISCSIDeploy) self.assertIsInstance(task.driver.deploy, iscsi_deploy.ISCSIDeploy)
self.assertIsInstance(task.driver.management, self.assertIsInstance(task.driver.management,
fake.FakeManagement) noop_mgmt.NoopManagement)
self.assertIsInstance(task.driver.console, noop.NoConsole) self.assertIsInstance(task.driver.console, noop.NoConsole)
self.assertIsInstance(task.driver.raid, noop.NoRAID) 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)

View File

@ -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.