Пример #1
0
def create_workflow_definition(values, session=None):
    wf_def = models.WorkflowDefinition()

    wf_def.update(values.copy())

    try:
        wf_def.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntryError(
            "Duplicate entry for WorkflowDefinition: %s" % e.columns)

    return wf_def
Пример #2
0
def create_workflow_definition(values, session=None):
    wf_def = models.WorkflowDefinition()

    wf_def.update(values.copy())

    try:
        wf_def.save(session=session)
    except db_exc.DBDuplicateEntry:
        raise exc.DBDuplicateEntryError(
            "Duplicate entry for WorkflowDefinition ['name', 'namespace',"
            " 'project_id']: {}, {}, {}".format(wf_def.name, wf_def.namespace,
                                                wf_def.project_id))
    return wf_def
import mock
import sqlalchemy as sa

from mistral.db.v2 import api as db_api
from mistral.db.v2.sqlalchemy import models
from mistral import exceptions as exc
from mistral.services import security
from mistral.services import triggers
from mistral.tests.unit.api import base
from mistral.tests.unit import base as unit_base

WF = models.WorkflowDefinition(spec={
    'version': '2.0',
    'name': 'my_wf',
    'tasks': {
        'task1': {
            'action': 'std.noop'
        }
    }
})
WF.update({'id': '123e4567-e89b-12d3-a456-426655440000', 'name': 'my_wf'})

TRIGGER = {
    'id': '09cc56a9-d15e-4494-a6e2-c4ec8bdaacae',
    'name': 'my_event_trigger',
    'workflow_id': '123e4567-e89b-12d3-a456-426655440000',
    'workflow_input': '{}',
    'workflow_params': '{}',
    'scope': 'private',
    'exchange': 'openstack',
    'topic': 'notification',
Пример #4
0
version: '2.0'

flow:
  type: direct
  input:
    - param1

  tasks:
    task1:
      action: std.echo output="Hi"
"""

WF_DB = models.WorkflowDefinition(
    id='123e4567-e89b-12d3-a456-426655440000',
    name='flow',
    definition=WF_DEFINITION,
    created_at=datetime.datetime(1970, 1, 1),
    updated_at=datetime.datetime(1970, 1, 1),
    spec={'input': ['param1']}
)

WF = {
    'id': '123e4567-e89b-12d3-a456-426655440000',
    'name': 'flow',
    'definition': WF_DEFINITION,
    'created_at': '1970-01-01 00:00:00',
    'updated_at': '1970-01-01 00:00:00',
    'input': 'param1'
}


MOCK_WF = mock.MagicMock(return_value=WF_DB)
Пример #5
0
    'id': '123e4567-e89b-12d3-a456-426655440000',
    'name': 'flow',
    'definition': '',
    'created_at': '1970-01-01 00:00:00',
    'updated_at': '1970-01-01 00:00:00',
}

ACTION_DB = models.ActionDefinition()
ACTION_DB.update(ACTION)

WORKBOOK_DB = models.Workbook()
WORKBOOK_DB.update(WORKBOOK)

WB_DB_WITH_NAMESPACE = models.Workbook(**WB_WITH_NAMESPACE)

WF_DB = models.WorkflowDefinition()
WF_DB.update(WF)

WORKBOOK_DB_PROJECT_ID = WORKBOOK_DB.get_clone()
WORKBOOK_DB_PROJECT_ID.project_id = '<default-project>'

UPDATED_WORKBOOK_DB = copy.copy(WORKBOOK_DB)
UPDATED_WORKBOOK_DB['definition'] = UPDATED_WORKBOOK_DEF
UPDATED_WORKBOOK = copy.deepcopy(WORKBOOK)
UPDATED_WORKBOOK['definition'] = UPDATED_WORKBOOK_DEF

WB_DEF_INVALID_MODEL_EXCEPTION = """
---
version: '2.0'
name: 'book'
Пример #6
0
---
version: '2.0'

flow:
  type: direct
  input:
    - param1

  tasks:
    task1:
      action: std.echo output="Hi"
"""

WF_DB = models.WorkflowDefinition(id='123e4567-e89b-12d3-a456-426655440000',
                                  name='flow',
                                  definition=WF_DEFINITION,
                                  created_at=datetime.datetime(1970, 1, 1),
                                  updated_at=datetime.datetime(1970, 1, 1),
                                  spec={'input': ['param1']})

WF_DB_SYSTEM = WF_DB.get_clone()
WF_DB_SYSTEM.is_system = True

WF = {
    'id': '123e4567-e89b-12d3-a456-426655440000',
    'name': 'flow',
    'definition': WF_DEFINITION,
    'created_at': '1970-01-01 00:00:00',
    'updated_at': '1970-01-01 00:00:00',
    'input': 'param1'
}
Пример #7
0
version: '2.0'

flow:
  type: direct
  input:
    - param1

  tasks:
    task1:
      action: std.echo output="Hi"
"""

WF_DB = models.WorkflowDefinition(
    name='flow',
    definition=WF_DEFINITION,
    created_at=datetime.datetime(1970, 1, 1),
    updated_at=datetime.datetime(1970, 1, 1),
    spec={'input': ['param1']}
)

WF = {
    'name': 'flow',
    'definition': WF_DEFINITION,
    'created_at': '1970-01-01 00:00:00',
    'updated_at': '1970-01-01 00:00:00',
    'input': 'param1'
}

WF_DEFINITION_WITH_INPUT = """
---
version: '2.0'