summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-02-24 14:58:57 (GMT)
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-02-27 17:28:39 (GMT)
commita6d7d3a8537215d0315a8dad66565ba26294b8b8 (patch)
treec7c8224dfd8944ceaf847433b8674e5cdf8a8f6b
parent7298d113860abb651fabdeaf35b5bcbda20cbe5a (diff)
downloaddefinitions-a6d7d3a8537215d0315a8dad66565ba26294b8b8.tar.gz
pxeboot: support u-boot pxe configuration file lookup
u-boot will look for a pxelinux configuration file on the TFTP server whose name corresponds to the normalized MAC address of the NIC prefixed with '01-' (Leading 01 means Ethernet). This support is only being added to remote deployments for now.
-rwxr-xr-xpxeboot.write31
1 files changed, 24 insertions, 7 deletions
diff --git a/pxeboot.write b/pxeboot.write
index c214808..3fdda5f 100755
--- a/pxeboot.write
+++ b/pxeboot.write
@@ -331,6 +331,16 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
cliapp.ssh_runcmd(hostname, ['rm', dst])
@contextlib.contextmanager
+ def _remote_symlink(self, hostname, src, dst):
+ 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])
+
+ @contextlib.contextmanager
def remote_kernel(self, rootfs, tftp_url, macaddr):
for name in ('vmlinuz', 'zImage', 'uImage'):
kernel_path = os.path.join(rootfs, 'boot', name)
@@ -408,14 +418,21 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
kernel_tftp_url = '{}/{}'.format(kernel_tftproot, kernel_subpath)
pxe_cfg_filename = _normalise_macaddr(macaddr)
url = urlparse.urlsplit(tftproot)
- inst_cfg_path = os.path.join(url.path, 'pxelinux.cfg',
- pxe_cfg_filename)
+ inst_cfg_path = os.path.join(url.path, 'pxelinux.cfg')
with tempfile.NamedTemporaryFile() as f:
- self._write_pxe_config(fh=f, kernel_tftp_url=kernel_tftp_url,
- rootfs_nfs_url=rootfs_nfs_url,
- extra_args=os.environ.get('KERNEL_ARGS',''))
- with self._remote_copy(hostname=url.hostname, src=f.name,
- dst=inst_cfg_path):
+ self._write_pxe_config(
+ fh=f, kernel_tftp_url=kernel_tftp_url,
+ rootfs_nfs_url=rootfs_nfs_url,
+ extra_args=os.environ.get('KERNEL_ARGS',''))
+ with self._remote_copy(
+ hostname=url.hostname, src=f.name,
+ dst=os.path.join(inst_cfg_path,
+ pxe_cfg_filename)), \
+ self._remote_symlink(
+ hostname=url.hostname,
+ src=pxe_cfg_filename,
+ dst=os.path.join(inst_cfg_path,
+ '01-' + pxe_cfg_filename)):
yield
@contextlib.contextmanager