]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : Avoid writing to class-scope parameters schema
authorSteven Hardy <shardy@redhat.com>
Mon, 30 Jul 2012 17:53:23 +0000 (18:53 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 30 Jul 2012 17:59:25 +0000 (18:59 +0100)
Fixes issue where multiple instances of the same resource types
which have different parameters break, because the parser is
writing back to the class-scope properties_schema which should
be immutable.  This patch fixes by making a per-instance copy.

Fixes #183

Change-Id: Ia29f67465acbcfaf8dfe511ddaa9075bc48157ad
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/checkeddict.py

index 90a04174cee6c5e40de97ec399c7246b19a5e72f..daef65867f109e7437d4956a2b742f14588450c7 100644 (file)
@@ -15,6 +15,7 @@
 
 import collections
 import re
+from copy import deepcopy
 
 from heat.openstack.common import log as logging
 
@@ -28,7 +29,7 @@ class CheckedDict(collections.MutableMapping):
         self.name = name
 
     def addschema(self, key, schema):
-        self.data[key] = schema
+        self.data[key] = deepcopy(schema)
 
     def get_attr(self, key, attr):
         return self.data[key].get(attr, '')
@@ -156,7 +157,7 @@ class CheckedDict(collections.MutableMapping):
 class Properties(CheckedDict):
     def __init__(self, name, schema):
         CheckedDict.__init__(self, name)
-        self.data = schema
+        self.data = deepcopy(schema)
 
         # set some defaults
         for s in self.data: