From 740facb79c70cd8e3380e08acb4f5c5a285bb1ae Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 23 Mar 2016 15:53:37 -0400 Subject: support [untested] network-config= on kernel command line --- cloudinit/net/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index 4f6b4dfc..3a208e43 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Curtin. If not, see . +import base64 import errno import glob import os @@ -646,10 +647,25 @@ def generate_fallback_config(): return nconf -def read_kernel_cmdline_config(files=None, mac_addrs=None): +def read_kernel_cmdline_config(files=None, mac_addrs=None, 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(base64.b64decode(data64)) + + if 'ip=' not in cmdline: + return None + if mac_addrs is None: mac_addrs = {k: sys_netdev_info(k, 'address') for k in get_devicelist()} + return config_from_klibc_net_cfg(files=files, mac_addrs=mac_addrs) -- cgit v1.2.3