summaryrefslogtreecommitdiff
path: root/cloudinit/net/cmdline.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2016-05-19 14:13:07 -0700
committerJoshua Harlow <harlowja@gmail.com>2016-05-19 14:13:07 -0700
commit880d9fc2f9c62abf19b1506595aa81e5417dea45 (patch)
tree6a53a8a5ac8ea1c53284aa610f98ddaab89c7f9f /cloudinit/net/cmdline.py
parentabb3c00fadefea8056c300faf141260e124a5064 (diff)
downloadvyos-cloud-init-880d9fc2f9c62abf19b1506595aa81e5417dea45.tar.gz
vyos-cloud-init-880d9fc2f9c62abf19b1506595aa81e5417dea45.zip
Adjust net module to be more isolated
This allows it to be used outside of cloudinit more easily in the future.
Diffstat (limited to 'cloudinit/net/cmdline.py')
-rw-r--r--cloudinit/net/cmdline.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index f5712533..b85d4b0a 100644
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -20,12 +20,25 @@ import base64
import glob
import gzip
import io
+import shlex
+import sys
+
+import six
from cloudinit.net import get_devicelist
from cloudinit.net import sys_netdev_info
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
@@ -33,7 +46,7 @@ def _load_shell_content(content, add_empty=False, empty_val=None):
then add entries in to the returned dictionary for 'VAR='
variables. Set their value to empty_val."""
data = {}
- for line in util.shlex_split(content):
+ for line in _shlex_split(content):
try:
key, value = line.split("=", 1)
except ValueError: