diff options
Diffstat (limited to 'ironic/tests')
-rw-r--r-- | ironic/tests/unit/common/test_pxe_utils.py | 26 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_deploy_utils.py | 50 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_ipxe.py | 15 |
3 files changed, 70 insertions, 21 deletions
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 25847a325..3c1f745dc 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -664,7 +664,7 @@ class TestPXEUtils(db_base.DbTestCase): 'config'), pxe_utils.get_pxe_config_file_path(self.node.uuid)) - def _dhcp_options_for_instance(self, ip_version=4): + def _dhcp_options_for_instance(self, ip_version=4, ipxe=False): self.config(ip_version=ip_version, group='pxe') if ip_version == 4: self.config(tftp_server='192.0.2.1', group='pxe') @@ -672,6 +672,10 @@ class TestPXEUtils(db_base.DbTestCase): self.config(tftp_server='ff80::1', group='pxe') self.config(pxe_bootfile_name='fake-bootfile', group='pxe') self.config(tftp_root='/tftp-path/', group='pxe') + if ipxe: + bootfile = 'fake-bootfile-ipxe' + else: + bootfile = 'fake-bootfile' if ip_version == 6: # NOTE(TheJulia): DHCPv6 RFCs seem to indicate that the prior @@ -679,11 +683,11 @@ class TestPXEUtils(db_base.DbTestCase): # by vendors. The apparent proper option is to return a # URL in the field https://tools.ietf.org/html/rfc5970#section-3 expected_info = [{'opt_name': '59', - 'opt_value': 'tftp://[ff80::1]/fake-bootfile', + 'opt_value': 'tftp://[ff80::1]/%s' % bootfile, 'ip_version': ip_version}] elif ip_version == 4: expected_info = [{'opt_name': '67', - 'opt_value': 'fake-bootfile', + 'opt_value': bootfile, 'ip_version': ip_version}, {'opt_name': '210', 'opt_value': '/tftp-path/', @@ -1380,7 +1384,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): # URL in the field https://tools.ietf.org/html/rfc5970#section-3 expected_boot_script_url = 'http://[ff80::1]:1234/boot.ipxe' expected_info = [{'opt_name': '!175,59', - 'opt_value': 'tftp://[ff80::1]/fake-bootfile', + 'opt_value': 'tftp://[ff80::1]/%s' % boot_file, 'ip_version': ip_version}, {'opt_name': '59', 'opt_value': expected_boot_script_url, @@ -1412,7 +1416,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): if ip_version == 6: # Boot URL variable set from prior test of isc parameters. expected_info = [{'opt_name': 'tag:!ipxe6,59', - 'opt_value': 'tftp://[ff80::1]/fake-bootfile', + 'opt_value': 'tftp://[ff80::1]/%s' % boot_file, 'ip_version': ip_version}, {'opt_name': 'tag:ipxe6,59', 'opt_value': expected_boot_script_url, @@ -1441,23 +1445,23 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): def test_dhcp_options_for_instance_ipxe_bios(self): self.config(ip_version=4, group='pxe') - boot_file = 'fake-bootfile-bios' - self.config(pxe_bootfile_name=boot_file, group='pxe') + boot_file = 'fake-bootfile-bios-ipxe' + self.config(ipxe_bootfile_name=boot_file, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: self._dhcp_options_for_instance_ipxe(task, boot_file) def test_dhcp_options_for_instance_ipxe_uefi(self): self.config(ip_version=4, group='pxe') - boot_file = 'fake-bootfile-uefi' - self.config(uefi_pxe_bootfile_name=boot_file, group='pxe') + boot_file = 'fake-bootfile-uefi-ipxe' + self.config(uefi_ipxe_bootfile_name=boot_file, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: task.node.properties['capabilities'] = 'boot_mode:uefi' self._dhcp_options_for_instance_ipxe(task, boot_file) def test_dhcp_options_for_ipxe_ipv6(self): self.config(ip_version=6, group='pxe') - boot_file = 'fake-bootfile' - self.config(pxe_bootfile_name=boot_file, group='pxe') + boot_file = 'fake-bootfile-ipxe' + self.config(ipxe_bootfile_name=boot_file, group='pxe') with task_manager.acquire(self.context, self.node.uuid) as task: self._dhcp_options_for_instance_ipxe(task, boot_file, ip_version=6) diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index 5344d3ed4..1e6c3b42b 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -582,6 +582,34 @@ class GetPxeBootConfigTestCase(db_base.DbTestCase): result = utils.get_pxe_boot_file(self.node) self.assertEqual('bios-bootfile', result) + def test_get_ipxe_boot_file(self): + self.config(ipxe_bootfile_name='meow', group='pxe') + result = utils.get_ipxe_boot_file(self.node) + self.assertEqual('meow', result) + + def test_get_ipxe_boot_file_uefi(self): + self.config(uefi_ipxe_bootfile_name='ipxe-uefi-bootfile', group='pxe') + properties = {'capabilities': 'boot_mode:uefi'} + self.node.properties = properties + result = utils.get_ipxe_boot_file(self.node) + self.assertEqual('ipxe-uefi-bootfile', result) + + def test_get_ipxe_boot_file_other_arch(self): + arch_names = {'aarch64': 'ipxe-aa64.efi', + 'x86_64': 'ipxe.kpxe'} + self.config(ipxe_bootfile_name_by_arch=arch_names, group='pxe') + properties = {'cpu_arch': 'aarch64', 'capabilities': 'boot_mode:uefi'} + self.node.properties = properties + result = utils.get_ipxe_boot_file(self.node) + self.assertEqual('ipxe-aa64.efi', result) + + def test_get_ipxe_boot_file_fallback(self): + self.config(ipxe_bootfile_name=None, group='pxe') + self.config(uefi_ipxe_bootfile_name=None, group='pxe') + self.config(pxe_bootfile_name='lolcat', group='pxe') + result = utils.get_ipxe_boot_file(self.node) + self.assertEqual('lolcat', result) + def test_get_pxe_config_template_emtpy_property(self): self.node.properties = {} self.config(pxe_config_template_by_arch=self.template_by_arch, @@ -597,6 +625,28 @@ class GetPxeBootConfigTestCase(db_base.DbTestCase): result = utils.get_pxe_config_template(node) self.assertEqual('fake-template', result) + def test_get_ipxe_config_template(self): + node = obj_utils.create_test_node( + self.context, driver='fake-hardware') + self.assertIn('ipxe_config.template', + utils.get_ipxe_config_template(node)) + + def test_get_ipxe_config_template_none(self): + self.config(ipxe_config_template=None, group='pxe') + self.config(pxe_config_template='magical_bootloader', + group='pxe') + node = obj_utils.create_test_node( + self.context, driver='fake-hardware') + self.assertEqual('magical_bootloader', + utils.get_ipxe_config_template(node)) + + def test_get_ipxe_config_template_override_pxe_fallback(self): + node = obj_utils.create_test_node( + self.context, driver='fake-hardware', + driver_info={'pxe_template': 'magical'}) + self.assertEqual('magical', + utils.get_ipxe_config_template(node)) + @mock.patch('time.sleep', lambda sec: None) class OtherFunctionTestCase(db_base.DbTestCase): diff --git a/ironic/tests/unit/drivers/modules/test_ipxe.py b/ironic/tests/unit/drivers/modules/test_ipxe.py index cbec1bb0d..c53facf22 100644 --- a/ironic/tests/unit/drivers/modules/test_ipxe.py +++ b/ironic/tests/unit/drivers/modules/test_ipxe.py @@ -310,14 +310,9 @@ class iPXEBootTestCase(db_base.DbTestCase): mock_cache_r_k.assert_called_once_with( task, {'rescue_kernel': 'a', 'rescue_ramdisk': 'r'}, ipxe_enabled=True) - if uefi: - mock_pxe_config.assert_called_once_with( - task, {}, CONF.pxe.uefi_pxe_config_template, - ipxe_enabled=True) - else: - mock_pxe_config.assert_called_once_with( - task, {}, CONF.pxe.pxe_config_template, - ipxe_enabled=True) + mock_pxe_config.assert_called_once_with( + task, {}, CONF.pxe.ipxe_config_template, + ipxe_enabled=True) def test_prepare_ramdisk(self): self.node.provision_state = states.DEPLOYING @@ -700,7 +695,7 @@ class iPXEBootTestCase(db_base.DbTestCase): ipxe_enabled=True) provider_mock.update_dhcp.assert_called_once_with(task, dhcp_opts) create_pxe_config_mock.assert_called_once_with( - task, mock.ANY, CONF.pxe.pxe_config_template, + task, mock.ANY, CONF.pxe.ipxe_config_template, ipxe_enabled=True) switch_pxe_config_mock.assert_called_once_with( pxe_config_path, "30212642-09d3-467f-8e09-21685826ab50", @@ -817,7 +812,7 @@ class iPXEBootTestCase(db_base.DbTestCase): self.assertFalse(cache_mock.called) provider_mock.update_dhcp.assert_called_once_with(task, dhcp_opts) create_pxe_config_mock.assert_called_once_with( - task, mock.ANY, CONF.pxe.pxe_config_template, + task, mock.ANY, CONF.pxe.ipxe_config_template, ipxe_enabled=True) switch_pxe_config_mock.assert_called_once_with( pxe_config_path, None, boot_modes.LEGACY_BIOS, False, |