From ce5fd966a09b838f658d8b6bc0cd026a7e358d0c Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Tue, 13 Feb 2018 19:07:32 +0100 Subject: [PATCH] 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 --- ironic/drivers/fake_hardware.py | 14 ++++++++------ ironic/tests/unit/common/test_driver_factory.py | 16 ++++++++-------- .../notes/fake-noop-bebc43983eb801d1.yaml | 6 ++++++ 3 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/fake-noop-bebc43983eb801d1.yaml diff --git a/ironic/drivers/fake_hardware.py b/ironic/drivers/fake_hardware.py index 5d0776f226..2eb6344876 100644 --- a/ironic/drivers/fake_hardware.py +++ b/ironic/drivers/fake_hardware.py @@ -18,6 +18,8 @@ Fake hardware type. from ironic.drivers import hardware_type 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): @@ -39,7 +41,7 @@ class FakeHardware(hardware_type.AbstractHardwareType): @property def supported_console_interfaces(self): """List of classes of supported console interfaces.""" - return [fake.FakeConsole] + return [fake.FakeConsole, noop.NoConsole] @property def supported_deploy_interfaces(self): @@ -49,7 +51,7 @@ class FakeHardware(hardware_type.AbstractHardwareType): @property def supported_inspect_interfaces(self): """List of classes of supported inspect interfaces.""" - return [fake.FakeInspect] + return [fake.FakeInspect, noop.NoInspect] @property def supported_management_interfaces(self): @@ -64,22 +66,22 @@ class FakeHardware(hardware_type.AbstractHardwareType): @property def supported_raid_interfaces(self): """List of classes of supported raid interfaces.""" - return [fake.FakeRAID] + return [fake.FakeRAID, noop.NoRAID] @property def supported_rescue_interfaces(self): """List of classes of supported rescue interfaces.""" - return [fake.FakeRescue] + return [fake.FakeRescue, noop.NoRescue] @property def supported_storage_interfaces(self): """List of classes of supported storage interfaces.""" - return [fake.FakeStorage] + return [fake.FakeStorage, noop_storage.NoopStorage] @property def supported_vendor_interfaces(self): """List of classes of supported rescue interfaces.""" - return [fake.FakeVendorB, fake.FakeVendorA] + return [fake.FakeVendorB, fake.FakeVendorA, noop.NoVendor] @property def supported_network_interfaces(self): diff --git a/ironic/tests/unit/common/test_driver_factory.py b/ironic/tests/unit/common/test_driver_factory.py index 9d7cbd5dc3..1e0ebc9c5a 100644 --- a/ironic/tests/unit/common/test_driver_factory.py +++ b/ironic/tests/unit/common/test_driver_factory.py @@ -618,8 +618,8 @@ class TestFakeHardware(hardware_type.AbstractHardwareType): return [fake.FakeVendorB, fake.FakeVendorA] -OPTIONAL_INTERFACES = set(drivers_base.BareDriver().standard_interfaces) - { - 'management', 'boot'} +OPTIONAL_INTERFACES = (set(drivers_base.BareDriver().standard_interfaces) - + {'management', 'boot'}) | {'vendor'} class HardwareTypeLoadTestCase(db_base.DbTestCase): @@ -797,16 +797,16 @@ class HardwareTypeLoadTestCase(db_base.DbTestCase): ht = fake_hardware.FakeHardware() expected = { 'boot': set(['fake']), - 'console': set(['fake']), + 'console': set(['fake', 'no-console']), 'deploy': set(['fake']), - 'inspect': set(['fake']), + 'inspect': set(['fake', 'no-inspect']), 'management': set(['fake']), 'network': set(['noop']), 'power': set(['fake']), - 'raid': set(['fake']), - 'rescue': set(['fake']), - 'storage': set([]), - 'vendor': set(['fake']) + 'raid': set(['fake', 'no-raid']), + 'rescue': set(['fake', 'no-rescue']), + 'storage': set(['noop']), + 'vendor': set(['fake', 'no-vendor']) } if enable_storage: self.config(enabled_storage_interfaces=['fake']) diff --git a/releasenotes/notes/fake-noop-bebc43983eb801d1.yaml b/releasenotes/notes/fake-noop-bebc43983eb801d1.yaml new file mode 100644 index 0000000000..2bca127a57 --- /dev/null +++ b/releasenotes/notes/fake-noop-bebc43983eb801d1.yaml @@ -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.