Modifying workflow and action services to save 'tags'

Closes-Bug: #1373295

Change-Id: I6812675d47cfc1d9f5108d2fe4466abaa7e2e40f
This commit is contained in:
Renat Akhmerov 2014-09-25 14:56:47 -07:00
parent 840765ec96
commit 914bbcd8c7
5 changed files with 11 additions and 0 deletions

View File

@ -148,6 +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())
tags = sa.Column(st.JsonListType())
input = sa.Column(sa.String(240)) input = sa.Column(sa.String(240))
# Ad-hoc action properties. # Ad-hoc action properties.

View File

@ -50,6 +50,7 @@ def create_action(action_spec, definition):
values = { values = {
'name': action_spec.get_name(), 'name': action_spec.get_name(),
'description': action_spec.get_description(), 'description': action_spec.get_description(),
'tags': action_spec.get_tags(),
'definition': definition, 'definition': definition,
'spec': action_spec.to_dict(), 'spec': action_spec.to_dict(),
'is_system': False 'is_system': False
@ -72,6 +73,7 @@ def create_or_update_action(action_spec, definition):
values = { values = {
'name': action_spec.get_name(), 'name': action_spec.get_name(),
'description': action_spec.get_description(), 'description': action_spec.get_description(),
'tags': action_spec.get_tags(),
'definition': definition, 'definition': definition,
'spec': action_spec.to_dict(), 'spec': action_spec.to_dict(),
'is_system': False 'is_system': False

View File

@ -47,6 +47,7 @@ def update_workflows(definition):
def create_workflow(wf_spec, definition): def create_workflow(wf_spec, definition):
values = { values = {
'name': wf_spec.get_name(), 'name': wf_spec.get_name(),
'tags': wf_spec.get_tags(),
'definition': definition, 'definition': definition,
'spec': wf_spec.to_dict() 'spec': wf_spec.to_dict()
} }
@ -59,6 +60,7 @@ def create_workflow(wf_spec, definition):
def create_or_update_workflow(wf_spec, definition): def create_or_update_workflow(wf_spec, definition):
values = { values = {
'name': wf_spec.get_name(), 'name': wf_spec.get_name(),
'tags': wf_spec.get_tags(),
'definition': definition, 'definition': definition,
'spec': wf_spec.to_dict() 'spec': wf_spec.to_dict()
} }

View File

@ -32,6 +32,7 @@ ACTION_LIST = """
version: '2.0' version: '2.0'
action1: action1:
tags: [test, v2]
base: std.echo output='Hi' base: std.echo output='Hi'
output: output:
result: $ result: $
@ -72,6 +73,7 @@ class ActionServiceTest(base.DbTestCase):
action1_spec = spec_parser.get_action_spec(action1_db.spec) action1_spec = spec_parser.get_action_spec(action1_db.spec)
self.assertEqual('action1', action1_spec.get_name()) self.assertEqual('action1', action1_spec.get_name())
self.assertListEqual(['test', 'v2'], action1_spec.get_tags())
self.assertEqual('std.echo', action1_spec.get_base()) self.assertEqual('std.echo', action1_spec.get_base())
self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input()) self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input())
@ -103,6 +105,7 @@ class ActionServiceTest(base.DbTestCase):
action1_spec = spec_parser.get_action_spec(action1_db.spec) action1_spec = spec_parser.get_action_spec(action1_db.spec)
self.assertEqual('action1', action1_spec.get_name()) self.assertEqual('action1', action1_spec.get_name())
self.assertListEqual([], action1_spec.get_tags())
self.assertEqual('std.echo', action1_spec.get_base()) self.assertEqual('std.echo', action1_spec.get_base())
self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input()) self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input())
self.assertListEqual(['param1'], action1_spec.get_input()) self.assertListEqual(['param1'], action1_spec.get_input())

View File

@ -31,6 +31,7 @@ WORKFLOW_LIST = """
version: '2.0' version: '2.0'
wf1: wf1:
tags: [test, v2]
type: reverse type: reverse
input: input:
- param1 - param1
@ -86,6 +87,7 @@ class WorkflowServiceTest(base.DbTestCase):
wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec) wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec)
self.assertEqual('wf1', wf1_spec.get_name()) self.assertEqual('wf1', wf1_spec.get_name())
self.assertListEqual(['test', 'v2'], wf1_spec.get_tags())
self.assertEqual('reverse', wf1_spec.get_type()) self.assertEqual('reverse', wf1_spec.get_type())
# Workflow 2. # Workflow 2.
@ -116,5 +118,6 @@ class WorkflowServiceTest(base.DbTestCase):
wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec) wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec)
self.assertEqual('wf1', wf1_spec.get_name()) self.assertEqual('wf1', wf1_spec.get_name())
self.assertListEqual([], wf1_spec.get_tags())
self.assertEqual('reverse', wf1_spec.get_type()) self.assertEqual('reverse', wf1_spec.get_type())
self.assertListEqual(['param1', 'param2'], wf1_spec.get_input()) self.assertListEqual(['param1', 'param2'], wf1_spec.get_input())