From 87c66644e8daa64008f9c23d3325c6bdb8857ce1 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Wed, 10 Jul 2013 15:38:24 +0400 Subject: [PATCH] Incorrect merging of lists in template files Change-Id: I884104f92304ea1fb9a538469f3c011ac15834e6 --- conductor/helpers.py | 12 +++++++++++- tools/pip-requires | 1 + tools/test-requires | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/conductor/helpers.py b/conductor/helpers.py index b22eec3..0e0b7b9 100644 --- a/conductor/helpers.py +++ b/conductor/helpers.py @@ -14,6 +14,7 @@ # limitations under the License. import types +import deep def transform_json(json, mappings): @@ -42,7 +43,16 @@ def transform_json(json, mappings): def merge_lists(list1, list2): - return list1 + list2 + result = [] + for item in list1 + list2: + exists = False + for old_item in result: + if deep.diff(item, old_item) is None: + exists = True + break + if not exists: + result.append(item) + return result def merge_dicts(dict1, dict2, max_levels=0): diff --git a/tools/pip-requires b/tools/pip-requires index ed21b98..4ea32bf 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -9,3 +9,4 @@ python-heatclient #http://tarballs.openstack.org/oslo-config/oslo-config-2013.1b4.tar.gz#egg=oslo-config oslo.config +deep diff --git a/tools/test-requires b/tools/test-requires index 842d565..37e0bec 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -7,4 +7,3 @@ nosexcover pep8 sphinx>=1.1.2 mockfs -deep