Move implementation_signature to StackResource
We need to use common logic for the update determination which uses implementation_signature, so move the common code from TemplateResource to the StackResource base-class. Change-Id: Ibd64b3607721487be5b0562cdb54e6c76db51149 Partial-Bug: #1389499
This commit is contained in:
parent
9321b61d09
commit
f5221feb8b
|
@ -11,7 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from requests import exceptions
|
from requests import exceptions
|
||||||
|
@ -147,11 +146,7 @@ class TemplateResource(stack_resource.StackResource):
|
||||||
|
|
||||||
def implementation_signature(self):
|
def implementation_signature(self):
|
||||||
self._generate_schema(self.t)
|
self._generate_schema(self.t)
|
||||||
schema_names = ([prop for prop in self.properties_schema] +
|
return super(TemplateResource, self).implementation_signature()
|
||||||
[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())
|
|
||||||
|
|
||||||
def template_data(self):
|
def template_data(self):
|
||||||
# we want to have the latest possible template.
|
# we want to have the latest possible template.
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
from oslo.serialization import jsonutils
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -349,3 +352,10 @@ class StackResource(resource.Resource):
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
return self.get_output(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())
|
||||||
|
|
|
@ -135,6 +135,13 @@ class StackResourceTest(common.HeatTestCase):
|
||||||
preview = self.parent_resource.preview()
|
preview = self.parent_resource.preview()
|
||||||
self.assertIsInstance(preview, stack_resource.StackResource)
|
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):
|
def test_propagated_files(self):
|
||||||
self.parent_stack.t.files["foo"] = "bar"
|
self.parent_stack.t.files["foo"] = "bar"
|
||||||
self.parent_resource.create_with_template(self.templ,
|
self.parent_resource.create_with_template(self.templ,
|
||||||
|
|
Loading…
Reference in New Issue