Merge "Remove the fake_ipmitool, fake_ipmitool_socat and fake_snmp drivers"

This commit is contained in:
Zuul 2018-06-13 12:14:22 +00:00 committed by Gerrit Code Review
commit 643422b4d6
6 changed files with 321 additions and 425 deletions

View File

@ -33,62 +33,16 @@ from ironic.drivers.modules import fake
from ironic.drivers.modules.ilo import inspect as ilo_inspect
from ironic.drivers.modules.ilo import management as ilo_management
from ironic.drivers.modules.ilo import power as ilo_power
from ironic.drivers.modules import ipmitool
from ironic.drivers.modules.irmc import inspect as irmc_inspect
from ironic.drivers.modules.irmc import management as irmc_management
from ironic.drivers.modules.irmc import power as irmc_power
from ironic.drivers.modules import iscsi_deploy
from ironic.drivers.modules.oneview import management as oneview_management
from ironic.drivers.modules.oneview import power as oneview_power
from ironic.drivers.modules import snmp
from ironic.drivers.modules.ucs import management as ucs_mgmt
from ironic.drivers.modules.ucs import power as ucs_power
class FakeIPMIToolDriver(base.BaseDriver):
"""Example implementation of a Driver."""
def __init__(self):
self.power = ipmitool.IPMIPower()
self.console = ipmitool.IPMIShellinaboxConsole()
self.deploy = fake.FakeDeploy()
self.vendor = ipmitool.VendorPassthru()
self.management = ipmitool.IPMIManagement()
@classmethod
def to_hardware_type(cls):
return 'fake-hardware', {
'boot': 'fake',
'console': 'ipmitool-shellinabox',
'deploy': 'fake',
'management': 'ipmitool',
'power': 'ipmitool',
'vendor': 'ipmitool'
}
class FakeIPMIToolSocatDriver(base.BaseDriver):
"""Example implementation of a Driver."""
def __init__(self):
self.power = ipmitool.IPMIPower()
self.console = ipmitool.IPMISocatConsole()
self.deploy = fake.FakeDeploy()
self.vendor = ipmitool.VendorPassthru()
self.management = ipmitool.IPMIManagement()
@classmethod
def to_hardware_type(cls):
return 'fake-hardware', {
'boot': 'fake',
'console': 'ipmitool-socat',
'deploy': 'fake',
'management': 'ipmitool',
'power': 'ipmitool',
'vendor': 'ipmitool'
}
class FakeIloDriver(base.BaseDriver):
"""Fake iLO driver, used in testing."""
@ -145,27 +99,6 @@ class FakeDracDriver(base.BaseDriver):
}
class FakeSNMPDriver(base.BaseDriver):
"""Fake SNMP driver."""
def __init__(self):
if not importutils.try_import('pysnmp'):
raise exception.DriverLoadError(
driver=self.__class__.__name__,
reason=_("Unable to import pysnmp library"))
self.power = snmp.SNMPPower()
self.deploy = fake.FakeDeploy()
@classmethod
def to_hardware_type(cls):
return 'fake-hardware', {
'boot': 'fake',
'deploy': 'fake',
'management': 'fake',
'power': 'snmp',
}
class FakeIRMCDriver(base.BaseDriver):
"""Fake iRMC driver."""

View File

