Renaming 'parameters' to 'input' everywhere

* 'parameters' was not consistent with 'output' for actions
  and workflows.

Change-Id: I74cbf7db37b0908225b97a60433b7da8c3c69b05
This commit is contained in:
Renat Akhmerov 2014-09-21 19:34:28 -07:00
parent f6fad04c59
commit fcd45511d8
27 changed files with 128 additions and 116 deletions

View File

@ -45,7 +45,7 @@ class Task(resource.Resource):
state = wtypes.text state = wtypes.text
result = wtypes.text result = wtypes.text
parameters = wtypes.text input = wtypes.text
output = wtypes.text output = wtypes.text
created_at = wtypes.text created_at = wtypes.text
@ -59,7 +59,7 @@ class Task(resource.Resource):
if hasattr(e, key): if hasattr(e, key):
# Nonetype check for dictionary must be explicit # Nonetype check for dictionary must be explicit
if val is not None and ( if val is not None and (
key == 'parameters' or key == 'output'): key == 'input' or key == 'output'):
val = json.dumps(val) val = json.dumps(val)
setattr(e, key, val) setattr(e, key, val)
@ -75,7 +75,7 @@ class Task(resource.Resource):
# TODO(everyone): replace with states.SUCCESS # TODO(everyone): replace with states.SUCCESS
state='SUCCESS', state='SUCCESS',
tags=['foo', 'fee'], tags=['foo', 'fee'],
parameters='{"first_name": "John", "last_name": "Doe"}', input='{"first_name": "John", "last_name": "Doe"}',
output='{"task": {"build_greeting": ' output='{"task": {"build_greeting": '
'{"greeting": "Hello, John Doe!"}}}', '{"greeting": "Hello, John Doe!"}}}',
created_at='1970-01-01T00:00:00.000000', created_at='1970-01-01T00:00:00.000000',

View File

@ -98,7 +98,7 @@ class Task(mb.MistralModelBase):
# Data Flow properties. # Data Flow properties.
in_context = sa.Column(st.JsonDictType()) in_context = sa.Column(st.JsonDictType())
parameters = sa.Column(st.JsonDictType()) input = sa.Column(st.JsonDictType())
output = sa.Column(st.JsonDictType()) output = sa.Column(st.JsonDictType())
# Runtime context like iteration_no of a repeater. # Runtime context like iteration_no of a repeater.
@ -148,7 +148,7 @@ class Action(mb.MistralModelBase):
id = mb.id_column() id = mb.id_column()
name = sa.Column(sa.String(200)) name = sa.Column(sa.String(200))
description = sa.Column(sa.Text()) description = sa.Column(sa.Text())
parameters = sa.Column(sa.String(240)) input = sa.Column(sa.String(240))
# Ad-hoc action properties. # Ad-hoc action properties.
definition = sa.Column(sa.Text(), nullable=True) definition = sa.Column(sa.Text(), nullable=True)

View File

