Merge "Add support for tagging Mistral workflows"

This commit is contained in:
Jenkins 2017-09-11 05:41:50 +00:00 committed by Gerrit Code Review
commit b0342270c1
2 changed files with 40 additions and 3 deletions

View File

@ -48,10 +48,10 @@ class Workflow(signal_responder.SignalResponder,
PROPERTIES = (
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',
'task_defaults', 'use_request_body_as_input'
'task_defaults', 'use_request_body_as_input', 'tags'
)
_TASKS_KEYS = (
@ -109,6 +109,12 @@ class Workflow(signal_responder.SignalResponder,
update_allowed=True,
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(
properties.Schema.STRING,
_('Workflow description.'),
@ -532,6 +538,7 @@ class Workflow(signal_responder.SignalResponder,
defn_name: {self.TYPE: props.get(self.TYPE),
self.DESCRIPTION: props.get(
self.DESCRIPTION),
self.TAGS: props.get(self.TAGS),
self.OUTPUT: props.get(self.OUTPUT)}}
for key in list(definition[defn_name].keys()):
if definition[defn_name][key] is None:

View File

@ -44,7 +44,21 @@ resources:
publish:
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 = """
heat_template_version: 2013-05-23
resources:
@ -747,6 +761,22 @@ class TestMistralWorkflow(common.HeatTestCase):
lambda *args, **kw: self.verify_params(*args, **kw))
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):
tmpl = template_format.parse(workflow_template_with_params)
stack = utils.parse_stack(tmpl)