Finish switch to inspector and inspector-client

This change is a bit ahead of time, as inspector was not released yet,
but we have chicken-and-egg problem with fixing inspector devstack here.

Change-Id: Iddb5377450806ad768582a705e1c4274079b002f
This commit is contained in:
Dmitry Tantsur 2015-06-18 17:25:35 +02:00
parent 13bcebcaf3
commit 6c08d283bb
7 changed files with 52 additions and 56 deletions

View File

@ -59,12 +59,12 @@ very similar to other OpenStack Services:
Optionally, one may wish to utilize the following associated projects for Optionally, one may wish to utilize the following associated projects for
additional functionality: additional functionality:
- ironic-discoverd_; An associated service which performs in-band hardware - ironic-inspector_; An associated service which performs in-band hardware
introspection by PXE booting unregistered hardware into a "discovery ramdisk". introspection by PXE booting unregistered hardware into a "discovery ramdisk".
- diskimage-builder_; May be used to customize machine images, create and - diskimage-builder_; May be used to customize machine images, create and
discovery deploy ramdisks, if necessary. discovery deploy ramdisks, if necessary.
.. _ironic-discoverd: https://github.com/stackforge/ironic-discoverd .. _ironic-inspector: https://github.com/openstack/ironic-inspector
.. _diskimage-builder: https://github.com/openstack/diskimage-builder .. _diskimage-builder: https://github.com/openstack/diskimage-builder
@ -1396,7 +1396,7 @@ There are two kinds of inspection supported by Ironic:
#. Out-of-band inspection is currently implemented by iLO drivers, listed at #. Out-of-band inspection is currently implemented by iLO drivers, listed at
:ref:`ilo`. :ref:`ilo`.
#. In-band inspection is performed by utilizing the ironic-discoverd_ project. #. In-band inspection is performed by utilizing the ironic-inspector_ project.
This is supported by the following drivers:: This is supported by the following drivers::
pxe_drac pxe_drac
@ -1404,22 +1404,31 @@ There are two kinds of inspection supported by Ironic:
pxe_ipminative pxe_ipminative
pxe_ssh pxe_ssh
As of Kilo release this feature needs to be explicitly enabled in the This feature needs to be explicitly enabled in the configuration
configuration by setting ``enabled = True`` in ``[discoverd]`` section. by setting ``enabled = True`` in ``[inspector]`` section.
You must additionally install ``ironic-discoverd`` to use this functionality. You must additionally install python-ironic-inspector-client_ to use
You must set ``service_url`` if the ironic-discoverd service is this functionality.
You must set ``service_url`` if the ironic-inspector service is
being run on a separate host from the ironic-conductor service, or is using being run on a separate host from the ironic-conductor service, or is using
non-standard port. non-standard port.
In order to ensure that ports in Ironic are synchronized with NIC ports on In order to ensure that ports in Ironic are synchronized with NIC ports on
the node, the following settings in the ironic-discoverd configuration file the node, the following settings in the ironic-inspector configuration file
must be set:: must be set::
[discoverd] [processing]
add_ports = all add_ports = all
keep_ports = present keep_ports = present
Note: It will require ironic-discoverd of version 1.1.0 or higher. .. note::
During Kilo cycle we used on older verions of Inspector called
ironic-discoverd_. Inspector is expected to be a mostly drop-in
replacement, and the same client library should be used to connect to both.
For Ironic Kilo install ironic-discoverd_ of version 1.1.0 or higher
instead of python-ironic-inspector-client and use ``[discoverd]`` option
group in both Ironic and ironic-discoverd configuration files instead of
ones provided above.
Inspection can be initiated using node-set-provision-state. Inspection can be initiated using node-set-provision-state.
The node should be in MANAGEABLE state before inspection is initiated. The node should be in MANAGEABLE state before inspection is initiated.
@ -1435,7 +1444,8 @@ The node should be in MANAGEABLE state before inspection is initiated.
.. note:: .. note::
The above commands require the python-ironicclient_ to be version 0.5.0 or greater. The above commands require the python-ironicclient_ to be version 0.5.0 or greater.
.. _ironic-discoverd: https://github.com/stackforge/ironic-discoverd .. _ironic-discoverd: https://pypi.python.org/pypi/ironic-discoverd
.. _python-ironic-inspector-client: https://pypi.python.org/pypi/python-ironic-inspector-client
.. _python-ironicclient: https://pypi.python.org/pypi/python-ironicclient .. _python-ironicclient: https://pypi.python.org/pypi/python-ironicclient
Specifying the disk for deployment Specifying the disk for deployment

