From 355f03eec21883935f47232b3e00a5cf1de1680b Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 12 Dec 2012 14:57:11 +0000 Subject: [PATCH] resource state_set, abstract update/store logic Abstract the DB update/store logic so the state_set function can be more cleanly overridden for AutoScalingGroupInstance ref bug 1089338 Change-Id: I02dc52068feaeed8ec8210269d9abb7b124f0a19 Signed-off-by: Steven Hardy --- heat/engine/resource.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index cc16e41b..bfca7a53 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -360,8 +360,8 @@ class Resource(object): except Exception as ex: logger.error('DB error %s' % str(ex)) - def state_set(self, new_state, reason="state changed"): - self.state, old_state = new_state, self.state + def _store_or_update(self, new_state, reason): + self.state = new_state self.state_description = reason if self.id is not None: @@ -381,6 +381,10 @@ class Resource(object): elif new_state == self.CREATE_IN_PROGRESS: self._store() + def state_set(self, new_state, reason="state changed"): + old_state = self.state + self._store_or_update(new_state, reason) + if new_state != old_state: self._add_event(new_state, reason) -- 2.45.2