From 56604b9d688d76b3d77e85c3c069ab2d0a08fb6a Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 11 Jan 2017 17:43:44 +0100 Subject: [PATCH] Do not fail in Inspector.__init__ if [inspector]enabled is False We already have a check in Inspector.create_if_enabled. This additional check prevents normal use of Inspector with hardware types, as it's not enough to add "inspector" to "enabled_inspect_interfaces" to use it. Change-Id: Iff29785002cd978702317d50ce52bdcebe06d0e3 Partial-Bug: #1524745 --- etc/ironic/ironic.conf.sample | 5 +++-- ironic/conf/inspector.py | 4 +++- ironic/drivers/modules/inspector.py | 4 ---- ironic/tests/unit/drivers/modules/test_inspector.py | 7 ++----- releasenotes/notes/inspector-enabled-f8a643f03e1e0360.yaml | 7 +++++++ 5 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 releasenotes/notes/inspector-enabled-f8a643f03e1e0360.yaml diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample index 28b18349cd..2e88f02739 100644 --- a/etc/ironic/ironic.conf.sample +++ b/etc/ironic/ironic.conf.sample @@ -1686,8 +1686,9 @@ # Domain name to scope to (string value) #domain_name = -# whether to enable inspection using ironic-inspector (boolean -# value) +# whether to enable inspection using ironic-inspector. This +# option does not affect new-style dynamic drivers and the +# fake_inspector driver. (boolean value) #enabled = false # Verify HTTPS connections. (boolean value) diff --git a/ironic/conf/inspector.py b/ironic/conf/inspector.py index 3627511eeb..336f53d743 100644 --- a/ironic/conf/inspector.py +++ b/ironic/conf/inspector.py @@ -19,7 +19,9 @@ from ironic.conf import auth opts = [ cfg.BoolOpt('enabled', default=False, - help=_('whether to enable inspection using ironic-inspector')), + help=_('whether to enable inspection using ironic-inspector. ' + 'This option does not affect new-style dynamic drivers ' + 'and the fake_inspector driver.')), cfg.StrOpt('service_url', help=_('ironic-inspector HTTP endpoint. If this is not set, ' 'the service catalog will be used.')), diff --git a/ironic/drivers/modules/inspector.py b/ironic/drivers/modules/inspector.py index 11c7a6f638..0fe60336f6 100644 --- a/ironic/drivers/modules/inspector.py +++ b/ironic/drivers/modules/inspector.py @@ -75,10 +75,6 @@ class Inspector(base.InspectInterface): "[inspector] enabled = True."), driver_name) def __init__(self): - if not CONF.inspector.enabled: - raise exception.DriverLoadError( - _('ironic-inspector support is disabled')) - if not client: raise exception.DriverLoadError( _('python-ironic-inspector-client Python module not found')) diff --git a/ironic/tests/unit/drivers/modules/test_inspector.py b/ironic/tests/unit/drivers/modules/test_inspector.py index 96c1d1f4c9..ca2dd6f05c 100644 --- a/ironic/tests/unit/drivers/modules/test_inspector.py +++ b/ironic/tests/unit/drivers/modules/test_inspector.py @@ -34,11 +34,8 @@ class DisabledTestCase(db_base.DbTestCase): self.config(enabled=False, group='inspector') self._do_mock() self.assertIsNone(self.driver.inspect) - # NOTE(dtantsur): it's expected that fake_inspector fails to load - # in this case - self.assertRaises(exception.DriverLoadError, - mgr_utils.mock_the_extension_manager, - "fake_inspector") + # Direct loading of the class is still possible + inspector.Inspector() def test_enabled(self): self.config(enabled=True, group='inspector') diff --git a/releasenotes/notes/inspector-enabled-f8a643f03e1e0360.yaml b/releasenotes/notes/inspector-enabled-f8a643f03e1e0360.yaml new file mode 100644 index 0000000000..8a39b7689a --- /dev/null +++ b/releasenotes/notes/inspector-enabled-f8a643f03e1e0360.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The "[inspector]enabled" configuration option no longer has effect on + the "fake_inspector" driver. It will also not have effect on new-style + dynamic drivers based on hardware types - it will be necessary to use + "enabled_inspect_interfaces" instead.