diff options
author | Pavlo Shchelokovskyy <pshchelokovskyy@mirantis.com> | 2016-08-17 18:09:07 +0300 |
---|---|---|
committer | Pavlo Shchelokovskyy <pshchelokovskyy@mirantis.com> | 2016-08-17 18:47:06 +0300 |
commit | 4a0767a14c1d2f7829ce6cd509622033494fea18 (patch) | |
tree | 963a3173fc14eaf54255a44d0327e4a818b07cc3 /ironic/drivers/modules | |
parent | 8783e8d0365cf6748b9d1c2ec93c0a7c63f84abc (diff) | |
download | ironic-4a0767a14c1d2f7829ce6cd509622033494fea18.tar.gz |
Copy iPXE script over only when needed
currently the iPXE boot script is overwritten on every `prepare_ramdisk`
call, which is inefficient.
Instead, copy it over only when it is missing from HTTPROOT or is
different from the one specified in the config.
The comparison is performed using `filecmp` from Python standard lib,
which in turn uses `os.stat()`, so although being not very strict,
comparison does not call to any extra utilities and is fast.
Change-Id: I1213fc9a9945e11f963d10f0581a7d69ef13ee53
Diffstat (limited to 'ironic/drivers/modules')
-rw-r--r-- | ironic/drivers/modules/pxe.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 45634a9f6..b6279e543 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -15,6 +15,7 @@ PXE Boot Interface """ +import filecmp import os import shutil @@ -413,13 +414,14 @@ class PXEBoot(base.BootInterface): """ node = task.node - # TODO(deva): optimize this if rerun on existing files if CONF.pxe.ipxe_enabled: # Copy the iPXE boot script to HTTP root directory 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.isfile(bootfile_path) or + not filecmp.cmp(CONF.pxe.ipxe_boot_script, bootfile_path)): + shutil.copyfile(CONF.pxe.ipxe_boot_script, bootfile_path) dhcp_opts = pxe_utils.dhcp_options_for_instance(task) provider = dhcp_factory.DHCPFactory() |