View File

@ -11,6 +11,17 @@ The Ironic service is tightly coupled with the Ironic driver that is shipped
with Nova. Currently, some special considerations must be taken into account with Nova. Currently, some special considerations must be taken into account
when upgrading your cloud from previous versions of OpenStack. when upgrading your cloud from previous versions of OpenStack.
Upgrading from Kilo to Liberty
==============================
Inspection
----------
If you used in-band inspection with **ironic-discoverd**, you have to install
**python-ironic-inspector-client** before the upgrade. It's also recommended
that you switch to using **ironic-inspector**, which is a newer version of the
same service.
Upgrading from Juno to Kilo Upgrading from Juno to Kilo
=========================== ===========================

View File

@ -4,10 +4,10 @@
# python projects they should package as optional dependencies for Ironic. # python projects they should package as optional dependencies for Ironic.
# These are available on pypi # These are available on pypi
ironic-discoverd>=1.0.0
proliantutils>=2.1.0 proliantutils>=2.1.0
pyghmi pyghmi
pysnmp pysnmp
python-ironic-inspector-client
python-scciclient python-scciclient
python-seamicroclient>=0.4.0 python-seamicroclient>=0.4.0
UcsSdk==0.8.1.9 UcsSdk==0.8.1.9

View File

@ -12,7 +12,7 @@
""" """
Modules required to work with ironic_inspector: Modules required to work with ironic_inspector:
https://pypi.python.org/pypi/ironic-discoverd https://pypi.python.org/pypi/ironic-inspector
""" """
import eventlet import eventlet
@ -52,13 +52,10 @@ CONF = cfg.CONF
CONF.register_opts(inspector_opts, group='inspector') CONF.register_opts(inspector_opts, group='inspector')
# TODO(dtantsur): change this to ironic_inspector_client once it's available client = importutils.try_import('ironic_inspector_client')
ironic_inspector = importutils.try_import('ironic_inspector')
if not ironic_inspector:
# NOTE(dtantsur): old name for ironic-inspector INSPECTOR_API_VERSION = (1, 0)
ironic_inspector = importutils.try_import('ironic_discoverd')
if ironic_inspector:
from ironic_inspector import client
class Inspector(base.InspectInterface): class Inspector(base.InspectInterface):
@ -84,16 +81,9 @@ class Inspector(base.InspectInterface):
raise exception.DriverLoadError( raise exception.DriverLoadError(
_('ironic-inspector support is disabled')) _('ironic-inspector support is disabled'))
if not ironic_inspector: if not client:
raise exception.DriverLoadError( raise exception.DriverLoadError(
_('ironic-inspector Python module not found')) _('python-ironic-inspector-client Python module not found'))
# NOTE(dtantsur): __version_info__ attribute appeared in 1.0.0
version = getattr(ironic_inspector, '__version_info__', (0, 2))
if version < (1, 0):
raise exception.DriverLoadError(
_('ironic-inspector version is too old: required >= 1.0.0, '
'got %s') % '.'.join(str(x) for x in version))
def get_properties(self): def get_properties(self):
"""Return the properties of the interface. """Return the properties of the interface.
@ -123,9 +113,7 @@ class Inspector(base.InspectInterface):
:returns: states.INSPECTING :returns: states.INSPECTING
""" """
LOG.debug('Starting inspection for node %(uuid)s using ' LOG.debug('Starting inspection for node %(uuid)s using '
'ironic-inspector client %(version)s', 'ironic-inspector', {'uuid': task.node.uuid})
{'uuid': task.node.uuid, 'version':
ironic_inspector.__version__})
# NOTE(dtantsur): we're spawning a short-living green thread so that # NOTE(dtantsur): we're spawning a short-living green thread so that
# we can release a lock as soon as possible and allow ironic-inspector # we can release a lock as soon as possible and allow ironic-inspector
@ -153,7 +141,7 @@ class Inspector(base.InspectInterface):
def _call_inspector(func, uuid, context): def _call_inspector(func, uuid, context):
"""Wrapper around calls to inspector.""" """Wrapper around calls to inspector."""
# NOTE(dtantsur): due to bug #1428652 None is not accepted for base_url. # NOTE(dtantsur): due to bug #1428652 None is not accepted for base_url.
kwargs = {} kwargs = {'api_version': INSPECTOR_API_VERSION}
if CONF.inspector.service_url: if CONF.inspector.service_url:
kwargs['base_url'] = CONF.inspector.service_url kwargs['base_url'] = CONF.inspector.service_url
return func(uuid, auth_token=context.auth_token, **kwargs) return func(uuid, auth_token=context.auth_token, **kwargs)

