Adjust the action state judgment logic

Only when True is returned, the action state is set to SUCCEEDED
some actions(such as migrate) will return None if exception raised

Change-Id: I52e7a1ffb68f54594f2b00d9843e8e0a4c985667
This commit is contained in:
licanwei
2017-08-07 00:50:03 -07:00
parent ffbd263888
commit 965af1b6fd
2 changed files with 34 additions and 5 deletions

View File

@@ -120,14 +120,15 @@ class TaskFlowActionContainer(base.BaseTaskFlowActionContainer):
def do_execute(self, *args, **kwargs):
LOG.debug("Running action: %s", self.name)
# NOTE: For result is False, set action state fail
# NOTE:Some actions(such as migrate) will return None when exception
# Only when True is returned, the action state is set to SUCCEEDED
result = self.action.execute()
if result is False:
return self.engine.notify(self._db_action,
objects.action.State.FAILED)
else:
if result is True:
return self.engine.notify(self._db_action,
objects.action.State.SUCCEEDED)
else:
return self.engine.notify(self._db_action,
objects.action.State.FAILED)
def do_post_execute(self):
LOG.debug("Post-condition action: %s", self.name)