Renamed Status to State
As we can see in the codebase, we have 3 "Status" enums which are located at: - watcher/objects/action.py - watcher/objects/action_plan.py - watcher/objects/audit.py So I renamed them from "Status" to "State" to be consistent with the DB schema. Change-Id: If3d180c9daba6ae9083775ad6813aa4c21763dbf Closes-Bug: #1522733
This commit is contained in:
@@ -22,7 +22,7 @@ from watcher.applier.action_plan import base
|
||||
from watcher.applier import default
|
||||
from watcher.applier.messaging import event_types
|
||||
from watcher.common.messaging.events import event
|
||||
from watcher import objects
|
||||
from watcher.objects import action_plan as ap_objects
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@@ -35,7 +35,7 @@ class DefaultActionPlanHandler(base.BaseActionPlanHandler):
|
||||
self.applier_manager = applier_manager
|
||||
|
||||
def notify(self, uuid, event_type, state):
|
||||
action_plan = objects.ActionPlan.get_by_uuid(self.ctx, uuid)
|
||||
action_plan = ap_objects.ActionPlan.get_by_uuid(self.ctx, uuid)
|
||||
action_plan.state = state
|
||||
action_plan.save()
|
||||
ev = event.Event()
|
||||
@@ -51,7 +51,7 @@ class DefaultActionPlanHandler(base.BaseActionPlanHandler):
|
||||
# update state
|
||||
self.notify(self.action_plan_uuid,
|
||||
event_types.EventTypes.LAUNCH_ACTION_PLAN,
|
||||
objects.action_plan.Status.ONGOING)
|
||||
ap_objects.State.ONGOING)
|
||||
applier = default.DefaultApplier(self.applier_manager, self.ctx)
|
||||
result = applier.execute(self.action_plan_uuid)
|
||||
except Exception as e:
|
||||
@@ -59,9 +59,9 @@ class DefaultActionPlanHandler(base.BaseActionPlanHandler):
|
||||
result = False
|
||||
finally:
|
||||
if result is True:
|
||||
status = objects.action_plan.Status.SUCCEEDED
|
||||
status = ap_objects.State.SUCCEEDED
|
||||
else:
|
||||
status = objects.action_plan.Status.FAILED
|
||||
status = ap_objects.State.FAILED
|
||||
# update state
|
||||
self.notify(self.action_plan_uuid,
|
||||
event_types.EventTypes.LAUNCH_ACTION_PLAN,
|
||||
|
||||
@@ -100,13 +100,13 @@ class TaskFlowActionContainer(task.Task):
|
||||
def pre_execute(self):
|
||||
try:
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.ONGOING)
|
||||
obj_action.State.ONGOING)
|
||||
LOG.debug("Precondition action %s", self.name)
|
||||
self.action.precondition()
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.FAILED)
|
||||
obj_action.State.FAILED)
|
||||
raise
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
@@ -117,17 +117,17 @@ class TaskFlowActionContainer(task.Task):
|
||||
result = self.action.execute()
|
||||
if result is not True:
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.FAILED)
|
||||
obj_action.State.FAILED)
|
||||
else:
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.SUCCEEDED)
|
||||
obj_action.State.SUCCEEDED)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
LOG.error(_LE('The WorkFlow Engine has failed '
|
||||
'to execute the action %s'), self.name)
|
||||
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.FAILED)
|
||||
obj_action.State.FAILED)
|
||||
raise
|
||||
|
||||
def post_execute(self):
|
||||
@@ -137,7 +137,7 @@ class TaskFlowActionContainer(task.Task):
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
self.engine.notify(self._db_action,
|
||||
obj_action.Status.FAILED)
|
||||
obj_action.State.FAILED)
|
||||
raise
|
||||
|
||||
def revert(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user