diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-03-16 15:43:27 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-03-16 15:43:27 -0600 |
commit | de34dc7c467b318b2d04d065f8d752c7a530e155 (patch) | |
tree | 768e0401dcdb4d6c428b516abe853bfbd8a3086a /cloudinit/net | |
parent | 7ce839f846de705980839f9c7851bd0fd7353aad (diff) | |
download | vyos-cloud-init-de34dc7c467b318b2d04d065f8d752c7a530e155.tar.gz vyos-cloud-init-de34dc7c467b318b2d04d065f8d752c7a530e155.zip |
net: recognize iscsi root cases without ip= on kernel command line.
When 'ip=' or 'ip6=' is found on the kernel command line,
cloud-init will consider read network config from /run/net-*.conf files.
There are some iscsi-root scenarios where initramfs configures networking
but the ip= parameter is not present. 2 such cases are:
a.) static config in /etc/iscsi/iscsi.initramfs (copied into the
initramfs)
b.) iBft
This changes cloud-init to consider initramfs provided networking
information if:
* there are /run/net-* files and
* (ip= or ip6 is on the command line) or open-iscsi.interface file
exists.
LP: #1752391
Diffstat (limited to 'cloudinit/net')
-rwxr-xr-x | cloudinit/net/cmdline.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py index 7b2cc9db..9e9fe0fe 100755 --- a/cloudinit/net/cmdline.py +++ b/cloudinit/net/cmdline.py @@ -9,12 +9,15 @@ import base64 import glob import gzip import io +import os from . import get_devicelist from . import read_sys_net_safe from cloudinit import util +_OPEN_ISCSI_INTERFACE_FILE = "/run/initramfs/open-iscsi.interface" + def _klibc_to_config_entry(content, mac_addrs=None): """Convert a klibc written shell content file to a 'config' entry @@ -103,9 +106,13 @@ def _klibc_to_config_entry(content, mac_addrs=None): return name, iface +def _get_klibc_net_cfg_files(): + return glob.glob('/run/net-*.conf') + glob.glob('/run/net6-*.conf') + + def config_from_klibc_net_cfg(files=None, mac_addrs=None): if files is None: - files = glob.glob('/run/net-*.conf') + glob.glob('/run/net6-*.conf') + files = _get_klibc_net_cfg_files() entries = [] names = {} @@ -160,10 +167,23 @@ def _b64dgz(b64str, gzipped="try"): return _decomp_gzip(blob, strict=gzipped != "try") +def _is_initramfs_netconfig(files, cmdline): + if files: + if 'ip=' in cmdline or 'ip6=' in cmdline: + return True + if os.path.exists(_OPEN_ISCSI_INTERFACE_FILE): + # iBft can configure networking without ip= + return True + return False + + def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None): if cmdline is None: cmdline = util.get_cmdline() + if files is None: + files = _get_klibc_net_cfg_files() + if 'network-config=' in cmdline: data64 = None for tok in cmdline.split(): @@ -172,7 +192,7 @@ def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None): if data64: return util.load_yaml(_b64dgz(data64)) - if 'ip=' not in cmdline and 'ip6=' not in cmdline: + if not _is_initramfs_netconfig(files, cmdline): return None if mac_addrs is None: |