Do not overwrite the iPXE boot script on every deployment
This patch just add a check to verify if the iPXE boot script have already been laid down in the HTTP root directory and do not overwrite it if it's already there. The script is the same for all deployments so we don't need to write it over and over. This also makes it easier to test some custom parameter in the script without having to deal with Ironic undoing the changes prior to deploy a node. Closes-Bug: #1489904 Change-Id: I0d56767978a6d1290442e50d7cb1308d78e3a352
This commit is contained in:
parent
d823aed23f
commit
d72493deb2
@ -429,7 +429,8 @@ class PXEBoot(base.BootInterface):
|
||||
bootfile_path = os.path.join(
|
||||
CONF.deploy.http_root,
|
||||
os.path.basename(CONF.pxe.ipxe_boot_script))
|
||||
shutil.copyfile(CONF.pxe.ipxe_boot_script, bootfile_path)
|
||||
if not os.path.exists(bootfile_path):
|
||||
shutil.copyfile(CONF.pxe.ipxe_boot_script, bootfile_path)
|
||||
|
||||
dhcp_opts = pxe_utils.dhcp_options_for_instance(task)
|
||||
provider = dhcp_factory.DHCPFactory()
|
||||
|
@ -737,19 +737,31 @@ class PXEBootTestCase(db_base.DbTestCase):
|
||||
self.node.save()
|
||||
self._test_prepare_ramdisk(uefi=True)
|
||||
|
||||
@mock.patch.object(shutil, 'copyfile', autospec=True)
|
||||
def test_prepare_ramdisk_ipxe(self, copyfile_mock):
|
||||
def _prepare_ramdisk_ipxe(self):
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
self.config(group='pxe', ipxe_enabled=True)
|
||||
self.config(group='deploy', http_url='http://myserver')
|
||||
self._test_prepare_ramdisk()
|
||||
|
||||
@mock.patch.object(shutil, 'copyfile', autospec=True)
|
||||
def test_prepare_ramdisk_ipxe(self, copyfile_mock):
|
||||
self._prepare_ramdisk_ipxe()
|
||||
copyfile_mock.assert_called_once_with(
|
||||
CONF.pxe.ipxe_boot_script,
|
||||
os.path.join(
|
||||
CONF.deploy.http_root,
|
||||
os.path.basename(CONF.pxe.ipxe_boot_script)))
|
||||
|
||||
@mock.patch.object(os.path, 'exists', autospec=True)
|
||||
@mock.patch.object(shutil, 'copyfile', autospec=True)
|
||||
def test_prepare_ramdisk_ipxe_already_present(
|
||||
self, copyfile_mock, path_exists_mock):
|
||||
path_exists_mock.return_value = True
|
||||
self._prepare_ramdisk_ipxe()
|
||||
# Assert we don't copy the boot script again
|
||||
self.assertFalse(copyfile_mock.called)
|
||||
|
||||
def test_prepare_ramdisk_cleaning(self):
|
||||
self.node.provision_state = states.CLEANING
|
||||
self.node.save()
|
||||
|
Loading…
Reference in New Issue
Block a user