diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-02-25 16:11:51 +0000 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-02-27 17:28:39 +0000 |
commit | 226129ec54cdcbee879076c535c3834b98a07a9a (patch) | |
tree | e45b1540df7e2c16944dd2840dbeb1def0066945 /pxeboot.write | |
parent | 588917e4c52dff7d8650ca6480ed5bbf3916389b (diff) | |
download | definitions-226129ec54cdcbee879076c535c3834b98a07a9a.tar.gz |
pxeboot: add support for a PXE_INSTALLER option
If PXE_INSTALLER is set to `no` or `False`, the remotely installed
rootfs, Kernel, bootloader config file and device tree blob if
specified, will not be removed after the deployment finishes.
Diffstat (limited to 'pxeboot.write')
-rwxr-xr-x | pxeboot.write | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/pxeboot.write b/pxeboot.write index 0f541998..06c44a31 100755 --- a/pxeboot.write +++ b/pxeboot.write @@ -223,11 +223,13 @@ class PXEBoot(morphlib.writeexts.WriteExtension): @contextlib.contextmanager def _remote_tempdir(self, hostname, template): + persist = os.environ.get('PXE_INSTALLER') in ('no', 'False') td = cliapp.ssh_runcmd(hostname, ['mktemp', '-d', template]).strip() try: yield td finally: - cliapp.ssh_runcmd(hostname, ['find', td, '-delete']) + if not persist: + cliapp.ssh_runcmd(hostname, ['find', td, '-delete']) def _serve_tftpd(self, sock, host, port, interface, tftproot): self.settings.progname = 'tftp server' @@ -321,6 +323,7 @@ class PXEBoot(morphlib.writeexts.WriteExtension): @contextlib.contextmanager def _remote_copy(self, hostname, src, dst): + persist = os.environ.get('PXE_INSTALLER') in ('no', 'False') with open(src, 'r') as f: cliapp.ssh_runcmd(hostname, ['install', '-D', '-m644', '/proc/self/fd/0', @@ -328,17 +331,20 @@ class PXEBoot(morphlib.writeexts.WriteExtension): try: yield finally: - cliapp.ssh_runcmd(hostname, ['rm', dst]) + if not persist: + cliapp.ssh_runcmd(hostname, ['rm', dst]) @contextlib.contextmanager def _remote_symlink(self, hostname, src, dst): + persist = os.environ.get('PXE_INSTALLER') in ('no', 'False') cliapp.ssh_runcmd(hostname, ['ln', '-s', '-f', src, dst], stdin=None, stdout=None, stderr=None) try: yield finally: - cliapp.ssh_runcmd(hostname, ['rm', '-f', dst]) + if not persist: + cliapp.ssh_runcmd(hostname, ['rm', '-f', dst]) @contextlib.contextmanager def remote_kernel(self, rootfs, tftp_url, macaddr): @@ -713,9 +719,11 @@ class PXEBoot(morphlib.writeexts.WriteExtension): rootfs_nfsroot=nfsroot, rootfs_subpath=rootfs_subpath, macaddr=macaddr): - self.ipmi_pxe_reboot_target() - self.wait_for_target_to_install() - self.ipmi_reboot_target() + persist = os.environ.get('PXE_INSTALLER') in ('no', 'False') + if not persist: + self.ipmi_pxe_reboot_target() + self.wait_for_target_to_install() + self.ipmi_reboot_target() else: cliapp.AppException('Invalid PXEBOOT_MODE: %s' % mode) |