diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-23 15:53:37 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-23 15:53:37 -0400 |
commit | 740facb79c70cd8e3380e08acb4f5c5a285bb1ae (patch) | |
tree | 2799910293e02ff5ae77e51225e5e2888b5662cd /cloudinit | |
parent | 51fa67a88dc0dc631c19770142b16c0b56c21384 (diff) | |
download | vyos-cloud-init-740facb79c70cd8e3380e08acb4f5c5a285bb1ae.tar.gz vyos-cloud-init-740facb79c70cd8e3380e08acb4f5c5a285bb1ae.zip |
support [untested] network-config=<base64> on kernel command line
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/net/__init__.py | 18 |
1 files changed, 17 insertions, 1 deletions
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 <http://www.gnu.org/licenses/>. +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) |