Use stored properties values in actions

During update, delete and signal operations, we set the properties of a
resource to the values stored in the database when they were last created
or updated, so that we don't resolve intrinsic functions to new values
caused by possible changes in live attribute values. In fact, since we
started requiring the resources' node data to be pre-populated into the
StackDefinition, we will get only placeholder values for attributes and
resource IDs if we tried to resolve live functions.

This change does the same for the suspend, resume, snapshot, and check
actions. Should any plugin's handler function for any of those actions read
the resource's properties (I'm not sure that any do) then they will now get
the stored values.

Change-Id: If6b6f66877e23b8538a97aa339357ca1a2a29276
This commit is contained in:
Zane Bitter 2017-06-28 20:53:10 -04:00
parent 2c3824436e
commit 6bc25ef0e0
1 changed files with 10 additions and 4 deletions

View File

@ -1629,7 +1629,9 @@ class Resource(status.ResourceStatus):
exc = Exception(_('Resource %s not created yet.') % self.name)
failure = exception.ResourceFailure(exc, self, action)
raise failure
return self._do_action(action)
with self.frozen_properties():
return self._do_action(action)
else:
reason = '%s not supported for %s' % (action, self.type())
self.state_set(action, self.COMPLETE, reason)
@ -1668,7 +1670,8 @@ class Resource(status.ResourceStatus):
raise exception.ResourceFailure(exc, self, action)
LOG.info('suspending %s', self)
return self._do_action(action)
with self.frozen_properties():
return self._do_action(action)
def resume(self):
"""Return a task to resume the resource.
@ -1686,13 +1689,16 @@ class Resource(status.ResourceStatus):
exc = exception.Error(_('State %s invalid for resume')
% six.text_type(self.state))
raise exception.ResourceFailure(exc, self, action)
LOG.info('resuming %s', self)
return self._do_action(action)
with self.frozen_properties():
return self._do_action(action)
def snapshot(self):
"""Snapshot the resource and return the created data, if any."""
LOG.info('snapshotting %s', self)
return self._do_action(self.SNAPSHOT)
with self.frozen_properties():
return self._do_action(self.SNAPSHOT)
@scheduler.wrappertask
def delete_snapshot(self, data):