summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-24 17:09:32 (GMT)
committerBaserock Gerrit <gerrit@baserock.org>2015-04-28 18:14:59 (GMT)
commite441ea4d3956840b5181c104c785a4d44f4a3c2f (patch)
tree56d089296a46842d6b60d1b460357c065013a577
parent8ace3d897295e26d83c680db983093bd43a11b96 (diff)
downloaddefinitions-e441ea4d3956840b5181c104c785a4d44f4a3c2f.tar.gz
pxeboot: add support for PXEBOOT_TARGET_INTERFACE
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.write18
-rw-r--r--pxeboot.write.help12
2 files changed, 26 insertions, 4 deletions
diff --git a/pxeboot.write b/pxeboot.write
index 7e4a995..3a12ebc 100755..100644
--- a/pxeboot.write
+++ b/pxeboot.write
@@ -414,14 +414,20 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
os.path.basename(rootfs))
@staticmethod
- def _write_pxe_config(fh, kernel_tftp_url, rootfs_nfs_url,
+ def _write_pxe_config(fh, kernel_tftp_url, rootfs_nfs_url, device=None,
fdt_subpath=None, extra_args=''):
+
+ if device is None:
+ ip_cfg = "ip=dhcp"
+ else:
+ ip_cfg = "ip=:::::{device}:dhcp::".format(device=device)
+
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))
@@ -429,7 +435,7 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
@contextlib.contextmanager
def local_pxeboot_config(self, tftproot, macaddr, ip, tftp_port,
- nfsroot_dir):
+ nfsroot_dir, device=None):
kernel_tftp_url = 'tftp://{}:{}/kernel'.format(ip, tftp_port)
rootfs_nfs_url = '{}:{}'.format(ip, nfsroot_dir)
pxe_cfg_filename = _normalise_macaddr(macaddr)
@@ -438,6 +444,7 @@ class PXEBoot(morphlib.writeexts.WriteExtension):
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,
+ device=device,
extra_args=os.environ.get('KERNEL_ARGS',''))
try:
@@ -637,6 +644,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')
@@ -662,6 +670,7 @@ 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,
+ device=target_interface,
ip=host_ip, tftp_port=tftp_port,
nfsroot_dir=temp_root), \
self.dhcp_server(interface=interface, host_ip=host_ip,
@@ -682,6 +691,7 @@ 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,
+ device=target_interface,
ip=host_ip, tftp_port=tftp_port,
nfsroot_dir=temp_root), \
self.dhcp_server(interface=interface, host_ip=host_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.