summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-24 17:09:32 (GMT)
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-28 12:56:24 (GMT)
commitbca42f14a057e36c5e23eed903697f4f3cd186c4 (patch)
tree6bd35897373fd5e4820c5e71e28f9fad381cb369
parent4b1e96facb0a91ae5a1375f08226b15f87b8f5bc (diff)
downloaddefinitions-baserock/pedroalvarez/pxeboot-fixes.tar.gz
pxeboot: add support for PXEBOOT_TARGET_INTERFACEbaserock/pedroalvarez/pxeboot-fixes
This is to set the name of the interface of the target to pxeboot from. Some targets with more than one interface try to get the rootfs from a different interface than the interface from where the pxeboot server is reachable. Using this variable, the kernel arguments will be filled to include the device. Change-Id: I022bf6b17a66d63f7f9b8830e72ca4020158a80a
-rw-r--r--[-rwxr-xr-x]pxeboot.write29
-rw-r--r--pxeboot.write.help12
2 files changed, 33 insertions, 8 deletions
diff --git a/pxeboot.write b/pxeboot.write
index c8d8bc4..be88436 100755..100644
--- a/pxeboot.write
+++ b/pxeboot.write
@@ -407,29 +407,39 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
@staticmethod
def _write_pxe_config(fh, kernel_tftp_url, rootfs_nfs_url,
+ host_ip=None, device=None, target_ip=None,
fdt_subpath=None, extra_args=''):
+
+ if device is None:
+ ip_cfg = "ip=dhcp"
+ else:
+ ip_cfg = "ip=:::::{device}:dhcp::".format(
+ device=device, host_ip=host_ip, target_ip=target_ip)
+
fh.write(textwrap.dedent('''\
DEFAULT default
LABEL default
LINUX {kernel_url}
- APPEND root=/dev/nfs ip=dhcp nfsroot={rootfs_nfs_url} {extra_args}
- ''').format(kernel_url=kernel_tftp_url,
+ APPEND root=/dev/nfs {ip_cfg} nfsroot={rootfs_nfs_url} {extra_args}
+ ''').format(kernel_url=kernel_tftp_url, ip_cfg=ip_cfg,
rootfs_nfs_url=rootfs_nfs_url, extra_args=extra_args))
if fdt_subpath is not None:
fh.write("FDT {}\n".format(fdt_subpath))
fh.flush()
@contextlib.contextmanager
- def local_pxeboot_config(self, tftproot, macaddr, ip, tftp_port,
- nfsroot_dir):
- kernel_tftp_url = 'tftp://{}:{}/kernel'.format(ip, tftp_port)
- rootfs_nfs_url = '{}:{}'.format(ip, nfsroot_dir)
+ def local_pxeboot_config(self, tftproot, macaddr, host_ip, tftp_port,
+ nfsroot_dir, device=None, target_ip=None):
+ kernel_tftp_url = 'tftp://{}:{}/kernel'.format(host_ip, tftp_port)
+ rootfs_nfs_url = '{}:{}'.format(host_ip, nfsroot_dir)
pxe_cfg_filename = _normalise_macaddr(macaddr)
pxe_cfg_path = os.path.join(tftproot, 'pxelinux.cfg', pxe_cfg_filename)
os.makedirs(os.path.dirname(pxe_cfg_path))
with open(pxe_cfg_path, 'w') as f:
self._write_pxe_config(fh=f, kernel_tftp_url=kernel_tftp_url,
rootfs_nfs_url=rootfs_nfs_url,
+ host_ip=host_ip, device=device,
+ target_ip=target_ip,
extra_args=os.environ.get('KERNEL_ARGS',''))
pxe_cfg_link_path = os.path.join (tftproot,
@@ -631,6 +641,7 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
def process_args(self, (temp_root, macaddr)):
interface = os.environ.get('PXEBOOT_DEPLOYER_INTERFACE', None)
+ target_interface = os.environ.get('PXEBOOT_TARGET_INTERFACE', None)
vlan = os.environ.get('PXEBOOT_VLAN')
if vlan is not None: vlan = int(vlan)
mode = os.environ.get('PXEBOOT_MODE')
@@ -656,7 +667,8 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
self.local_kernel(rootfs=temp_root, tftproot=tftproot), \
self.local_nfsroot(rootfs=temp_root, target_ip=target_ip), \
self.local_pxeboot_config(tftproot=tftproot, macaddr=macaddr,
- ip=host_ip, tftp_port=tftp_port,
+ device=target_interface, target_ip=target_ip,
+ host_ip=host_ip, tftp_port=tftp_port,
nfsroot_dir=temp_root), \
self.dhcp_server(interface=interface, host_ip=host_ip,
target_ip=target_ip,
@@ -676,7 +688,8 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
self.local_kernel(rootfs=temp_root, tftproot=tftproot), \
self.local_nfsroot(rootfs=temp_root, target_ip=target_ip), \
self.local_pxeboot_config(tftproot=tftproot, macaddr=macaddr,
- ip=host_ip, tftp_port=tftp_port,
+ device=target_interface, target_ip=target_ip,
+ host_ip=host_ip, tftp_port=tftp_port,
nfsroot_dir=temp_root), \
self.dhcp_server(interface=interface, host_ip=host_ip,
target_ip=target_ip,
diff --git a/pxeboot.write.help b/pxeboot.write.help
index 3aefe75..7cb78bc 100644
--- a/pxeboot.write.help
+++ b/pxeboot.write.help
@@ -152,3 +152,15 @@ help: >
device tree blob if specified, will not be removed after the
deployment finishes. This variable is only meanful on the
`existing-server` mode.
+
+
+ ## PXEBOOT_TARGET_INTERFACE
+
+ Name of the interface of the target to pxeboot from. Some targets
+ with more than one interface try to get the rootfs from a different
+ interface than the interface from where the pxeboot server is
+ reachable. Using this variable, the kernel arguments will be filled
+ to include the device.
+
+ Note that the name of this interface is the kernel's default name,
+ usually called ethX, and is non-determinisic.