Merge "Add support for tagging Mistral workflows"
This commit is contained in:
commit
b0342270c1
|
@ -48,10 +48,10 @@ class Workflow(signal_responder.SignalResponder,
|
||||||
|
|
||||||
PROPERTIES = (
|
PROPERTIES = (
|
||||||
NAME, TYPE, DESCRIPTION, INPUT, OUTPUT, TASKS, PARAMS,
|
NAME, TYPE, DESCRIPTION, INPUT, OUTPUT, TASKS, PARAMS,
|
||||||
TASK_DEFAULTS, USE_REQUEST_BODY_AS_INPUT
|
TASK_DEFAULTS, USE_REQUEST_BODY_AS_INPUT, TAGS
|
||||||
) = (
|
) = (
|
||||||
'name', 'type', 'description', 'input', 'output', 'tasks', 'params',
|
'name', 'type', 'description', 'input', 'output', 'tasks', 'params',
|
||||||
'task_defaults', 'use_request_body_as_input'
|
'task_defaults', 'use_request_body_as_input', 'tags'
|
||||||
)
|
)
|
||||||
|
|
||||||
_TASKS_KEYS = (
|
_TASKS_KEYS = (
|
||||||
|
@ -109,6 +109,12 @@ class Workflow(signal_responder.SignalResponder,
|
||||||
update_allowed=True,
|
update_allowed=True,
|
||||||
support_status=support.SupportStatus(version='6.0.0')
|
support_status=support.SupportStatus(version='6.0.0')
|
||||||
),
|
),
|
||||||
|
TAGS: properties.Schema(
|
||||||
|
properties.Schema.LIST,
|
||||||
|
_('List of tags to set on the workflow.'),
|
||||||
|
update_allowed=True,
|
||||||
|
support_status=support.SupportStatus(version='10.0.0')
|
||||||
|
),
|
||||||
DESCRIPTION: properties.Schema(
|
DESCRIPTION: properties.Schema(
|
||||||
properties.Schema.STRING,
|
properties.Schema.STRING,
|
||||||
_('Workflow description.'),
|
_('Workflow description.'),
|
||||||
|
@ -532,6 +538,7 @@ class Workflow(signal_responder.SignalResponder,
|
||||||
defn_name: {self.TYPE: props.get(self.TYPE),
|
defn_name: {self.TYPE: props.get(self.TYPE),
|
||||||
self.DESCRIPTION: props.get(
|
self.DESCRIPTION: props.get(
|
||||||
self.DESCRIPTION),
|
self.DESCRIPTION),
|
||||||
|
self.TAGS: props.get(self.TAGS),
|
||||||
self.OUTPUT: props.get(self.OUTPUT)}}
|
self.OUTPUT: props.get(self.OUTPUT)}}
|
||||||
for key in list(definition[defn_name].keys()):
|
for key in list(definition[defn_name].keys()):
|
||||||
if definition[defn_name][key] is None:
|
if definition[defn_name][key] is None:
|
||||||
|
|
|
@ -44,7 +44,21 @@ resources:
|
||||||
publish:
|
publish:
|
||||||
result: <% $.hello %>
|
result: <% $.hello %>
|
||||||
"""
|
"""
|
||||||
|
workflow_template_with_tags = """
|
||||||
|
heat_template_version: queens
|
||||||
|
resources:
|
||||||
|
workflow:
|
||||||
|
type: OS::Mistral::Workflow
|
||||||
|
properties:
|
||||||
|
type: direct
|
||||||
|
tags:
|
||||||
|
- tagged
|
||||||
|
tasks:
|
||||||
|
- name: hello
|
||||||
|
action: std.echo output='Good morning!'
|
||||||
|
publish:
|
||||||
|
result: <% $.hello %>
|
||||||
|
"""
|
||||||
workflow_template_with_params = """
|
workflow_template_with_params = """
|
||||||
heat_template_version: 2013-05-23
|
heat_template_version: 2013-05-23
|
||||||
resources:
|
resources:
|
||||||
|
@ -747,6 +761,22 @@ class TestMistralWorkflow(common.HeatTestCase):
|
||||||
lambda *args, **kw: self.verify_params(*args, **kw))
|
lambda *args, **kw: self.verify_params(*args, **kw))
|
||||||
scheduler.TaskRunner(wf.signal, details)()
|
scheduler.TaskRunner(wf.signal, details)()
|
||||||
|
|
||||||
|
def test_workflow_tags(self):
|
||||||
|
tmpl = template_format.parse(workflow_template_with_tags)
|
||||||
|
stack = utils.parse_stack(tmpl)
|
||||||
|
rsrc_defns = stack.t.resource_definitions(stack)['workflow']
|
||||||
|
wf = workflow.Workflow('workflow', rsrc_defns, stack)
|
||||||
|
self.mistral.workflows.create.return_value = [
|
||||||
|
FakeWorkflow('workflow')]
|
||||||
|
scheduler.TaskRunner(wf.create)()
|
||||||
|
details = {'tags': ['mytag'],
|
||||||
|
'params': {'test': 'param_value', 'test1': 'param_value_1'}}
|
||||||
|
execution = mock.Mock()
|
||||||
|
execution.id = '12345'
|
||||||
|
self.mistral.executions.create.side_effect = (
|
||||||
|
lambda *args, **kw: self.verify_params(*args, **kw))
|
||||||
|
scheduler.TaskRunner(wf.signal, details)()
|
||||||
|
|
||||||
def test_workflow_params_merge(self):
|
def test_workflow_params_merge(self):
|
||||||
tmpl = template_format.parse(workflow_template_with_params)
|
tmpl = template_format.parse(workflow_template_with_params)
|
||||||
stack = utils.parse_stack(tmpl)
|
stack = utils.parse_stack(tmpl)
|
||||||
|
|
Loading…
Reference in New Issue