Merge "clean up mac address with the pxe configuration files"
This commit is contained in:
commit
66dd15931c
@ -345,8 +345,6 @@ def clean_up_pxe_config(task, ipxe_enabled=False):
|
||||
if is_uefi_boot_mode and not ipxe_enabled:
|
||||
api = dhcp_factory.DHCPFactory().provider
|
||||
ip_addresses = api.get_ip_addresses(task)
|
||||
if not ip_addresses:
|
||||
return
|
||||
|
||||
for port_ip_address in ip_addresses:
|
||||
try:
|
||||
|
@ -874,6 +874,33 @@ class TestPXEUtils(db_base.DbTestCase):
|
||||
relpath = pxe_utils.get_path_relative_to_tftp_root(test_file_path)
|
||||
self.assertEqual(relpath, 'pxelinux.cfg/test')
|
||||
|
||||
@mock.patch('ironic.common.utils.rmtree_without_raise', autospec=True)
|
||||
@mock.patch('ironic_lib.utils.unlink_without_raise', autospec=True)
|
||||
@mock.patch('ironic.common.dhcp_factory.DHCPFactory.provider',
|
||||
autospec=True)
|
||||
def test_clean_up_pxe_config_uefi_no_ipaddress(self, provider_mock,
|
||||
unlink_mock,
|
||||
rmtree_mock):
|
||||
address = "aa:aa:aa:aa:aa:aa"
|
||||
properties = {'capabilities': 'boot_mode:uefi'}
|
||||
object_utils.create_test_port(self.context, node_id=self.node.id,
|
||||
address=address)
|
||||
|
||||
provider_mock.get_ip_addresses.return_value = []
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
task.node.properties = properties
|
||||
pxe_utils.clean_up_pxe_config(task)
|
||||
|
||||
unlink_calls = [
|
||||
mock.call('/tftpboot/pxelinux.cfg/01-%s' %
|
||||
address.replace(':', '-')),
|
||||
mock.call('/tftpboot/aa:aa:aa:aa:aa:aa.conf')
|
||||
]
|
||||
unlink_mock.assert_has_calls(unlink_calls)
|
||||
rmtree_mock.assert_called_once_with(
|
||||
os.path.join(CONF.pxe.tftp_root, self.node.uuid))
|
||||
|
||||
|
||||
@mock.patch.object(ipxe.iPXEBoot, '__init__', lambda self: None)
|
||||
@mock.patch.object(pxe.PXEBoot, '__init__', lambda self: None)
|
||||
|
Loading…
Reference in New Issue
Block a user