@ -64,7 +64,7 @@ class RunTask(EngineCommand):
self.task_db = self._create_db_task(exec_db) self.task_db = self._create_db_task(exec_db)
# Evaluate Data Flow properties ('parameters', 'in_context'). # Evaluate Data Flow properties ('input', 'in_context').
data_flow.prepare_db_task( data_flow.prepare_db_task(
self.task_db, self.task_db,
self.task_spec, self.task_spec,
@ -83,7 +83,7 @@ class RunTask(EngineCommand):
'name': self.task_spec.get_name(), 'name': self.task_spec.get_name(),
'state': states.RUNNING, 'state': states.RUNNING,
'spec': self.task_spec.to_dict(), 'spec': self.task_spec.to_dict(),
'parameters': None, 'input': None,
'in_context': None, 'in_context': None,
'output': None, 'output': None,
'runtime_context': None 'runtime_context': None
@ -111,7 +111,7 @@ class RunTask(EngineCommand):
action_spec_name action_spec_name
) )
action_params = self.task_db.parameters or {} action_input = self.task_db.input or {}
if action_db.spec: if action_db.spec:
# Ad-hoc action. # Ad-hoc action.
@ -125,21 +125,21 @@ class RunTask(EngineCommand):
base_name base_name
) )
base_params = action_spec.get_base_parameters() base_input = action_spec.get_base_input()
if base_params: if base_input:
action_params = expr.evaluate_recursively( action_input = expr.evaluate_recursively(
base_params, base_input,
action_params action_input
) )
else: else:
action_params = {} action_input = {}
rpc.get_executor_client().run_action( rpc.get_executor_client().run_action(
self.task_db.id, self.task_db.id,
action_db.action_class, action_db.action_class,
action_db.attributes or {}, action_db.attributes or {},
action_params action_input
) )
def _run_workflow(self): def _run_workflow(self):
@ -156,12 +156,12 @@ class RunTask(EngineCommand):
wf_spec = spec_parser.get_workflow_spec(wf_db.spec) wf_spec = spec_parser.get_workflow_spec(wf_db.spec)
wf_input = self.task_db.parameters wf_input = self.task_db.input
start_params = {'parent_task_id': self.task_db.id} start_params = {'parent_task_id': self.task_db.id}
for k, v in wf_input.items(): for k, v in wf_input.items():
if k not in wf_spec.get_parameters(): if k not in wf_spec.get_input():
start_params[k] = v start_params[k] = v
del wf_input[k] del wf_input[k]

View File

@ -28,7 +28,7 @@ def validate_workflow_input(wf_db, wf_spec, wf_input):
input_param_names = copy.copy((wf_input or {}).keys()) input_param_names = copy.copy((wf_input or {}).keys())
missing_param_names = [] missing_param_names = []
for p_name in wf_spec.get_parameters(): for p_name in wf_spec.get_input():
if p_name not in input_param_names: if p_name not in input_param_names:
missing_param_names.append(p_name) missing_param_names.append(p_name)
else: else:

View File

@ -37,13 +37,13 @@ def get_registered_actions(**kwargs):
def _register_action_in_db(name, action_class, attributes, def _register_action_in_db(name, action_class, attributes,
description=None, parameter_str=None): description=None, input_str=None):
values = { values = {
'name': name, 'name': name,
'action_class': action_class, 'action_class': action_class,
'attributes': attributes, 'attributes': attributes,
'description': description, 'description': description,
'parameters': parameter_str, 'input': input_str,
'is_system': True 'is_system': True
} }
@ -97,13 +97,13 @@ def register_action_classes():
action_class_str = mgr[name].entry_point_target.replace(':', '.') action_class_str = mgr[name].entry_point_target.replace(':', '.')
action_class = mgr[name].plugin action_class = mgr[name].plugin
description = i_utils.get_docstring(action_class) description = i_utils.get_docstring(action_class)
parameter_str = i_utils.get_arg_list_as_str(action_class.__init__) input_str = i_utils.get_arg_list_as_str(action_class.__init__)
attrs = i_utils.get_public_fields(mgr[name].plugin) attrs = i_utils.get_public_fields(mgr[name].plugin)
_register_action_in_db(name, action_class_str, attrs, _register_action_in_db(name, action_class_str, attrs,
description=description, description=description,
parameter_str=parameter_str) input_str=input_str)
_register_dynamic_action_classes() _register_dynamic_action_classes()

View File

@ -25,6 +25,7 @@ from mistral.services import action_manager as a_m
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
# TODO(rakhmerov): Deprecated. Remove it once engine v1 is gone.
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -112,7 +112,9 @@ class FunctionalTest(base.DbTestCase):
self.app.get(url, headers={'Accept': 'application/json'}) self.app.get(url, headers={'Accept': 'application/json'})
except webtest_app.AppError as error: except webtest_app.AppError as error:
self.assertIn('Bad response: 404 Not Found', str(error)) self.assertIn('Bad response: 404 Not Found', str(error))
return return
self.fail('Expected 404 Not found but got OK') self.fail('Expected 404 Not found but got OK')
def assertUnauthorized(self, url): def assertUnauthorized(self, url):
@ -120,5 +122,7 @@ class FunctionalTest(base.DbTestCase):
self.app.get(url, headers={'Accept': 'application/json'}) self.app.get(url, headers={'Accept': 'application/json'})
except webtest_app.AppError as error: except webtest_app.AppError as error:
self.assertIn('Bad response: 401 Unauthorized', str(error)) self.assertIn('Bad response: 401 Unauthorized', str(error))
return return
self.fail('Expected 401 Unauthorized but got OK') self.fail('Expected 401 Unauthorized but got OK')

