summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorJay Faulkner <jay@jvf.cc>2014-08-26 15:12:35 -0700
committerJay Faulkner <jay@jvf.cc>2014-08-26 15:12:35 -0700
commit1e019cc001a8f31fa978d76b86fbe7813b2a076f (patch)
tree3ac9c736450a09fc457711317cbdd1fdd1129e5e /cloudinit/sources
parentdf7b6c5564e6ef8f5ceae9de8ff79410a4894f5f (diff)
downloadvyos-cloud-init-1e019cc001a8f31fa978d76b86fbe7813b2a076f.tar.gz
vyos-cloud-init-1e019cc001a8f31fa978d76b86fbe7813b2a076f.zip
Refactor vendor_data handling
vendor_data is guaranteed to be a dict if it exists; if it doesn't exist ensure it's represented by an empty dict to avoid checking it to see if it's a dict.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceConfigDrive.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index c55f7d4a..65477184 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -126,15 +126,12 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
self.version = results['version']
self.files.update(results.get('files', {}))
+ # If there is no vendordata, set vd to an empty dict instead of None
+ vd = results.get('vendordata', {})
# if vendordata includes 'cloud-init', then read that explicitly
# for cloud-init (for namespacing).
- vd = results.get('vendordata')
- if isinstance(vd, dict):
- if 'cloud-init' in vd:
- self.vendordata_raw = vd['cloud-init']
- else:
- # TODO(pquerna): this is so wrong.
- self.vendordata_raw = json.dumps(vd)
+ if 'cloud-init' in vd:
+ self.vendordata_raw = vd['cloud-init']
else:
self.vendordata_raw = vd