View File

@ -11,8 +11,7 @@
# under the License. # under the License.
import eventlet import eventlet
import ironic_inspector import ironic_inspector_client as client
from ironic_inspector import client
import mock import mock
from ironic.common import driver_factory from ironic.common import driver_factory
@ -50,22 +49,15 @@ class DisabledTestCase(db_base.DbTestCase):
self._do_mock() self._do_mock()
self.assertIsNotNone(self.driver.inspect) self.assertIsNotNone(self.driver.inspect)
@mock.patch.object(inspector, 'ironic_inspector', None) @mock.patch.object(inspector, 'client', None)
def test_init_inspector_not_imported(self): def test_init_inspector_not_imported(self):
self.assertRaises(exception.DriverLoadError, self.assertRaises(exception.DriverLoadError,
inspector.Inspector) inspector.Inspector)
@mock.patch.object(ironic_inspector, '__version_info__', (1, 0, 0))
def test_init_ok(self): def test_init_ok(self):
self.config(enabled=True, group='inspector') self.config(enabled=True, group='inspector')
inspector.Inspector() inspector.Inspector()
@mock.patch.object(ironic_inspector, '__version_info__', (0, 2, 2))
def test_init_old_version(self):
self.config(enabled=True, group='inspector')
self.assertRaises(exception.DriverLoadError,
inspector.Inspector)
class BaseTestCase(db_base.DbTestCase): class BaseTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
@ -190,7 +182,6 @@ class CheckStatusTestCase(BaseTestCase):
@mock.patch.object(eventlet.greenthread, 'spawn_n', @mock.patch.object(eventlet.greenthread, 'spawn_n',
lambda f, *a, **kw: f(*a, **kw)) lambda f, *a, **kw: f(*a, **kw))
@mock.patch.object(ironic_inspector, '__version_info__', (1, 0, 0))
@mock.patch.object(task_manager, 'acquire', autospec=True) @mock.patch.object(task_manager, 'acquire', autospec=True)
@mock.patch.object(inspector, '_check_status', autospec=True) @mock.patch.object(inspector, '_check_status', autospec=True)
class PeriodicTaskTestCase(BaseTestCase): class PeriodicTaskTestCase(BaseTestCase):

View File

@ -22,10 +22,9 @@ IBOOT_SPEC = (
) )
# ironic_inspector # ironic_inspector
IRONIC_INSPECTOR_SPEC = ( IRONIC_INSPECTOR_CLIENT_SPEC = (
'__version__', 'introspect',
'__version_info__', 'get_status',
'client',
) )
# proliantutils # proliantutils

View File

@ -186,14 +186,11 @@ if not pyremotevbox:
sys.modules['ironic.drivers.modules.virtualbox']) sys.modules['ironic.drivers.modules.virtualbox'])
ironic_inspector = importutils.try_import('ironic_inspector') ironic_inspector_client = importutils.try_import('ironic_inspector_client')
if not ironic_inspector: if not ironic_inspector_client:
ironic_inspector = mock.MagicMock( ironic_inspector_client = mock.MagicMock(
spec_set=mock_specs.IRONIC_INSPECTOR_SPEC) spec_set=mock_specs.IRONIC_INSPECTOR_CLIENT_SPEC)
ironic_inspector.__version_info__ = (1, 0, 0) sys.modules['ironic_inspector_client'] = ironic_inspector_client
ironic_inspector.__version__ = "1.0.0"
sys.modules['ironic_inspector'] = ironic_inspector
sys.modules['ironic_inspector.client'] = ironic_inspector.client
if 'ironic.drivers.modules.inspector' in sys.modules: if 'ironic.drivers.modules.inspector' in sys.modules:
six.moves.reload_module( six.moves.reload_module(
sys.modules['ironic.drivers.modules.inspector']) sys.modules['ironic.drivers.modules.inspector'])