Moving TaskResult and states to 'workflow' package

Change-Id: Iaa9a5514afdc7ad07f20cb373fd6c356f1391fa9
This commit is contained in:
Renat Akhmerov 2014-08-07 16:13:57 +07:00
parent 2b243d79aa
commit 4e71b1a69f
7 changed files with 22 additions and 23 deletions

View File

@ -19,20 +19,6 @@ import abc
import six 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) @six.add_metaclass(abc.ABCMeta)
class Engine(object): class Engine(object):
"""Engine interface.""" """Engine interface."""

View File

@ -18,10 +18,10 @@ from oslo.config import cfg
from mistral.db import api as db_api from mistral.db import api as db_api
from mistral.engine1 import base from mistral.engine1 import base
from mistral.engine1 import states
from mistral import exceptions as exc from mistral import exceptions as exc
from mistral.openstack.common import log as logging from mistral.openstack.common import log as logging
from mistral.workflow import selector as wf_selector from mistral.workflow import selector as wf_selector
from mistral.workflow import states
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
WF_TRACE = logging.getLogger(cfg.CONF.workflow_trace_log_name) WF_TRACE = logging.getLogger(cfg.CONF.workflow_trace_log_name)

View File

@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mistral.engine1 import states as s
from mistral.openstack.common import log as logging from mistral.openstack.common import log as logging
from mistral.tests import base from mistral.tests import base
from mistral.workflow import states as s
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,13 +15,12 @@
# limitations under the License. # limitations under the License.
from mistral.db.v2.sqlalchemy import models 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.openstack.common import log as logging
from mistral.tests import base from mistral.tests import base
from mistral.workbook import parser as spec_parser 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 reverse_workflow as r_wf
from mistral.workflow import states
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -92,7 +91,7 @@ class ReverseWorkflowHandlerTest(base.BaseTest):
# Emulate finishing 'task1'. # Emulate finishing 'task1'.
task_specs = self.handler.on_task_result( task_specs = self.handler.on_task_result(
task1_db, task1_db,
eng_base.TaskResult(data='Hey') wf_base.TaskResult(data='Hey')
) )
self.assertEqual(1, len(task_specs)) self.assertEqual(1, len(task_specs))
@ -107,7 +106,7 @@ class ReverseWorkflowHandlerTest(base.BaseTest):
task_specs = self.handler.on_task_result( task_specs = self.handler.on_task_result(
task2_db, task2_db,
eng_base.TaskResult(data='Hi!') wf_base.TaskResult(data='Hi!')
) )
self.assertEqual(0, len(task_specs)) self.assertEqual(0, len(task_specs))

View File

@ -13,10 +13,10 @@
# limitations under the License. # limitations under the License.
import abc import abc
from mistral.engine1 import states
from mistral import exceptions as exc from mistral import exceptions as exc
from mistral.openstack.common import log as logging from mistral.openstack.common import log as logging
from mistral.workbook import parser as spec_parser from mistral.workbook import parser as spec_parser
from mistral.workflow import states
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -96,6 +96,20 @@ class WorkflowHandler(object):
raise exc.WorkflowException(msg) 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): class FlowControl(object):
"""Flow control structure. """Flow control structure.

View File

@ -15,9 +15,9 @@
import networkx as nx import networkx as nx
from networkx.algorithms import traversal from networkx.algorithms import traversal
from mistral.engine1 import states
from mistral import exceptions as exc from mistral import exceptions as exc
from mistral.workflow import base from mistral.workflow import base
from mistral.workflow import states
class ReverseWorkflowHandler(base.WorkflowHandler): class ReverseWorkflowHandler(base.WorkflowHandler):