add disabled option to VALID_ADD_PORTS_VALUES
This allows inspector to create nodes without creating ports for the node. Change-Id: Ife4c06d20e9217f0a308fef19177884596c6cf2d Closes-Bug: #1693892
This commit is contained in:
parent
8b2e7d16b5
commit
f61a75aaa0
@ -47,6 +47,11 @@ Usual hardware introspection flow is as follows:
|
|||||||
created for all detected NIC's, and all other ports will be deleted.
|
created for all detected NIC's, and all other ports will be deleted.
|
||||||
Refer to the `Ironic inspection documentation`_ for details.
|
Refer to the `Ironic inspection documentation`_ for details.
|
||||||
|
|
||||||
|
Ironic inspector can also be configured to not create any ports. This is
|
||||||
|
done by setting ``add_ports=disabled``. If setting ``add_ports`` to disabled
|
||||||
|
the ``keep_ports`` option should be also set to ``all``. This will ensure
|
||||||
|
no manually added ports will be deleted.
|
||||||
|
|
||||||
* Separate API (see :ref:`usage` and :ref:`api`) can be used to query
|
* Separate API (see :ref:`usage` and :ref:`api`) can be used to query
|
||||||
introspection results for a given node.
|
introspection results for a given node.
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@
|
|||||||
# IP addresses), pxe (only MAC address of NIC node PXE booted from,
|
# IP addresses), pxe (only MAC address of NIC node PXE booted from,
|
||||||
# falls back to "active" if PXE MAC is not supplied by the ramdisk).
|
# falls back to "active" if PXE MAC is not supplied by the ramdisk).
|
||||||
# (string value)
|
# (string value)
|
||||||
# Allowed values: all, active, pxe
|
# Allowed values: all, active, pxe, disabled
|
||||||
#add_ports = pxe
|
#add_ports = pxe
|
||||||
|
|
||||||
# Which ports (already present on a node) to keep after introspection.
|
# Which ports (already present on a node) to keep after introspection.
|
||||||
|
@ -21,7 +21,7 @@ MIN_VERSION_HEADER = 'X-OpenStack-Ironic-Inspector-API-Minimum-Version'
|
|||||||
MAX_VERSION_HEADER = 'X-OpenStack-Ironic-Inspector-API-Maximum-Version'
|
MAX_VERSION_HEADER = 'X-OpenStack-Ironic-Inspector-API-Maximum-Version'
|
||||||
VERSION_HEADER = 'X-OpenStack-Ironic-Inspector-API-Version'
|
VERSION_HEADER = 'X-OpenStack-Ironic-Inspector-API-Version'
|
||||||
|
|
||||||
VALID_ADD_PORTS_VALUES = ('all', 'active', 'pxe')
|
VALID_ADD_PORTS_VALUES = ('all', 'active', 'pxe', 'disabled')
|
||||||
VALID_KEEP_PORTS_VALUES = ('all', 'present', 'added')
|
VALID_KEEP_PORTS_VALUES = ('all', 'present', 'added')
|
||||||
VALID_STORE_DATA_VALUES = ('none', 'swift')
|
VALID_STORE_DATA_VALUES = ('none', 'swift')
|
||||||
|
|
||||||
|
@ -124,6 +124,15 @@ class SchedulerHook(base.ProcessingHook):
|
|||||||
class ValidateInterfacesHook(base.ProcessingHook):
|
class ValidateInterfacesHook(base.ProcessingHook):
|
||||||
"""Hook to validate network interfaces."""
|
"""Hook to validate network interfaces."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# Some configuration checks
|
||||||
|
if (CONF.processing.add_ports == 'disabled' and
|
||||||
|
CONF.processing.keep_ports == 'added'):
|
||||||
|
msg = _("Configuration error: add_ports set to disabled "
|
||||||
|
"and keep_ports set to added. Please change keep_ports "
|
||||||
|
"to all.")
|
||||||
|
raise utils.Error(msg)
|
||||||
|
|
||||||
def _get_interfaces(self, data=None):
|
def _get_interfaces(self, data=None):
|
||||||
"""Convert inventory to a dict with interfaces.
|
"""Convert inventory to a dict with interfaces.
|
||||||
|
|
||||||
@ -237,7 +246,8 @@ class ValidateInterfacesHook(base.ProcessingHook):
|
|||||||
def before_update(self, introspection_data, node_info, **kwargs):
|
def before_update(self, introspection_data, node_info, **kwargs):
|
||||||
"""Create new ports and drop ports that are not present in the data."""
|
"""Create new ports and drop ports that are not present in the data."""
|
||||||
interfaces = introspection_data.get('interfaces')
|
interfaces = introspection_data.get('interfaces')
|
||||||
node_info.create_ports(list(interfaces.values()))
|
if CONF.processing.add_ports != 'disabled':
|
||||||
|
node_info.create_ports(list(interfaces.values()))
|
||||||
|
|
||||||
if CONF.processing.keep_ports == 'present':
|
if CONF.processing.keep_ports == 'present':
|
||||||
expected_macs = {
|
expected_macs = {
|
||||||
|
@ -173,6 +173,24 @@ class TestValidateInterfacesHookBeforeProcessing(test_base.NodeTest):
|
|||||||
sorted(self.data['macs']))
|
sorted(self.data['macs']))
|
||||||
self.assertEqual(self.all_interfaces, self.data['all_interfaces'])
|
self.assertEqual(self.all_interfaces, self.data['all_interfaces'])
|
||||||
|
|
||||||
|
@mock.patch.object(node_cache.NodeInfo, 'create_ports')
|
||||||
|
def test_disabled_bad_conf(self, mock_create_port):
|
||||||
|
CONF.set_override('add_ports', 'disabled', 'processing')
|
||||||
|
CONF.set_override('keep_ports', 'added', 'processing')
|
||||||
|
|
||||||
|
self.assertRaisesRegex(utils.Error, 'Configuration error:',
|
||||||
|
self.hook.__init__)
|
||||||
|
mock_create_port.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch.object(node_cache.NodeInfo, 'create_ports')
|
||||||
|
def test_disabled(self, mock_create_port):
|
||||||
|
CONF.set_override('add_ports', 'disabled', 'processing')
|
||||||
|
CONF.set_override('keep_ports', 'all', 'processing')
|
||||||
|
|
||||||
|
self.hook.before_processing(self.data)
|
||||||
|
self.assertEqual(self.active_interfaces, self.data['interfaces'])
|
||||||
|
mock_create_port.assert_not_called()
|
||||||
|
|
||||||
def test_malformed_interfaces(self):
|
def test_malformed_interfaces(self):
|
||||||
self.inventory['interfaces'] = [
|
self.inventory['interfaces'] = [
|
||||||
# no name
|
# no name
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``disabled`` option to add_ports, so discovered nodes can be created
|
||||||
|
without create ports.
|
Loading…
Reference in New Issue
Block a user