summaryrefslogtreecommitdiff
path: root/cloudinit/net/cmdline.py
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2019-07-26 20:40:18 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-07-26 20:40:18 +0000
commit496aaa947ec563bd02b3148f220ff0afe1b32abb (patch)
tree447ccd21a9d67a69ba40eae215feabf8039c6383 /cloudinit/net/cmdline.py
parent1dbede64dc645b090b4047a105143b5d5090d214 (diff)
downloadvyos-cloud-init-496aaa947ec563bd02b3148f220ff0afe1b32abb.tar.gz
vyos-cloud-init-496aaa947ec563bd02b3148f220ff0afe1b32abb.zip
net/cmdline: split interfaces_by_mac and init network config determination
Previously "cmdline" network configuration could be either user-specified network-config=... configuration data, or initramfs-provided configuration data. Before data sources could modify the order in which network config sources were considered, this conflation didn't matter (and, indeed, in the default data source configuration it will continue to not matter). However, it _is_ desirable for a data source to be able to specify that its network configuration should be preferred over the initramfs-provided network configuration but still allow explicit network-config=... configuration passed to the kernel cmdline to continue to override both of those sources. (This also modifies the Oracle data source to use read_initramfs_config directly, which is effectively what it was using read_kernel_cmdline_config for previously.)
Diffstat (limited to 'cloudinit/net/cmdline.py')
-rwxr-xr-xcloudinit/net/cmdline.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index f89a0f73..556a10f3 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -177,21 +177,13 @@ def _is_initramfs_netconfig(files, cmdline):
return False
-def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None):
+def read_initramfs_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():
- if tok.startswith("network-config="):
- data64 = tok.split("=", 1)[1]
- if data64:
- return util.load_yaml(_b64dgz(data64))
-
if not _is_initramfs_netconfig(files, cmdline):
return None
@@ -204,4 +196,19 @@ def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None):
return config_from_klibc_net_cfg(files=files, mac_addrs=mac_addrs)
+
+def read_kernel_cmdline_config(cmdline=None):
+ if cmdline is None:
+ cmdline = util.get_cmdline()
+
+ if 'network-config=' in cmdline:
+ data64 = None
+ for tok in cmdline.split():
+ if tok.startswith("network-config="):
+ data64 = tok.split("=", 1)[1]
+ if data64:
+ return util.load_yaml(_b64dgz(data64))
+
+ return None
+
# vi: ts=4 expandtab