View File

@ -29,7 +29,7 @@ version: '2.0'
description: My super cool action. description: My super cool action.
base: std.echo base: std.echo
base-parameters: base-input:
output: "{$.str1}{$.str2}" output: "{$.str1}{$.str2}"
""" """
@ -57,7 +57,7 @@ UPDATED_ACTION_DEFINITION = """
version: '2.0' version: '2.0'
base: std.echo base: std.echo
base-parameters: base-input:
output: "{$.str1}{$.str2}{$.str3}" output: "{$.str1}{$.str2}{$.str3}"
""" """

View File

@ -38,7 +38,7 @@ TASK_DB = models.Task(
state=states.RUNNING, state=states.RUNNING,
tags=['a', 'b'], tags=['a', 'b'],
in_context={}, in_context={},
parameters={}, input={},
output={}, output={},
runtime_context={}, runtime_context={},
execution_id='123', execution_id='123',
@ -50,15 +50,11 @@ TASK = {
'id': '123', 'id': '123',
'name': 'task', 'name': 'task',
'wf_name': 'flow', 'wf_name': 'flow',
'state': 'RUNNING', 'state': 'RUNNING',
'result': '{}', 'result': '{}',
'input': '{}',
'parameters': '{}',
'output': '{}', 'output': '{}',
'execution_id': '123', 'execution_id': '123',
'created_at': '1970-01-01 00:00:00', 'created_at': '1970-01-01 00:00:00',
'updated_at': '1970-01-01 00:00:00' 'updated_at': '1970-01-01 00:00:00'
} }

View File

@ -28,7 +28,7 @@ WF_DEFINITION = """
version: '2.0' version: '2.0'
type: direct type: direct
parameters: input:
- param1 - param1
tasks: tasks:
@ -61,7 +61,7 @@ UPDATED_WF_DEFINITION = """
version: '2.0' version: '2.0'
type: direct type: direct
parameters: input:
- param1 - param1
tasks: tasks:

View File

@ -477,7 +477,7 @@ TASKS = [
'state': 'IDLE', 'state': 'IDLE',
'tags': ['deployment'], 'tags': ['deployment'],
'in_context': None, 'in_context': None,
'parameters': None, 'input': None,
'output': None, 'output': None,
'runtime_context': None, 'runtime_context': None,
'created_at': None, 'created_at': None,
@ -493,7 +493,7 @@ TASKS = [
'state': 'IDLE', 'state': 'IDLE',
'tags': ['deployment'], 'tags': ['deployment'],
'in_context': {'image_id': '123123'}, 'in_context': {'image_id': '123123'},
'parameters': {'image_id': '123123'}, 'input': {'image_id': '123123'},
'output': {'vm_id': '343123'}, 'output': {'vm_id': '343123'},
'runtime_context': None, 'runtime_context': None,
'created_at': None, 'created_at': None,

View File

@ -33,9 +33,9 @@ version: '2.0'
actions: actions:
concat_twice: concat_twice:
base: std.echo base: std.echo
base-parameters: base-input:
output: "{$.s1}+{$.s2}" output: "{$.s1}+{$.s2}"
parameters: input:
- s1 - s1
- s2 - s2
output: "{$} and {$}" output: "{$} and {$}"
@ -43,7 +43,7 @@ actions:
workflows: workflows:
wf1: wf1:
type: direct type: direct
parameters: input:
- str1 - str1
- str2 - str2
output: output:
@ -78,6 +78,10 @@ class AdhocActionsTest(base.EngineTestCase):
exec_db = db_api.get_execution(exec_db.id) exec_db = db_api.get_execution(exec_db.id)
self.assertDictEqual({'workflow_result': 'a+b and a+b', self.assertDictEqual(
'concat_task_result': 'a+b and a+b'}, {
exec_db.output) 'workflow_result': 'a+b and a+b',
'concat_task_result': 'a+b and a+b'
},
exec_db.output
)

View File

@ -40,7 +40,7 @@ version: '2.0'
workflows: workflows:
wf1: wf1:
type: reverse type: reverse
parameters: input:
- param1 - param1
- param2 - param2
@ -109,7 +109,7 @@ class DefaultEngineTest(base.DbTestCase):
# Data Flow properties. # Data Flow properties.
self._assert_dict_contains_subset(wf_input, task_db.in_context) self._assert_dict_contains_subset(wf_input, task_db.in_context)
self.assertIn('__execution', task_db.in_context) self.assertIn('__execution', task_db.in_context)
self.assertDictEqual({'output': 'Hey'}, task_db.parameters) self.assertDictEqual({'output': 'Hey'}, task_db.input)
def test_start_workflow_missing_parameters(self): def test_start_workflow_missing_parameters(self):
self.assertRaises( self.assertRaises(
@ -158,7 +158,7 @@ class DefaultEngineTest(base.DbTestCase):
self.assertIsNone(task_db.runtime_context) self.assertIsNone(task_db.runtime_context)
self._assert_dict_contains_subset(wf_input, task_db.in_context) self._assert_dict_contains_subset(wf_input, task_db.in_context)
self.assertIn('__execution', task_db.in_context) self.assertIn('__execution', task_db.in_context)
self.assertDictEqual({'output': 'Hey'}, task_db.parameters) self.assertDictEqual({'output': 'Hey'}, task_db.input)
# Finish 'task1'. # Finish 'task1'.
task1_db = self.engine.on_task_result( task1_db = self.engine.on_task_result(
@ -173,7 +173,7 @@ class DefaultEngineTest(base.DbTestCase):
# Data Flow properties. # Data Flow properties.
self._assert_dict_contains_subset(wf_input, task1_db.in_context) self._assert_dict_contains_subset(wf_input, task1_db.in_context)
self.assertIn('__execution', task_db.in_context) self.assertIn('__execution', task_db.in_context)
self.assertDictEqual({'output': 'Hey'}, task1_db.parameters) self.assertDictEqual({'output': 'Hey'}, task1_db.input)
self.assertDictEqual( self.assertDictEqual(
{ {
'result': 'Hey', 'result': 'Hey',
@ -213,7 +213,7 @@ class DefaultEngineTest(base.DbTestCase):
self._assert_dict_contains_subset(in_context, task2_db.in_context) self._assert_dict_contains_subset(in_context, task2_db.in_context)
self.assertIn('__execution', task_db.in_context) self.assertIn('__execution', task_db.in_context)
self.assertDictEqual({'output': 'Hi'}, task2_db.parameters) self.assertDictEqual({'output': 'Hi'}, task2_db.input)
self.assertDictEqual({'task': {'task2': 'Hi'}}, task2_db.output) self.assertDictEqual({'task': {'task2': 'Hi'}}, task2_db.output)
self.assertEqual(2, len(exec_db.tasks)) self.assertEqual(2, len(exec_db.tasks))

View File

@ -34,7 +34,7 @@ version: '2.0'
workflows: workflows:
wf: wf:
type: direct type: direct
parameters: input:
- my_var - my_var
tasks: tasks:
@ -111,7 +111,7 @@ version: '2.0'
workflows: workflows:
wf: wf:
type: direct type: direct
parameters: input:
- my_var - my_var
on-task-complete: on-task-complete:

View File

@ -34,7 +34,7 @@ version: '2.0'
workflows: workflows:
wf1: wf1:
type: reverse type: reverse
parameters: input:
- param1 - param1
- param2 - param2

View File

@ -36,7 +36,7 @@ version: '2.0'
workflows: workflows:
wf1: wf1:
type: reverse type: reverse
parameters: input:
- param1 - param1
- param2 - param2
output: output:

View File

@ -17,17 +17,19 @@ from mistral.tests import base
class ActionManagerTest(base.DbTestCase): class ActionManagerTest(base.DbTestCase):
def test_action_parameters(self): def test_action_input(self):
std_http = db_api.get_action("std.http") std_http = db_api.get_action("std.http")
std_email = db_api.get_action("std.email") std_email = db_api.get_action("std.email")
http_action_params = ("url, method=GET, params=None, body=None, " http_action_input = (
"url, method=GET, params=None, body=None, "
"headers=None, cookies=None, auth=None, " "headers=None, cookies=None, auth=None, "
"timeout=None, allow_redirects=None, " "timeout=None, allow_redirects=None, "
"proxies=None") "proxies=None"
)
self.assertEqual(http_action_params, std_http.parameters) self.assertEqual(http_action_input, std_http.input)
self.assertEqual("params, settings", std_email.parameters) self.assertEqual("params, settings", std_email.input)
def test_action_description(self): def test_action_description(self):
std_http = db_api.get_action("std.http") std_http = db_api.get_action("std.http")

View File

@ -34,13 +34,13 @@ version: '2.0'
actions: actions:
concat: concat:
base: std.echo base: std.echo
base-parameters: base-input:
output: "{$.str1}{$.str2}" output: "{$.str1}{$.str2}"
workflows: workflows:
wf1: wf1:
type: reverse type: reverse
parameters: input:
- param1 - param1
output: output:
result: $.result result: $.result
@ -70,7 +70,7 @@ version: '2.0'
actions: actions:
concat: concat:
base: std.echo base: std.echo
base-parameters: base-input:
output: "{$.str1}{$.str2}" output: "{$.str1}{$.str2}"
workflows: workflows:
@ -87,7 +87,7 @@ workflows:
wf2: wf2:
type: reverse type: reverse
parameters: input:
- param1 - param1
output: output:
result: $.result result: $.result

View File

@ -28,15 +28,9 @@ DATA = {
SERVERS = { SERVERS = {
"servers": [ "servers": [
{ {'name': 'centos'},
'name': 'centos' {'name': 'ubuntu'},
}, {'name': 'fedora'}
{
'name': 'ubuntu'
},
{
'name': 'fedora'
}
] ]
} }
@ -87,10 +81,12 @@ class YaqlEvaluatorTest(base.BaseTest):
'new_key11': 'new_key1' 'new_key11': 'new_key1'
} }
} }
modified_task = expr.evaluate_recursively(task_spec_dict, modified_task = expr.evaluate_recursively(
task_spec_dict,
{ {
'param2': 'val32' 'param2': 'val32'
}) }
)
self.assertDictEqual( self.assertDictEqual(
{ {
@ -103,13 +99,15 @@ class YaqlEvaluatorTest(base.BaseTest):
'new_key11': 'new_key1' 'new_key11': 'new_key1'
} }
}, },
modified_task) modified_task
)
def test_evaluate_recursively_arbitrary_dict(self): def test_evaluate_recursively_arbitrary_dict(self):
context = { context = {
"auth_token": "123", "auth_token": "123",
"project_id": "mistral" "project_id": "mistral"
} }
data = { data = {
"parameters": { "parameters": {
"parameter1": { "parameter1": {
@ -138,4 +136,5 @@ class YaqlEvaluatorTest(base.BaseTest):
}, },
"token": "123" "token": "123"
}, },
applied) applied
)

View File

@ -22,10 +22,13 @@ class InspectUtilsTest(base.BaseTest):
action_class = std_actions.HTTPAction action_class = std_actions.HTTPAction
parameters_str = i_u.get_arg_list_as_str(action_class.__init__) parameters_str = i_u.get_arg_list_as_str(action_class.__init__)
http_action_params = ("url, method=GET, params=None, body=None, " http_action_params = (
"url, method=GET, params=None, body=None, "
"headers=None, cookies=None, auth=None, " "headers=None, cookies=None, auth=None, "
"timeout=None, allow_redirects=None, " "timeout=None, allow_redirects=None, "
"proxies=None") "proxies=None"
)
self.assertEqual(http_action_params, parameters_str) self.assertEqual(http_action_params, parameters_str)
def test_get_parameters_str_all_mandatory(self): def test_get_parameters_str_all_mandatory(self):

View File

@ -27,7 +27,7 @@ actions:
action1: action1:
description: This is a test ad-hoc action description: This is a test ad-hoc action
base: std.echo base: std.echo
base-parameters: base-input:
output: "Hello {$.name}!" output: "Hello {$.name}!"
output: $ output: $
@ -41,7 +41,7 @@ workflows:
description: This is a test workflow description: This is a test workflow
type: reverse type: reverse
parameters: input:
- name - name
- age - age
@ -136,9 +136,9 @@ class DSLv2ModelTest(base.BaseTest):
self.assertEqual('std.echo', action_spec.get_base()) self.assertEqual('std.echo', action_spec.get_base())
self.assertDictEqual( self.assertDictEqual(
{'output': 'Hello {$.name}!'}, {'output': 'Hello {$.name}!'},
action_spec.get_base_parameters() action_spec.get_base_input()
) )
self.assertDictEqual({}, action_spec.get_parameters()) self.assertDictEqual({}, action_spec.get_input())
self.assertEqual('$', action_spec.get_output()) self.assertEqual('$', action_spec.get_output())
# Workflows. # Workflows.
@ -165,7 +165,7 @@ class DSLv2ModelTest(base.BaseTest):
self.assertEqual('task1', task1_spec.get_name()) self.assertEqual('task1', task1_spec.get_name())
self.assertEqual('This is a test task', task1_spec.get_description()) self.assertEqual('This is a test task', task1_spec.get_description())
self.assertEqual('ns1.action1', task1_spec.get_action_name()) self.assertEqual('ns1.action1', task1_spec.get_action_name())
self.assertEqual({'name': '{$.name}'}, task1_spec.get_parameters()) self.assertEqual({'name': '{$.name}'}, task1_spec.get_input())
policies = task1_spec.get_policies() policies = task1_spec.get_policies()
@ -187,7 +187,7 @@ class DSLv2ModelTest(base.BaseTest):
self.assertIsNone(task2_spec.get_workflow_name()) self.assertIsNone(task2_spec.get_workflow_name())
self.assertEqual( self.assertEqual(
{'output': 'Thanks {$.name}!'}, {'output': 'Thanks {$.name}!'},
task2_spec.get_parameters() task2_spec.get_input()
) )
wf2_spec = wf_specs.get('wf2') wf2_spec = wf_specs.get('wf2')
@ -220,7 +220,7 @@ class DSLv2ModelTest(base.BaseTest):
'param1': None, 'param1': None,
'param2': False 'param2': False
}, },
task3_spec.get_parameters() task3_spec.get_input()
) )
self.assertListEqual( self.assertListEqual(
[('task4', '$.my_val = 1')], [('task4', '$.my_val = 1')],
@ -242,7 +242,7 @@ class DSLv2ModelTest(base.BaseTest):
'is_true': True, 'is_true': True,
'object_list': [1, None, 'str'], 'object_list': [1, None, 'str'],
}, },
task7_spec.get_parameters() task7_spec.get_input()
) )
task8_spec = wf2_spec.get_tasks().get('task8') task8_spec = wf2_spec.get_tasks().get('task8')
@ -252,7 +252,7 @@ class DSLv2ModelTest(base.BaseTest):
'expr_list': ['$.value', '{$.key}'], 'expr_list': ['$.value', '{$.key}'],
'expr': '{$.value}', 'expr': '{$.value}',
}, },
task8_spec.get_parameters() task8_spec.get_input()
) )
def test_adhoc_action_with_base_in_one_string(self): def test_adhoc_action_with_base_in_one_string(self):
@ -263,7 +263,7 @@ class DSLv2ModelTest(base.BaseTest):
self.assertEqual("std.echo", action_spec.get_base()) self.assertEqual("std.echo", action_spec.get_base())
self.assertEqual({'output': 'Echo output'}, self.assertEqual({'output': 'Echo output'},
action_spec.get_base_parameters()) action_spec.get_base_input())
def test_to_dict(self): def test_to_dict(self):
wb_spec = spec_parser.get_workbook_spec_from_yaml(VALID_WB) wb_spec = spec_parser.get_workbook_spec_from_yaml(VALID_WB)

View File

@ -85,7 +85,7 @@ class BaseSpec(object):
return val.items()[0] if isinstance(val, dict) else (val, '') return val.items()[0] if isinstance(val, dict) else (val, '')
@staticmethod @staticmethod
def _parse_cmd_and_params(cmd_str): def _parse_cmd_and_input(cmd_str):
# TODO(rakhmerov): Try to find a way with one expression. # TODO(rakhmerov): Try to find a way with one expression.
cmd_matcher = CMD_PTRN.search(cmd_str) cmd_matcher = CMD_PTRN.search(cmd_str)

View File

@ -27,8 +27,8 @@ class ActionSpec(base.BaseSpec):
"name": {"type": "string"}, "name": {"type": "string"},
"description": {"type": "string"}, "description": {"type": "string"},
"base": {"type": "string"}, "base": {"type": "string"},
"base-parameters": {"type": "object"}, "base-input": {"type": "object"},
"parameters": {"type": "array"}, "input": {"type": "array"},
"output": {"type": ["string", "object", "array", "null"]}, "output": {"type": ["string", "object", "array", "null"]},
}, },
"required": ["version", "name", "base"], "required": ["version", "name", "base"],
@ -43,13 +43,13 @@ class ActionSpec(base.BaseSpec):
self._name = data['name'] self._name = data['name']
self._description = data.get('description') self._description = data.get('description')
self._base = data['base'] self._base = data['base']
self._base_parameters = data.get('base-parameters', {}) self._base_input = data.get('base-input', {})
self._parameters = data.get('parameters', {}) self._input = data.get('input', {})
self._output = data.get('output') self._output = data.get('output')
self._base, params = self._parse_cmd_and_params(self._base) self._base, _input = self._parse_cmd_and_input(self._base)
utils.merge_dicts(self._base_parameters, params) utils.merge_dicts(self._base_input, _input)
def get_name(self): def get_name(self):
return self._name return self._name
@ -60,11 +60,11 @@ class ActionSpec(base.BaseSpec):
def get_base(self): def get_base(self):
return self._base return self._base
def get_base_parameters(self): def get_base_input(self):
return self._base_parameters return self._base_input
def get_parameters(self): def get_input(self):
return self._parameters return self._input
def get_output(self): def get_output(self):
return self._output return self._output

View File

@ -32,7 +32,7 @@ class TaskSpec(base.BaseSpec):
"description": {"type": "string"}, "description": {"type": "string"},
"action": {"type": ["string", "null"]}, "action": {"type": ["string", "null"]},
"workflow": {"type": ["string", "null"]}, "workflow": {"type": ["string", "null"]},
"parameters": {"type": ["object", "null"]}, "input": {"type": ["object", "null"]},
"publish": {"type": ["object", "null"]}, "publish": {"type": ["object", "null"]},
"policies": {"type": ["object", "null"]}, "policies": {"type": ["object", "null"]},
"requires": {"type": ["string", "array", "null"]}, "requires": {"type": ["string", "array", "null"]},
@ -53,7 +53,7 @@ class TaskSpec(base.BaseSpec):
self._description = data.get('description') self._description = data.get('description')
self._action = data.get('action') self._action = data.get('action')
self._workflow = data.get('workflow') self._workflow = data.get('workflow')
self._parameters = data.get('parameters', {}) self._input = data.get('input', {})
self._publish = data.get('publish', {}) self._publish = data.get('publish', {})
self._policies = self._spec_property( self._policies = self._spec_property(
'policies', 'policies',
@ -80,12 +80,12 @@ class TaskSpec(base.BaseSpec):
params = {} params = {}
if self._action: if self._action:
self._action, params = self._parse_cmd_and_params(self._action) self._action, params = self._parse_cmd_and_input(self._action)
elif self._workflow: elif self._workflow:
self._workflow, params = self._parse_cmd_and_params( self._workflow, params = self._parse_cmd_and_input(
self._workflow) self._workflow)
utils.merge_dicts(self._parameters, params) utils.merge_dicts(self._input, params)
def get_name(self): def get_name(self):
return self._name return self._name
@ -99,8 +99,8 @@ class TaskSpec(base.BaseSpec):
def get_workflow_name(self): def get_workflow_name(self):
return self._workflow return self._workflow
def get_parameters(self): def get_input(self):
return self._parameters return self._input
def get_policies(self): def get_policies(self):
return self._policies return self._policies

View File

@ -29,7 +29,7 @@ class WorkflowSpec(base.BaseSpec):
"on-task-complete": {"type": ["array", "null"]}, "on-task-complete": {"type": ["array", "null"]},
"on-task-success": {"type": ["array", "null"]}, "on-task-success": {"type": ["array", "null"]},
"on-task-error": {"type": ["array", "null"]}, "on-task-error": {"type": ["array", "null"]},
"parameters": {"type": ["array", "null"]}, "input": {"type": ["array", "null"]},
"output": {"type": ["string", "object", "array", "null"]}, "output": {"type": ["string", "object", "array", "null"]},
"tasks": {"type": "object"}, "tasks": {"type": "object"},
}, },
@ -45,9 +45,10 @@ class WorkflowSpec(base.BaseSpec):
self._name = data['name'] self._name = data['name']
self._description = data.get('description') self._description = data.get('description')
self._type = data['type'] self._type = data['type']
self._parameters = data.get('parameters', {}) self._input = data.get('input', [])
self._output = data.get('output', {}) self._output = data.get('output', {})
# TODO(rakhmerov): Build workflow policies specification.
# TODO(rakhmerov): Implement 'task-defaults' instead.
self._policies = None self._policies = None
self._on_task_complete = self._as_list_of_tuples("on-task-complete") self._on_task_complete = self._as_list_of_tuples("on-task-complete")
self._on_task_success = self._as_list_of_tuples("on-task-success") self._on_task_success = self._as_list_of_tuples("on-task-success")
@ -64,8 +65,8 @@ class WorkflowSpec(base.BaseSpec):
def get_type(self): def get_type(self):
return self._type return self._type
def get_parameters(self): def get_input(self):
return self._parameters return self._input
def get_output(self): def get_output(self):
return self._output return self._output

View File

@ -63,6 +63,8 @@ class WorkflowHandler(object):
(before publisher). Instance of mistral.workflow.utils.TaskResult (before publisher). Instance of mistral.workflow.utils.TaskResult
:return List of engine commands that needs to be performed. :return List of engine commands that needs to be performed.
""" """
# TODO(rakhmerov): need to ignore result if task is complete.
task_db.state = \ task_db.state = \
states.ERROR if raw_result.is_error() else states.SUCCESS states.ERROR if raw_result.is_error() else states.SUCCESS

View File

@ -31,7 +31,7 @@ CONF = cfg.CONF
def prepare_db_task(task_db, task_spec, upstream_task_specs, exec_db, def prepare_db_task(task_db, task_spec, upstream_task_specs, exec_db,
cause_task_db=None): cause_task_db=None):
"""Prepare Data Flow properties ('in_context' and 'parameters') """Prepare Data Flow properties ('in_context' and 'input')
of given DB task. of given DB task.
:param task_db: DB task to prepare. :param task_db: DB task to prepare.
@ -59,14 +59,14 @@ def prepare_db_task(task_db, task_spec, upstream_task_specs, exec_db,
old_task_output old_task_output
) )
task_db.parameters = evaluate_task_parameters( task_db.input = evaluate_task_input(
task_spec, task_spec,
task_db.in_context task_db.in_context
) )
def evaluate_task_parameters(task_spec, context): def evaluate_task_input(task_spec, context):
return expr.evaluate_recursively(task_spec.get_parameters(), context) return expr.evaluate_recursively(task_spec.get_input(), context)
def _evaluate_upstream_context(upstream_db_tasks): def _evaluate_upstream_context(upstream_db_tasks):