summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers/modules/test_pxe.py
diff options
context:
space:
mode:
authorArun S A G <sagarun@gmail.com>2021-10-14 17:29:22 -0700
committerArun S A G <sagarun@gmail.com>2021-10-27 10:42:25 -0700
commitdf99dea001772c1c6691150060d3ebbf496e5d25 (patch)
treea9221488c4d716c06874abb614c0c206237ae409 /ironic/tests/unit/drivers/modules/test_pxe.py
parent98896c515d5d6faead5aa4be18b31fb5e99e6c16 (diff)
downloadironic-df99dea001772c1c6691150060d3ebbf496e5d25.tar.gz
Fix various issues in the anaconda deploy interface
The kickstart template expects a dictionary with 'ks_options' as the key. Instead build_kickstart_config_options function returns a dict with keys 'liveimg_url', 'agent_token' and 'heartbeat_url'. This change fixes this problem by returning a dictionary of dict with 'ks_options' as key and the dictionary with keys 'liveimg_url', 'agent_token' and heartbeat_url' as value. Fix a bug where the deploy() method of anaconda deploy interface where it did not return states.DEPLOYWAIT instead it returned 'None' which caused the instance to go straight to 'active' instead of 'wait call-back'. Fix issues in the default kickstart template where heartbeat was missing 'callback_url' parameter and the HTTP method should be 'POST' not 'PUT'. Fix issues with automated cleaning when anaconda deploy interface is used. Anaconda deploy interface could not deploy tarballs as the disk image sent to the anaconda interface via liveimg --url kickstart command does not include any file extension. When no file extension is present the kickstart command liveimg --url assumes the disk is a mountable partiton image. We fix this problem by enabling the user to specify file extensions using a glance image property named 'disk_file_extension' on the OS image. Co-Authored-By: Ruby Loo <opensrloo@gmail.com> Change-Id: I556f8c9efbc5ab0941513c3ecaa2aa3ca7f346ae
Diffstat (limited to 'ironic/tests/unit/drivers/modules/test_pxe.py')
-rw-r--r--ironic/tests/unit/drivers/modules/test_pxe.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py
index d1e2c2e7b..ce40b8dd8 100644
--- a/ironic/tests/unit/drivers/modules/test_pxe.py
+++ b/ironic/tests/unit/drivers/modules/test_pxe.py
@@ -236,7 +236,7 @@ class PXEBootTestCase(db_base.DbTestCase):
task.driver.boot.validate_inspection, task)
@mock.patch.object(image_service.GlanceImageService, 'show', autospec=True)
- def test_validate_kickstart_has_squashfs_id(self, mock_glance):
+ def test_validate_kickstart_missing_stage2_id(self, mock_glance):
mock_glance.return_value = {'properties': {'kernel_id': 'fake-kernel',
'ramdisk_id': 'fake-initr'}}
self.node.deploy_interface = 'anaconda'
@@ -244,7 +244,7 @@ class PXEBootTestCase(db_base.DbTestCase):
self.config(http_url='http://fake_url', group='deploy')
with task_manager.acquire(self.context, self.node.uuid) as task:
self.assertRaisesRegex(exception.MissingParameterValue,
- 'squashfs_id',
+ 'stage2_id',
task.driver.boot.validate, task)
def test_validate_kickstart_fail_http_url_not_set(self):
@@ -1011,7 +1011,9 @@ class PXEAnacondaDeployTestCase(db_base.DbTestCase):
'ks_cfg': ('', '/path/to/ks_cfg')}
mock_image_info.return_value = image_info
with task_manager.acquire(self.context, self.node.uuid) as task:
- self.assertIsNone(task.driver.deploy.deploy(task))
+ self.assertEqual(
+ states.DEPLOYWAIT, task.driver.deploy.deploy(task)
+ )
mock_image_info.assert_called_once_with(task, ipxe_enabled=False)
mock_cache.assert_called_once_with(
task, image_info, ipxe_enabled=False)
@@ -1050,6 +1052,8 @@ class PXEAnacondaDeployTestCase(db_base.DbTestCase):
'ks_template': ('', '/path/to/ks_template'),
'ks_cfg': ('', '/path/to/ks_cfg')}
mock_image_info.return_value = image_info
+ self.node.provision_state = states.DEPLOYWAIT
+ self.node.save()
with task_manager.acquire(self.context, self.node.uuid) as task:
task.driver.deploy.reboot_to_instance(task)
mock_set_boot_dev.assert_called_once_with(task, boot_devices.DISK)
@@ -1112,6 +1116,17 @@ class PXEAnacondaDeployTestCase(db_base.DbTestCase):
task.node.driver_internal_info['agent_status'])
self.assertTrue(mock_reboot_to_instance.called)
+ @mock.patch.object(deploy_utils, 'prepare_inband_cleaning', autospec=True)
+ def test_prepare_cleaning(self, prepare_inband_cleaning_mock):
+ prepare_inband_cleaning_mock.return_value = states.CLEANWAIT
+ self.node.provision_state = states.CLEANING
+ self.node.save()
+ with task_manager.acquire(self.context, self.node.uuid) as task:
+ self.assertEqual(
+ states.CLEANWAIT, self.deploy.prepare_cleaning(task))
+ prepare_inband_cleaning_mock.assert_called_once_with(
+ task, manage_boot=True)
+
class PXEValidateRescueTestCase(db_base.DbTestCase):