Add missing noop implementations to fake-hardware

Currently operators have to enable all fake interfaces even if
they don't plan on using them.

Change-Id: If6cf0194f199b395388ed837cb4d46d51a1dd893
Closes-Bug: #1749256
This commit is contained in:
Dmitry Tantsur 2018-02-13 19:07:32 +01:00
parent 180277a65a
commit ce5fd966a0
3 changed files with 22 additions and 14 deletions

View File

@ -18,6 +18,8 @@ Fake hardware type.
from ironic.drivers import hardware_type from ironic.drivers import hardware_type
from ironic.drivers.modules import fake from ironic.drivers.modules import fake
from ironic.drivers.modules import noop
from ironic.drivers.modules.storage import noop as noop_storage
class FakeHardware(hardware_type.AbstractHardwareType): class FakeHardware(hardware_type.AbstractHardwareType):
@ -39,7 +41,7 @@ class FakeHardware(hardware_type.AbstractHardwareType):
@property @property
def supported_console_interfaces(self): def supported_console_interfaces(self):
"""List of classes of supported console interfaces.""" """List of classes of supported console interfaces."""
return [fake.FakeConsole] return [fake.FakeConsole, noop.NoConsole]
@property @property
def supported_deploy_interfaces(self): def supported_deploy_interfaces(self):
@ -49,7 +51,7 @@ class FakeHardware(hardware_type.AbstractHardwareType):
@property @property
def supported_inspect_interfaces(self): def supported_inspect_interfaces(self):
"""List of classes of supported inspect interfaces.""" """List of classes of supported inspect interfaces."""
return [fake.FakeInspect] return [fake.FakeInspect, noop.NoInspect]
@property @property
def supported_management_interfaces(self): def supported_management_interfaces(self):
@ -64,22 +66,22 @@ class FakeHardware(hardware_type.AbstractHardwareType):
@property @property
def supported_raid_interfaces(self): def supported_raid_interfaces(self):
"""List of classes of supported raid interfaces.""" """List of classes of supported raid interfaces."""
return [fake.FakeRAID] return [fake.FakeRAID, noop.NoRAID]
@property @property
def supported_rescue_interfaces(self): def supported_rescue_interfaces(self):
"""List of classes of supported rescue interfaces.""" """List of classes of supported rescue interfaces."""
return [fake.FakeRescue] return [fake.FakeRescue, noop.NoRescue]
@property @property
def supported_storage_interfaces(self): def supported_storage_interfaces(self):
"""List of classes of supported storage interfaces.""" """List of classes of supported storage interfaces."""
return [fake.FakeStorage] return [fake.FakeStorage, noop_storage.NoopStorage]
@property @property
def supported_vendor_interfaces(self): def supported_vendor_interfaces(self):
"""List of classes of supported rescue interfaces.""" """List of classes of supported rescue interfaces."""
return [fake.FakeVendorB, fake.FakeVendorA] return [fake.FakeVendorB, fake.FakeVendorA, noop.NoVendor]
@property @property
def supported_network_interfaces(self): def supported_network_interfaces(self):

View File

@ -618,8 +618,8 @@ class TestFakeHardware(hardware_type.AbstractHardwareType):
return [fake.FakeVendorB, fake.FakeVendorA] return [fake.FakeVendorB, fake.FakeVendorA]
OPTIONAL_INTERFACES = set(drivers_base.BareDriver().standard_interfaces) - { OPTIONAL_INTERFACES = (set(drivers_base.BareDriver().standard_interfaces) -
'management', 'boot'} {'management', 'boot'}) | {'vendor'}
class HardwareTypeLoadTestCase(db_base.DbTestCase): class HardwareTypeLoadTestCase(db_base.DbTestCase):
@ -797,16 +797,16 @@ class HardwareTypeLoadTestCase(db_base.DbTestCase):
ht = fake_hardware.FakeHardware() ht = fake_hardware.FakeHardware()
expected = { expected = {
'boot': set(['fake']), 'boot': set(['fake']),
'console': set(['fake']), 'console': set(['fake', 'no-console']),
'deploy': set(['fake']), 'deploy': set(['fake']),
'inspect': set(['fake']), 'inspect': set(['fake', 'no-inspect']),
'management': set(['fake']), 'management': set(['fake']),
'network': set(['noop']), 'network': set(['noop']),
'power': set(['fake']), 'power': set(['fake']),
'raid': set(['fake']), 'raid': set(['fake', 'no-raid']),
'rescue': set(['fake']), 'rescue': set(['fake', 'no-rescue']),
'storage': set([]), 'storage': set(['noop']),
'vendor': set(['fake']) 'vendor': set(['fake', 'no-vendor'])
} }
if enable_storage: if enable_storage:
self.config(enabled_storage_interfaces=['fake']) self.config(enabled_storage_interfaces=['fake'])

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Adds missed noop implementations (e.g. ``no-inspect``) to the
``fake-hardware`` hardware type. This fixes enabling this hardware type
without enabling all (even optional) ``fake`` interfaces.