Add _needs_update() to OS::Heat::TestResource resource

This will enable update-preview to see if the resource will be replaced
during a particular stack-update.

Change-Id: I613f176570e6f0d873c83e1826d2b0b285eb3b8e
Partial-Bug: #1494436
This commit is contained in:
Jason Dunsmore 2015-09-14 15:59:20 -05:00
parent 9038df0936
commit 113b0a4948
1 changed files with 22 additions and 10 deletions

View File

@ -150,21 +150,33 @@ class TestResource(resource.Resource):
return timeutils.utcnow(), self._wait_secs()
def _needs_update(self, after, before, after_props, before_props,
prev_resource, check_init_complete=True):
result = super(TestResource, self)._needs_update(
after, before, after_props, before_props, prev_resource,
check_init_complete=check_init_complete)
prop_diff = self.update_template_diff_properties(after_props,
before_props)
if self.UPDATE_REPLACE in prop_diff:
update_replace = prop_diff.get(self.UPDATE_REPLACE)
if update_replace:
raise exception.UpdateReplace(self.name)
return result
def handle_update(self, json_snippet=None, tmpl_diff=None, prop_diff=None):
self.properties = json_snippet.properties(self.properties_schema,
self.context)
value = prop_diff.get(self.VALUE)
if value:
update_replace = self.properties[self.UPDATE_REPLACE]
if update_replace:
raise exception.UpdateReplace(self.name)
else:
# emulate failure
fail_prop = self.properties[self.FAIL]
if not fail_prop:
# update in place
self.data_set('value', value, redact=False)
return timeutils.utcnow(), self._wait_secs()
# emulate failure
fail_prop = self.properties[self.FAIL]
if not fail_prop:
# update in place
self.data_set('value', value, redact=False)
return timeutils.utcnow(), self._wait_secs()
return timeutils.utcnow(), 0
def handle_delete(self):