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.
This commit is contained in:
parent
40364de38d
commit
db76f6fc88
@ -126,15 +126,12 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
|
|||||||
self.version = results['version']
|
self.version = results['version']
|
||||||
self.files.update(results.get('files', {}))
|
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
|
# if vendordata includes 'cloud-init', then read that explicitly
|
||||||
# for cloud-init (for namespacing).
|
# for cloud-init (for namespacing).
|
||||||
vd = results.get('vendordata')
|
if 'cloud-init' in vd:
|
||||||
if isinstance(vd, dict):
|
self.vendordata_raw = vd['cloud-init']
|
||||||
if 'cloud-init' in vd:
|
|
||||||
self.vendordata_raw = vd['cloud-init']
|
|
||||||
else:
|
|
||||||
# TODO(pquerna): this is so wrong.
|
|
||||||
self.vendordata_raw = json.dumps(vd)
|
|
||||||
else:
|
else:
|
||||||
self.vendordata_raw = vd
|
self.vendordata_raw = vd
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user