Merge "Fix ramdisk boot option handling"
This commit is contained in:
commit
2744afcca9
@ -588,11 +588,21 @@ def get_boot_option(node):
|
||||
return 'local'
|
||||
if is_anaconda_deploy(node):
|
||||
return 'kickstart'
|
||||
if is_ramdisk_deploy(node):
|
||||
return 'ramdisk'
|
||||
capabilities = utils.parse_instance_info_capabilities(node)
|
||||
return capabilities.get('boot_option',
|
||||
CONF.deploy.default_boot_option).lower()
|
||||
|
||||
|
||||
# FIXME(dtantsur): relying on deploy interface name is an anti-pattern.
|
||||
# Refactor the code so that the deploy interface itself provides the only boot
|
||||
# option it supports.
|
||||
|
||||
def is_ramdisk_deploy(node):
|
||||
return node.deploy_interface == 'ramdisk'
|
||||
|
||||
|
||||
def is_anaconda_deploy(node):
|
||||
"""Determine if Anaconda deploy interface is in use for the deployment.
|
||||
|
||||
|
@ -90,19 +90,6 @@ class PXERamdiskDeploy(agent_base.AgentBaseMixin, agent_base.HeartbeatMixin,
|
||||
@task_manager.require_exclusive_lock
|
||||
def prepare(self, task):
|
||||
node = task.node
|
||||
# Log a warning if the boot_option is wrong... and
|
||||
# otherwise reset it.
|
||||
boot_option = deploy_utils.get_boot_option(node)
|
||||
if boot_option != 'ramdisk':
|
||||
LOG.warning('Incorrect "boot_option" set for node %(node)s '
|
||||
'and will be overridden to "ramdisk" as to '
|
||||
'match the deploy interface. Found: %(boot_opt)s.',
|
||||
{'node': node.uuid,
|
||||
'boot_opt': boot_option})
|
||||
i_info = task.node.instance_info
|
||||
i_info.update({'capabilities': {'boot_option': 'ramdisk'}})
|
||||
node.instance_info = i_info
|
||||
node.save()
|
||||
|
||||
deploy_utils.populate_storage_driver_internal_info(task)
|
||||
if node.provision_state == states.DEPLOYING:
|
||||
|
@ -941,8 +941,6 @@ class PXERamdiskDeployTestCase(db_base.DbTestCase):
|
||||
with task_manager.acquire(self.context, node.uuid) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
self.assertFalse(mock_prepare_instance.called)
|
||||
self.assertEqual({'boot_option': 'ramdisk'},
|
||||
task.node.instance_info['capabilities'])
|
||||
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_instance', autospec=True)
|
||||
def test_prepare_active(self, mock_prepare_instance):
|
||||
@ -962,22 +960,6 @@ class PXERamdiskDeployTestCase(db_base.DbTestCase):
|
||||
task.driver.deploy.prepare(task)
|
||||
mock_prepare_instance.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(pxe.LOG, 'warning', autospec=True)
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_instance', autospec=True)
|
||||
def test_prepare_fixes_and_logs_boot_option_warning(
|
||||
self, mock_prepare_instance, mock_warning):
|
||||
node = self.node
|
||||
node.properties['capabilities'] = 'boot_option:ramdisk'
|
||||
node.provision_state = states.DEPLOYING
|
||||
node.instance_info = {}
|
||||
node.save()
|
||||
with task_manager.acquire(self.context, node.uuid) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
self.assertFalse(mock_prepare_instance.called)
|
||||
self.assertEqual({'boot_option': 'ramdisk'},
|
||||
task.node.instance_info['capabilities'])
|
||||
self.assertTrue(mock_warning.called)
|
||||
|
||||
@mock.patch.object(deploy_utils, 'validate_image_properties',
|
||||
autospec=True)
|
||||
def test_validate(self, mock_validate_img):
|
||||
|
Loading…
Reference in New Issue
Block a user