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
This commit is contained in:
Dmitry Tantsur 2017-01-11 17:43:44 +01:00
parent c7781fccd5
commit 56604b9d68
5 changed files with 15 additions and 12 deletions

View File

@ -1686,8 +1686,9 @@
# Domain name to scope to (string value)
#domain_name = <None>
# 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)

View File

@ -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.')),

View File

@ -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'))

View File

@ -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')

View File

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