Merge "No deploy_kernel/ramdisk with the ramdisk deploy and no cleaning"
This commit is contained in:
commit
6afa549f2a
@ -229,10 +229,13 @@ def get_kernel_ramdisk_info(node_uuid, driver_info, mode='deploy',
|
||||
image_info = {}
|
||||
labels = KERNEL_RAMDISK_LABELS[mode]
|
||||
for label in labels:
|
||||
image_info[label] = (
|
||||
str(driver_info[label]),
|
||||
os.path.join(root_dir, node_uuid, label)
|
||||
)
|
||||
try:
|
||||
image_info[label] = (
|
||||
str(driver_info[label]),
|
||||
os.path.join(root_dir, node_uuid, label)
|
||||
)
|
||||
except KeyError:
|
||||
pass # may be absent in rare cases, verified in parse_driver_info
|
||||
return image_info
|
||||
|
||||
|
||||
@ -619,6 +622,11 @@ def parse_driver_info(node, mode='deploy'):
|
||||
:returns: A dict with the driver_info values.
|
||||
:raises: MissingParameterValue
|
||||
"""
|
||||
if not deploy_utils.needs_agent_ramdisk(node, mode=mode):
|
||||
# Ramdisk deploy does not need an agent, nor does it support any other,
|
||||
# options. Skipping.
|
||||
return {}
|
||||
|
||||
info = node.driver_info
|
||||
|
||||
params_to_check = KERNEL_RAMDISK_LABELS[mode]
|
||||
|
@ -938,7 +938,7 @@ def notify_conductor_resume_deploy(task):
|
||||
notify_conductor_resume_operation(task, 'deploy')
|
||||
|
||||
|
||||
def skip_automated_cleaning(node):
|
||||
def skip_automated_cleaning(node, log=True):
|
||||
"""Checks if node cleaning needs to be skipped for an specific node.
|
||||
|
||||
:param node: the node to consider
|
||||
@ -948,9 +948,9 @@ def skip_automated_cleaning(node):
|
||||
elif node.automated_clean is None:
|
||||
return not CONF.conductor.automated_clean
|
||||
else:
|
||||
LOG.info("Automated cleaning is disabled via the API for "
|
||||
"node %(node)s",
|
||||
{'node': node.uuid})
|
||||
if log:
|
||||
LOG.info("Automated cleaning is disabled via the API for "
|
||||
"node %(node)s", {'node': node.uuid})
|
||||
return True
|
||||
|
||||
|
||||
|
@ -1452,3 +1452,17 @@ def get_root_device_for_deploy(node):
|
||||
_('Failed to validate the root device hints %(hints)s (from the '
|
||||
'node\'s %(source)s) for node %(node)s: %(error)s') %
|
||||
{'node': node.uuid, 'hints': hints, 'source': source, 'error': e})
|
||||
|
||||
|
||||
def needs_agent_ramdisk(node, mode='deploy'):
|
||||
"""Checks whether the node requires an agent ramdisk now."""
|
||||
if mode != 'deploy':
|
||||
return True # Rescue always needs a ramdisk
|
||||
|
||||
if get_boot_option(node) != 'ramdisk':
|
||||
return True # Normal deploys need an agent
|
||||
|
||||
# Ramdisk deploys don't need an agent, but cleaning will. Since we don't
|
||||
# want nodes to be stuck on deletion, require an agent when cleaning is
|
||||
# enabled.
|
||||
return not manager_utils.skip_automated_cleaning(node, log=False)
|
||||
|
@ -91,9 +91,14 @@ def _parse_driver_info(node):
|
||||
:raises: InvalidParameterValue, if any of the parameters have invalid
|
||||
value.
|
||||
"""
|
||||
mode = deploy_utils.rescue_or_deploy_mode(node)
|
||||
if not deploy_utils.needs_agent_ramdisk(node, mode=mode):
|
||||
# Ramdisk deploy does not need an agent, nor does it support any other
|
||||
# options. Skipping.
|
||||
return {'can_provide_config': False}
|
||||
|
||||
d_info = node.driver_info
|
||||
|
||||
mode = deploy_utils.rescue_or_deploy_mode(node)
|
||||
iso_param = f'{mode}_iso'
|
||||
iso_ref = driver_utils.get_agent_iso(node, deprecated_prefix='redfish',
|
||||
mode=mode)
|
||||
|
@ -921,11 +921,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
||||
def test_get_kernel_ramdisk_info_bad_driver_info(self):
|
||||
self.config(tftp_root='/tftp', group='pxe')
|
||||
node_uuid = 'fake-node'
|
||||
driver_info = {}
|
||||
self.assertRaises(KeyError,
|
||||
pxe_utils.get_kernel_ramdisk_info,
|
||||
node_uuid,
|
||||
driver_info)
|
||||
self.assertEqual({}, pxe_utils.get_kernel_ramdisk_info(node_uuid, {}))
|
||||
|
||||
def test_get_rescue_kr_info(self):
|
||||
expected_dir = '/tftp'
|
||||
@ -1189,6 +1185,13 @@ class PXEInterfacesTestCase(db_base.DbTestCase):
|
||||
group='conductor')
|
||||
self._test_parse_driver_info_missing_ramdisk(mode='rescue')
|
||||
|
||||
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
|
||||
def test_parse_driver_info_ramdisk(self):
|
||||
self.node.driver_info = {}
|
||||
self.node.automated_clean = False
|
||||
image_info = pxe_utils.parse_driver_info(self.node, mode='deploy')
|
||||
self.assertEqual({}, image_info)
|
||||
|
||||
def test__get_deploy_image_info(self):
|
||||
expected_info = {'deploy_ramdisk':
|
||||
(DRV_INFO_DICT['deploy_ramdisk'],
|
||||
|
@ -58,6 +58,16 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
|
||||
'Unable to import the sushy library',
|
||||
redfish_boot.RedfishVirtualMediaBoot)
|
||||
|
||||
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
|
||||
def test_parse_driver_info_ramdisk(self):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=True) as task:
|
||||
task.node.driver_info = {}
|
||||
task.node.automated_clean = False
|
||||
actual_driver_info = redfish_boot._parse_driver_info(task.node)
|
||||
self.assertEqual({'can_provide_config': False},
|
||||
actual_driver_info)
|
||||
|
||||
def test_parse_driver_info_deploy(self):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=True) as task:
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
When the ``ramdisk`` deploy interface is used and automated cleaning is
|
||||
disabled, the ``pxe``, ``ipxe`` and ``redfish-virtual-media`` boot
|
||||
interfaces no longer require a deploy kernel/ramdisk to be provided.
|
Loading…
Reference in New Issue
Block a user