Browse Source

clean up mac address with the pxe configuration files

In pxe_utils.py/create_pxe_config function, mac pxe configs will always
be created, so when we clear pxe configs, no matter whether the ip
address is None or not, we need to clear them.

Change-Id: I5cee9c4465630b162baf911ef9efef5f471671c0
Signed-off-by: Armstrong Liu <vpbvmw651078@gmail.com>
(cherry picked from commit 41f15dba65)
changes/92/760792/1
Armstrong Liu 4 months ago
committed by Ning Yao
parent
commit
9e35573f12
2 changed files with 27 additions and 2 deletions
  1. +0
    -2
      ironic/common/pxe_utils.py
  2. +27
    -0
      ironic/tests/unit/common/test_pxe_utils.py

+ 0
- 2
ironic/common/pxe_utils.py View File

@@ -347,8 +347,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:


+ 27
- 0
ironic/tests/unit/common/test_pxe_utils.py View File

@@ -970,6 +970,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…
Cancel
Save