@ -14,7 +14,6 @@ import mock
from oslo_config import cfg
from oslo_utils import uuidutils
from ironic.common import driver_factory
from ironic.common import exception
from ironic.common import network
from ironic.common import states
@ -55,51 +54,27 @@ class NodeSetBootDeviceTestCase(db_base.DbTestCase):
def setUp(self):
super(NodeSetBootDeviceTestCase, self).setUp()
self.config(enabled_drivers=['fake_ipmitool'])
self.driver = driver_factory.get_driver("fake_ipmitool")
self.node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid())
self.task = task_manager.TaskManager(self.context, self.node.uuid)
def test_node_set_boot_device_non_existent_device(self):
ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool',
driver_info=ipmi_info)
task = task_manager.TaskManager(self.context, node.uuid)
self.assertRaises(exception.InvalidParameterValue,
conductor_utils.node_set_boot_device,
task,
self.task,
device='fake')
def test_node_set_boot_device_valid(self):
ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool',
driver_info=ipmi_info)
task = task_manager.TaskManager(self.context, node.uuid)
@mock.patch.object(fake.FakeManagement, 'set_boot_device', autospec=True)
def test_node_set_boot_device_valid(self, mock_sbd):
conductor_utils.node_set_boot_device(self.task, device='pxe')
mock_sbd.assert_called_once_with(mock.ANY, self.task,
device='pxe', persistent=False)
with mock.patch.object(self.driver.management,
'set_boot_device') as mock_sbd:
conductor_utils.node_set_boot_device(task,
device='pxe')
mock_sbd.assert_called_once_with(task,
device='pxe',
persistent=False)
def test_node_set_boot_device_adopting(self):
ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool',
driver_info=ipmi_info,
provision_state=states.ADOPTING)
task = task_manager.TaskManager(self.context, node.uuid)
with mock.patch.object(self.driver.management,
'set_boot_device') as mock_sbd:
conductor_utils.node_set_boot_device(task,
device='pxe')
self.assertFalse(mock_sbd.called)
@mock.patch.object(fake.FakeManagement, 'set_boot_device', autospec=True)
def test_node_set_boot_device_adopting(self, mock_sbd):
self.task.node.provision_state = states.ADOPTING
conductor_utils.node_set_boot_device(self.task, device='pxe')
self.assertFalse(mock_sbd.called)
class NodePowerActionTestCase(db_base.DbTestCase):

File diff suppressed because it is too large Load Diff

View File

@ -447,9 +447,10 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase):
def setUp(self):
super(SNMPDeviceDriverTestCase, self).setUp()
self.config(enabled_power_interfaces=['fake', 'snmp'])
self.node = obj_utils.get_test_node(
self.context,
driver='fake_snmp',
power_interface='snmp',
driver_info=INFO_DICT)
def _update_driver_info(self, **kwargs):
@ -1219,10 +1220,11 @@ class SNMPDriverTestCase(db_base.DbTestCase):
def setUp(self):
super(SNMPDriverTestCase, self).setUp()
self.config(enabled_drivers=['fake_snmp'])
self.config(enabled_power_interfaces=['fake', 'snmp'])
self.node = obj_utils.create_test_node(self.context,
driver='fake_snmp',
power_interface='snmp',
vendor_interface='no-vendor',
driver_info=INFO_DICT)
def _get_snmp_failure(self):

View File

@ -6,7 +6,10 @@ upgrade:
* ``fake``
* ``fake_agent``
* ``fake_inspector``
* ``fake_ipmitool``
* ``fake_ipmitool_socat``
* ``fake_pxe``
* ``fake_snmp``
* ``fake_soft_power``
Please use the ``fake-hardware`` hardware type instead.

View File

@ -59,11 +59,8 @@ ironic.drivers =
agent_irmc = ironic.drivers.irmc:IRMCVirtualMediaAgentDriver
agent_pxe_oneview = ironic.drivers.oneview:AgentPXEOneViewDriver
agent_ucs = ironic.drivers.agent:AgentAndUcsDriver
fake_ipmitool = ironic.drivers.fake:FakeIPMIToolDriver
fake_ipmitool_socat = ironic.drivers.fake:FakeIPMIToolSocatDriver
fake_ilo = ironic.drivers.fake:FakeIloDriver
fake_drac = ironic.drivers.fake:FakeDracDriver
fake_snmp = ironic.drivers.fake:FakeSNMPDriver
fake_irmc = ironic.drivers.fake:FakeIRMCDriver
fake_ucs = ironic.drivers.fake:FakeUcsDriver
fake_cimc = ironic.drivers.fake:FakeCIMCDriver