summaryrefslogtreecommitdiff
path: root/cloudinit/net/cmdline.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-05-16 13:43:55 -0400
committerScott Moser <smoser@brickies.net>2017-05-16 15:34:21 -0400
commit4bcc947301bedc5ebf430cfaf6e4597bfb174aa7 (patch)
tree166aacb426f156147d5e8f7cc693c1b99e8c3861 /cloudinit/net/cmdline.py
parent9d437489b8ce1f8cd9d34cd9ff4994ca18bd2d78 (diff)
downloadvyos-cloud-init-4bcc947301bedc5ebf430cfaf6e4597bfb174aa7.tar.gz
vyos-cloud-init-4bcc947301bedc5ebf430cfaf6e4597bfb174aa7.zip
Improve detection of snappy to include os-release and kernel cmdline.
Recent core snap images (edge channel revision 1886) do not contain the previously known files used to detect that a system is ubuntu core. The changes here are to look in 2 additional locations to determine if a system is snappy. LP: #1689944
Diffstat (limited to 'cloudinit/net/cmdline.py')
-rwxr-xr-xcloudinit/net/cmdline.py31
1 files changed, 1 insertions, 30 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 61e23697..38b27a52 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -9,41 +9,12 @@ import base64
import glob
import gzip
import io
-import shlex
-import sys
-
-import six
from . import get_devicelist
from . import read_sys_net_safe
from cloudinit import util
-PY26 = sys.version_info[0:2] == (2, 6)
-
-
-def _shlex_split(blob):
- if PY26 and isinstance(blob, six.text_type):
- # Older versions don't support unicode input
- blob = blob.encode("utf8")
- return shlex.split(blob)
-
-
-def _load_shell_content(content, add_empty=False, empty_val=None):
- """Given shell like syntax (key=value\nkey2=value2\n) in content
- return the data in dictionary form. If 'add_empty' is True
- then add entries in to the returned dictionary for 'VAR='
- variables. Set their value to empty_val."""
- data = {}
- for line in _shlex_split(content):
- key, value = line.split("=", 1)
- if not value:
- value = empty_val
- if add_empty or value:
- data[key] = value
-
- return data
-
def _klibc_to_config_entry(content, mac_addrs=None):
"""Convert a klibc written shell content file to a 'config' entry
@@ -63,7 +34,7 @@ def _klibc_to_config_entry(content, mac_addrs=None):
if mac_addrs is None:
mac_addrs = {}
- data = _load_shell_content(content)
+ data = util.load_shell_content(content)
try:
name = data['DEVICE'] if 'DEVICE' in data else data['DEVICE6']
except KeyError: