summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-02-25 16:11:51 (GMT)
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-02-27 17:28:39 (GMT)
commit226129ec54cdcbee879076c535c3834b98a07a9a (patch)
treee45b1540df7e2c16944dd2840dbeb1def0066945
parent588917e4c52dff7d8650ca6480ed5bbf3916389b (diff)
downloaddefinitions-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.
-rwxr-xr-xpxeboot.write20
-rw-r--r--pxeboot.write.help10
2 files changed, 24 insertions, 6 deletions
diff --git a/pxeboot.write b/pxeboot.write
index 0f54199..06c44a3 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)
diff --git a/pxeboot.write.help b/pxeboot.write.help
index 0e5242c..3aefe75 100644
--- a/pxeboot.write.help
+++ b/pxeboot.write.help
@@ -142,3 +142,13 @@ help: >
Location in the deployed root filesystem of the Flattened Device
Tree blob (FDT) to use.
+
+
+ ## PXE_INSTALLER
+
+
+ If set to `no`, `False` or any other YAML value for false, the
+ remotely installed rootfs, kernel, bootloader config file and
+ device tree blob if specified, will not be removed after the
+ deployment finishes. This variable is only meanful on the
+ `existing-server` mode.