Merge "Add support for preparing rescue ramdisk in iLO PXE"
This commit is contained in:
commit
e882dfbd52
@ -607,15 +607,19 @@ class IloVirtualMediaBoot(base.BootInterface):
|
||||
class IloPXEBoot(pxe.PXEBoot):
|
||||
|
||||
@METRICS.timer('IloPXEBoot.prepare_ramdisk')
|
||||
def prepare_ramdisk(self, task, ramdisk_params):
|
||||
def prepare_ramdisk(self, task, ramdisk_params, mode='deploy'):
|
||||
"""Prepares the boot of Ironic ramdisk using PXE.
|
||||
|
||||
This method prepares the boot of the deploy ramdisk after
|
||||
This method prepares the boot of the deploy or rescue ramdisk after
|
||||
reading relevant information from the node's driver_info and
|
||||
instance_info.
|
||||
|
||||
:param task: a task from TaskManager.
|
||||
:param ramdisk_params: the parameters to be passed to the ramdisk.
|
||||
:param mode: Label indicating a deploy or rescue operation
|
||||
being carried out on the node. Supported values are
|
||||
'deploy' and 'rescue'. Defaults to 'deploy', indicating
|
||||
deploy operation is being carried out.
|
||||
:returns: None
|
||||
:raises: MissingParameterValue, if some information is missing in
|
||||
node's driver_info or instance_info.
|
||||
@ -626,10 +630,11 @@ class IloPXEBoot(pxe.PXEBoot):
|
||||
:raises: IloOperationError, if some operation on iLO failed.
|
||||
"""
|
||||
|
||||
if task.node.provision_state == states.DEPLOYING:
|
||||
if task.node.provision_state in (states.DEPLOYING, states.RESCUING):
|
||||
prepare_node_for_deploy(task)
|
||||
|
||||
super(IloPXEBoot, self).prepare_ramdisk(task, ramdisk_params)
|
||||
super(IloPXEBoot, self).prepare_ramdisk(task, ramdisk_params,
|
||||
mode=mode)
|
||||
|
||||
@METRICS.timer('IloPXEBoot.prepare_instance')
|
||||
def prepare_instance(self, task):
|
||||
|
@ -1076,8 +1076,8 @@ class IloPXEBootTestCase(db_base.DbTestCase):
|
||||
autospec=True)
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', spec_set=True,
|
||||
autospec=True)
|
||||
def test_prepare_ramdisk_not_deploying_not_cleaning(
|
||||
self, pxe_prepare_instance_mock, prepare_node_mock):
|
||||
def test_prepare_ramdisk_in_cleaning(
|
||||
self, pxe_prepare_ramdisk_mock, prepare_node_mock):
|
||||
self.node.provision_state = states.CLEANING
|
||||
self.node.save()
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
@ -1086,25 +1086,34 @@ class IloPXEBootTestCase(db_base.DbTestCase):
|
||||
task.driver.boot.prepare_ramdisk(task, None))
|
||||
|
||||
self.assertFalse(prepare_node_mock.called)
|
||||
pxe_prepare_instance_mock.assert_called_once_with(mock.ANY,
|
||||
task, None)
|
||||
pxe_prepare_ramdisk_mock.assert_called_once_with(
|
||||
mock.ANY, task, None, mode='deploy')
|
||||
|
||||
@mock.patch.object(ilo_boot, 'prepare_node_for_deploy', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', spec_set=True,
|
||||
autospec=True)
|
||||
def test_prepare_ramdisk_in_deploying(self, pxe_prepare_instance_mock,
|
||||
prepare_node_mock):
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
def _test_prepare_ramdisk_needs_node_prep(self, pxe_prepare_ramdisk_mock,
|
||||
prepare_node_mock, prov_state,
|
||||
mode):
|
||||
self.node.provision_state = prov_state
|
||||
self.node.save()
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
self.assertIsNone(
|
||||
task.driver.boot.prepare_ramdisk(task, None))
|
||||
task.driver.boot.prepare_ramdisk(task, None, mode=mode))
|
||||
|
||||
prepare_node_mock.assert_called_once_with(task)
|
||||
pxe_prepare_instance_mock.assert_called_once_with(mock.ANY,
|
||||
task, None)
|
||||
pxe_prepare_ramdisk_mock.assert_called_once_with(
|
||||
mock.ANY, task, None, mode=mode)
|
||||
|
||||
def test_prepare_ramdisk_in_deploying(self):
|
||||
self._test_prepare_ramdisk_needs_node_prep(prov_state=states.DEPLOYING,
|
||||
mode='deploy')
|
||||
|
||||
def test_prepare_ramdisk_in_rescuing(self):
|
||||
self._test_prepare_ramdisk_needs_node_prep(prov_state=states.RESCUING,
|
||||
mode='rescue')
|
||||
|
||||
@mock.patch.object(deploy_utils, 'is_iscsi_boot',
|
||||
spec_set=True, autospec=True)
|
||||
|
Loading…
Reference in New Issue
Block a user