Merge "Add support for rescue mode in enrollment and node configuration workflows"

This commit is contained in:
Zuul 2018-05-03 16:02:41 +00:00 committed by Gerrit Code Review
commit eb9f2f72c8
5 changed files with 58 additions and 8 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
Sets ``rescue_kernel`` and ``rescue_ramdisk`` to the same values as
``deploy_kernel`` and ``deploy_ramdisk`` on node enrollment or
configuration.
- |
Adds support for ``rescue_interface`` when enrolling nodes.

View File

@ -152,6 +152,16 @@ class ConfigureBootAction(base.TripleOAction):
'path': '/driver_info/deploy_kernel', 'path': '/driver_info/deploy_kernel',
'value': image_ids['kernel'], 'value': image_ids['kernel'],
}, },
{
'op': 'add',
'path': '/driver_info/rescue_ramdisk',
'value': image_ids['ramdisk'],
},
{
'op': 'add',
'path': '/driver_info/rescue_kernel',
'value': image_ids['kernel'],
},
]) ])
LOG.debug("Configuring boot option for Node %s", self.node_uuid) LOG.debug("Configuring boot option for Node %s", self.node_uuid)
except Exception as err: except Exception as err:

View File

@ -35,6 +35,12 @@ class TestConfigureBootAction(base.TestCase):
'value': 'r_id'}, 'value': 'r_id'},
{'op': 'add', {'op': 'add',
'path': '/driver_info/deploy_kernel', 'path': '/driver_info/deploy_kernel',
'value': 'k_id'},
{'op': 'add',
'path': '/driver_info/rescue_ramdisk',
'value': 'r_id'},
{'op': 'add',
'path': '/driver_info/rescue_kernel',
'value': 'k_id'}] 'value': 'k_id'}]
self.ironic = mock.MagicMock() self.ironic = mock.MagicMock()
@ -118,8 +124,18 @@ class TestConfigureBootAction(base.TestCase):
self.assertIsNone(result) self.assertIsNone(result)
self.node_update[1].update({'value': 'test_ramdisk_id'}) self.node_update[1:] = [{'op': 'add',
self.node_update[2].update({'value': 'test_kernel_id'}) 'path': '/driver_info/deploy_ramdisk',
'value': 'test_ramdisk_id'},
{'op': 'add',
'path': '/driver_info/deploy_kernel',
'value': 'test_kernel_id'},
{'op': 'add',
'path': '/driver_info/rescue_ramdisk',
'value': 'test_ramdisk_id'},
{'op': 'add',
'path': '/driver_info/rescue_kernel',
'value': 'test_kernel_id'}]
self.ironic.node.update.assert_called_once_with(mock.ANY, self.ironic.node.update.assert_called_once_with(mock.ANY,
self.node_update) self.node_update)

View File

@ -336,7 +336,9 @@ class NodesTest(base.TestCase):
"ipmi_username": "test", "ipmi_username": "test",
"ipmi_password": "random", "ipmi_password": "random",
"deploy_kernel": "kernel-123", "deploy_kernel": "kernel-123",
"deploy_ramdisk": "ramdisk-999"} "deploy_ramdisk": "ramdisk-999",
"rescue_kernel": "kernel-123",
"rescue_ramdisk": "ramdisk-999"}
pxe_node = mock.call(driver="ipmi", pxe_node = mock.call(driver="ipmi",
name='node1', name='node1',
driver_info=pxe_node_driver_info, driver_info=pxe_node_driver_info,
@ -408,6 +410,7 @@ class NodesTest(base.TestCase):
'network_interface': 'neutron', 'network_interface': 'neutron',
'power_interface': 'ipmitool', 'power_interface': 'ipmitool',
'raid_interface': 'agent', 'raid_interface': 'agent',
'rescue_interface': 'agent',
'storage_interface': 'cinder', 'storage_interface': 'cinder',
'vendor_interface': 'ipmitool'} 'vendor_interface': 'ipmitool'}
@ -444,6 +447,7 @@ class NodesTest(base.TestCase):
'network_interface': 'neutron', 'network_interface': 'neutron',
'power_interface': 'ipmitool', 'power_interface': 'ipmitool',
'raid_interface': 'agent', 'raid_interface': 'agent',
'rescue_interface': 'agent',
'storage_interface': 'cinder', 'storage_interface': 'cinder',
'vendor_interface': 'ipmitool'} 'vendor_interface': 'ipmitool'}
@ -498,6 +502,8 @@ class NodesTest(base.TestCase):
{'path': '/properties/capabilities', 'value': 'num_nics:6'}, {'path': '/properties/capabilities', 'value': 'num_nics:6'},
{'path': '/driver_info/deploy_kernel', 'value': 'image-k'}, {'path': '/driver_info/deploy_kernel', 'value': 'image-k'},
{'path': '/driver_info/deploy_ramdisk', 'value': 'image-r'}, {'path': '/driver_info/deploy_ramdisk', 'value': 'image-r'},
{'path': '/driver_info/rescue_kernel', 'value': 'image-k'},
{'path': '/driver_info/rescue_ramdisk', 'value': 'image-r'},
{'path': '/driver_info/ipmi_username', 'value': 'test'}] {'path': '/driver_info/ipmi_username', 'value': 'test'}]
for key in update_patch: for key in update_patch:
key['op'] = 'add' key['op'] = 'add'

