handle empty sections in environment files

If an environment file has an *empty* section, as in:

    parameter_defaults:

This would ultimately fail in deep_update (in
heatclient/common/template_utils.py), which would get called with old
== None.  This patch handles this situation by explicitly setting old
= {} if deep_update is called with old == None.

Change-Id: Ia7bee87cdb99e29c63c9dc163f8490fef3f24f24
Closes-bug: 1631408
This commit is contained in:
Lars Kellogg-Stedman
2016-10-07 11:05:59 -04:00
parent 7f0f66e4fe
commit 0d218c92be

View File

@@ -188,6 +188,12 @@ def normalise_file_path_to_url(path):
def deep_update(old, new):
'''Merge nested dictionaries.'''
# Prevents an error if in a previous iteration
# old[k] = None but v[k] = {...},
if old is None:
old = {}
for k, v in new.items():
if isinstance(v, collections.Mapping):
r = deep_update(old.get(k, {}), v)