From 4e71b1a69f2ed17ca660de6ed50553f8d1202f5a Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 7 Aug 2014 16:13:57 +0700 Subject: [PATCH] Moving TaskResult and states to 'workflow' package Change-Id: Iaa9a5514afdc7ad07f20cb373fd6c356f1391fa9 --- mistral/engine1/base.py | 14 -------------- mistral/engine1/default_engine.py | 2 +- mistral/tests/unit/engine1/test_states.py | 2 +- .../tests/unit/workflow/test_reverse_workflow.py | 9 ++++----- mistral/workflow/base.py | 16 +++++++++++++++- mistral/workflow/reverse_workflow.py | 2 +- mistral/{engine1 => workflow}/states.py | 0 7 files changed, 22 insertions(+), 23 deletions(-) rename mistral/{engine1 => workflow}/states.py (100%) diff --git a/mistral/engine1/base.py b/mistral/engine1/base.py index 10ef70913..0fb3326ad 100644 --- a/mistral/engine1/base.py +++ b/mistral/engine1/base.py @@ -19,20 +19,6 @@ import abc import six -class TaskResult(object): - """Explicit data structure containing a result of task execution.""" - - def __init__(self, data=None, error=None): - self.data = data - self.error = error - - def is_error(self): - return self.error is not None - - def is_success(self): - return not self.is_error() - - @six.add_metaclass(abc.ABCMeta) class Engine(object): """Engine interface.""" diff --git a/mistral/engine1/default_engine.py b/mistral/engine1/default_engine.py index d01f6c47d..12e4c55e4 100644 --- a/mistral/engine1/default_engine.py +++ b/mistral/engine1/default_engine.py @@ -18,10 +18,10 @@ from oslo.config import cfg from mistral.db import api as db_api from mistral.engine1 import base -from mistral.engine1 import states from mistral import exceptions as exc from mistral.openstack.common import log as logging from mistral.workflow import selector as wf_selector +from mistral.workflow import states LOG = logging.getLogger(__name__) WF_TRACE = logging.getLogger(cfg.CONF.workflow_trace_log_name) diff --git a/mistral/tests/unit/engine1/test_states.py b/mistral/tests/unit/engine1/test_states.py index a30d51613..0b2097427 100644 --- a/mistral/tests/unit/engine1/test_states.py +++ b/mistral/tests/unit/engine1/test_states.py @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mistral.engine1 import states as s from mistral.openstack.common import log as logging from mistral.tests import base +from mistral.workflow import states as s LOG = logging.getLogger(__name__) diff --git a/mistral/tests/unit/workflow/test_reverse_workflow.py b/mistral/tests/unit/workflow/test_reverse_workflow.py index cc2f491a9..38013203a 100644 --- a/mistral/tests/unit/workflow/test_reverse_workflow.py +++ b/mistral/tests/unit/workflow/test_reverse_workflow.py @@ -15,13 +15,12 @@ # limitations under the License. from mistral.db.v2.sqlalchemy import models -# TODO(rakhmerov): Should the next two be in package 'workflow'? -from mistral.engine1 import base as eng_base -from mistral.engine1 import states from mistral.openstack.common import log as logging from mistral.tests import base from mistral.workbook import parser as spec_parser +from mistral.workflow import base as wf_base from mistral.workflow import reverse_workflow as r_wf +from mistral.workflow import states LOG = logging.getLogger(__name__) @@ -92,7 +91,7 @@ class ReverseWorkflowHandlerTest(base.BaseTest): # Emulate finishing 'task1'. task_specs = self.handler.on_task_result( task1_db, - eng_base.TaskResult(data='Hey') + wf_base.TaskResult(data='Hey') ) self.assertEqual(1, len(task_specs)) @@ -107,7 +106,7 @@ class ReverseWorkflowHandlerTest(base.BaseTest): task_specs = self.handler.on_task_result( task2_db, - eng_base.TaskResult(data='Hi!') + wf_base.TaskResult(data='Hi!') ) self.assertEqual(0, len(task_specs)) diff --git a/mistral/workflow/base.py b/mistral/workflow/base.py index 2d167d950..4635fe228 100644 --- a/mistral/workflow/base.py +++ b/mistral/workflow/base.py @@ -13,10 +13,10 @@ # limitations under the License. import abc -from mistral.engine1 import states from mistral import exceptions as exc from mistral.openstack.common import log as logging from mistral.workbook import parser as spec_parser +from mistral.workflow import states LOG = logging.getLogger(__name__) @@ -96,6 +96,20 @@ class WorkflowHandler(object): raise exc.WorkflowException(msg) +class TaskResult(object): + """Explicit data structure containing a result of task execution.""" + + def __init__(self, data=None, error=None): + self.data = data + self.error = error + + def is_error(self): + return self.error is not None + + def is_success(self): + return not self.is_error() + + class FlowControl(object): """Flow control structure. diff --git a/mistral/workflow/reverse_workflow.py b/mistral/workflow/reverse_workflow.py index 483c28325..6e5acd8ea 100644 --- a/mistral/workflow/reverse_workflow.py +++ b/mistral/workflow/reverse_workflow.py @@ -15,9 +15,9 @@ import networkx as nx from networkx.algorithms import traversal -from mistral.engine1 import states from mistral import exceptions as exc from mistral.workflow import base +from mistral.workflow import states class ReverseWorkflowHandler(base.WorkflowHandler): diff --git a/mistral/engine1/states.py b/mistral/workflow/states.py similarity index 100% rename from mistral/engine1/states.py rename to mistral/workflow/states.py