View File

@ -28,7 +28,8 @@ LOG = logging.getLogger(__name__)
_KNOWN_INTERFACE_FIELDS = [ _KNOWN_INTERFACE_FIELDS = [
'%s_interface' % field for field in ('boot', 'console', 'deploy', '%s_interface' % field for field in ('boot', 'console', 'deploy',
'inspect', 'management', 'network', 'inspect', 'management', 'network',
'power', 'raid', 'storage', 'vendor') 'power', 'raid', 'rescue', 'storage',
'vendor')
] ]
CTLPLANE_NETWORK = 'ctlplane' CTLPLANE_NETWORK = 'ctlplane'
@ -326,8 +327,10 @@ def register_ironic_node(node, client):
if "kernel_id" in node: if "kernel_id" in node:
driver_info["deploy_kernel"] = node["kernel_id"] driver_info["deploy_kernel"] = node["kernel_id"]
driver_info["rescue_kernel"] = node["kernel_id"]
if "ramdisk_id" in node: if "ramdisk_id" in node:
driver_info["deploy_ramdisk"] = node["ramdisk_id"] driver_info["deploy_ramdisk"] = node["ramdisk_id"]
driver_info["rescue_ramdisk"] = node["ramdisk_id"]
interface_fields = {field: node.pop(field) interface_fields = {field: node.pop(field)
for field in _KNOWN_INTERFACE_FIELDS for field in _KNOWN_INTERFACE_FIELDS
@ -439,8 +442,10 @@ _NON_DRIVER_FIELDS = {'cpu': '/properties/cpus',
'root_device': '/properties/root_device', 'root_device': '/properties/root_device',
'name': '/name', 'name': '/name',
'resource_class': '/resource_class', 'resource_class': '/resource_class',
'kernel_id': '/driver_info/deploy_kernel', 'kernel_id': ['/driver_info/deploy_kernel',
'ramdisk_id': '/driver_info/deploy_ramdisk', '/driver_info/rescue_kernel'],
'ramdisk_id': ['/driver_info/deploy_ramdisk',
'/driver_info/rescue_ramdisk'],
'capabilities': '/properties/capabilities'} 'capabilities': '/properties/capabilities'}
_NON_DRIVER_FIELDS.update({field: '/%s' % field _NON_DRIVER_FIELDS.update({field: '/%s' % field
@ -456,9 +461,14 @@ def _update_or_register_ironic_node(node, node_map, client):
node_uuid) node_uuid)
patched = {} patched = {}
for field, path in _NON_DRIVER_FIELDS.items(): for field, paths in _NON_DRIVER_FIELDS.items():
if isinstance(paths, six.string_types):
paths = [paths]
if field in node: if field in node:
patched[path] = node.pop(field) value = node.pop(field)
for path in paths:
patched[path] = value
driver_info = handler.convert(node) driver_info = handler.convert(node)
for key, value in driver_info.items(): for key, value in driver_info.items():