summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-09-12 12:32:08 -0400
committerScott Moser <smoser@brickies.net>2016-09-12 12:39:11 -0400
commit2aa9b1ddf80ffe7d35e8437c59670856d612e64e (patch)
treec848951aded34cab7437414b30c2170dc1bf2bd7 /cloudinit
parent97b5b40e14fd6563b9cac716f202891d4c38ecf6 (diff)
downloadvyos-cloud-init-2aa9b1ddf80ffe7d35e8437c59670856d612e64e.tar.gz
vyos-cloud-init-2aa9b1ddf80ffe7d35e8437c59670856d612e64e.zip
DataSourceOVF: fix user-data as base64 with python3
When user-data was provided in the ovf environment python3 would call base64.decodestring() with a string rather than bytes and an exception would occur. This fixes the broken path and adds unit test. Also changes to return None rather than empty string when there is no user-data and when there is user-data return that as bytes instead of string. LP: #1619394
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/sources/DataSourceOVF.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index 43347cfb..5b3bdb4e 100644
--- a/cloudinit/sources/DataSourceOVF.py
+++ b/cloudinit/sources/DataSourceOVF.py
@@ -237,7 +237,7 @@ def wait_for_imc_cfg_file(dirpath, filename, maxwait=180, naplen=5):
def read_vmware_imc(config):
md = {}
cfg = {}
- ud = ""
+ ud = None
if config.host_name:
if config.domain_name:
md['local-hostname'] = config.host_name + "." + config.domain_name
@@ -256,7 +256,7 @@ def read_ovf_environment(contents):
props = get_properties(contents)
md = {}
cfg = {}
- ud = ""
+ ud = None
cfg_props = ['password']
md_props = ['seedfrom', 'local-hostname', 'public-keys', 'instance-id']
for (prop, val) in props.items():
@@ -268,9 +268,9 @@ def read_ovf_environment(contents):
cfg[prop] = val
elif prop == "user-data":
try:
- ud = base64.decodestring(val)
+ ud = base64.b64decode(val.encode())
except Exception:
- ud = val
+ ud = val.encode()
return (md, ud, cfg)