diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-11-22 18:42:12 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-11-22 18:42:12 +0000 |
commit | 70b0a445c7ea8261ce90a513b1af3f6b80e805d9 (patch) | |
tree | df54d7fa6344592449298f1e7bb87f9565b9fed6 | |
parent | 7ca351e71b9fe22b169cf3f8c2d4cdd9067d754c (diff) | |
parent | 5664854f372b9810d040c615d8a678dbfdfb880e (diff) | |
download | heat-70b0a445c7ea8261ce90a513b1af3f6b80e805d9.tar.gz |
Merge "Move implementation_signature to StackResource" into stable/juno
-rw-r--r-- | heat/engine/resources/template_resource.py | 7 | ||||
-rw-r--r-- | heat/engine/stack_resource.py | 10 | ||||
-rw-r--r-- | heat/tests/test_stack_resource.py | 7 |
3 files changed, 18 insertions, 6 deletions
diff --git a/heat/engine/resources/template_resource.py b/heat/engine/resources/template_resource.py index e91a76974..816919fe0 100644 --- a/heat/engine/resources/template_resource.py +++ b/heat/engine/resources/template_resource.py @@ -11,7 +11,6 @@ # License for the specific language governing permissions and limitations # under the License. -import hashlib import json from requests import exceptions @@ -146,11 +145,7 @@ class TemplateResource(stack_resource.StackResource): def implementation_signature(self): self._generate_schema(self.t) - schema_names = ([prop for prop in self.properties_schema] + - [at for at in self.attributes_schema]) - schema_hash = hashlib.sha1(';'.join(schema_names)) - templ_hash = hashlib.sha1(self.template_data()) - return (schema_hash.hexdigest(), templ_hash.hexdigest()) + return super(TemplateResource, self).implementation_signature() def template_data(self): # we want to have the latest possible template. diff --git a/heat/engine/stack_resource.py b/heat/engine/stack_resource.py index fa2911203..195c814f8 100644 --- a/heat/engine/stack_resource.py +++ b/heat/engine/stack_resource.py @@ -11,7 +11,10 @@ # License for the specific language governing permissions and limitations # under the License. +import hashlib + from oslo.config import cfg +from oslo.serialization import jsonutils from heat.common import environment_format from heat.common import exception @@ -353,3 +356,10 @@ class StackResource(resource.Resource): def _resolve_attribute(self, name): return self.get_output(name) + + def implementation_signature(self): + schema_names = ([prop for prop in self.properties_schema] + + [at for at in self.attributes_schema]) + schema_hash = hashlib.sha1(';'.join(schema_names)) + templ_hash = hashlib.sha1(jsonutils.dumps(self.child_template())) + return (schema_hash.hexdigest(), templ_hash.hexdigest()) diff --git a/heat/tests/test_stack_resource.py b/heat/tests/test_stack_resource.py index 26e4ea720..1159b4c76 100644 --- a/heat/tests/test_stack_resource.py +++ b/heat/tests/test_stack_resource.py @@ -134,6 +134,13 @@ class StackResourceTest(HeatTestCase): preview = self.parent_resource.preview() self.assertIsInstance(preview, stack_resource.StackResource) + def test_implementation_signature(self): + self.parent_resource.child_template = mock.Mock( + return_value=self.simple_template) + sig1, sig2 = self.parent_resource.implementation_signature() + self.assertEqual('3700dc2ae6ff4f0a236e7477ad6b8d51157f2153', sig1) + self.assertEqual('efe1707e1bd7dda17b9e995d8a8cf3c057119c96', sig2) + def test_propagated_files(self): self.parent_stack.t.files["foo"] = "bar" self.parent_resource.create_with_template(self.templ, |