summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceGCE.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index 2da34a99..bebc9918 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -213,16 +213,15 @@ def read_md(address=None, platform_check=True):
if md['availability-zone']:
md['availability-zone'] = md['availability-zone'].split('/')[-1]
- encoding = instance_data.get('user-data-encoding')
- if encoding:
+ if 'user-data' in instance_data:
+ # instance_data was json, so values are all utf-8 strings.
+ ud = instance_data['user-data'].encode("utf-8")
+ encoding = instance_data.get('user-data-encoding')
if encoding == 'base64':
- md['user-data'] = b64decode(instance_data.get('user-data'))
- else:
+ ud = b64decode(ud)
+ elif encoding:
LOG.warning('unknown user-data-encoding: %s, ignoring', encoding)
-
- if 'user-data' in md:
- ret['user-data'] = md['user-data']
- del md['user-data']
+ ret['user-data'] = ud
ret['meta-data'] = md
ret['success'] = True