Fixing workbook service to create actions
Change-Id: I1983a2930b0e68313e038f2680db936c209403f8
This commit is contained in:
parent
636e5290bc
commit
d8583b566d
@ -36,6 +36,8 @@ class Workbook(mb.MistralModelBase):
|
|||||||
definition = sa.Column(sa.Text(), nullable=True)
|
definition = sa.Column(sa.Text(), nullable=True)
|
||||||
spec = sa.Column(st.JsonDictType())
|
spec = sa.Column(st.JsonDictType())
|
||||||
tags = sa.Column(st.JsonListType())
|
tags = sa.Column(st.JsonListType())
|
||||||
|
|
||||||
|
# Security properties.
|
||||||
scope = sa.Column(sa.String(80))
|
scope = sa.Column(sa.String(80))
|
||||||
project_id = sa.Column(sa.String(80))
|
project_id = sa.Column(sa.String(80))
|
||||||
trust_id = sa.Column(sa.String(80))
|
trust_id = sa.Column(sa.String(80))
|
||||||
@ -55,6 +57,8 @@ class Workflow(mb.MistralModelBase):
|
|||||||
definition = sa.Column(sa.Text(), nullable=True)
|
definition = sa.Column(sa.Text(), nullable=True)
|
||||||
spec = sa.Column(st.JsonDictType())
|
spec = sa.Column(st.JsonDictType())
|
||||||
tags = sa.Column(st.JsonListType())
|
tags = sa.Column(st.JsonListType())
|
||||||
|
|
||||||
|
# Security properties.
|
||||||
scope = sa.Column(sa.String(80))
|
scope = sa.Column(sa.String(80))
|
||||||
project_id = sa.Column(sa.String(80))
|
project_id = sa.Column(sa.String(80))
|
||||||
trust_id = sa.Column(sa.String(80))
|
trust_id = sa.Column(sa.String(80))
|
||||||
@ -145,7 +149,16 @@ class Action(mb.MistralModelBase):
|
|||||||
name = sa.Column(sa.String(200))
|
name = sa.Column(sa.String(200))
|
||||||
description = sa.Column(sa.Text())
|
description = sa.Column(sa.Text())
|
||||||
|
|
||||||
|
# Ad-hoc action properties.
|
||||||
|
definition = sa.Column(sa.Text(), nullable=True)
|
||||||
|
spec = sa.Column(st.JsonDictType())
|
||||||
|
|
||||||
# Service properties.
|
# Service properties.
|
||||||
action_class = sa.Column(sa.String(200))
|
action_class = sa.Column(sa.String(200))
|
||||||
attributes = sa.Column(st.JsonDictType())
|
attributes = sa.Column(st.JsonDictType())
|
||||||
is_system = sa.Column(sa.Boolean())
|
is_system = sa.Column(sa.Boolean())
|
||||||
|
|
||||||
|
# Security properties.
|
||||||
|
scope = sa.Column(sa.String(80))
|
||||||
|
project_id = sa.Column(sa.String(80))
|
||||||
|
trust_id = sa.Column(sa.String(80))
|
||||||
|
@ -74,8 +74,19 @@ def _check_workbook_definition_update(wb_db, values):
|
|||||||
|
|
||||||
def _create_or_update_actions(wb_db, actions_spec):
|
def _create_or_update_actions(wb_db, actions_spec):
|
||||||
if actions_spec:
|
if actions_spec:
|
||||||
# TODO(rakhmerov): Complete when action DB model is added.
|
for action_spec in actions_spec:
|
||||||
pass
|
action_name = '%s.%s' % (wb_db.name, action_spec.get_name())
|
||||||
|
|
||||||
|
values = {
|
||||||
|
'name': action_name,
|
||||||
|
'spec': action_spec.to_dict(),
|
||||||
|
'is_system': False,
|
||||||
|
'scope': wb_db.scope,
|
||||||
|
'trust_id': wb_db.trust_id,
|
||||||
|
'project_id': wb_db.project_id
|
||||||
|
}
|
||||||
|
|
||||||
|
db_api_v2.create_or_update_action(action_name, values)
|
||||||
|
|
||||||
|
|
||||||
def _create_or_update_workflows(wb_db, workflows_spec):
|
def _create_or_update_workflows(wb_db, workflows_spec):
|
||||||
|
@ -31,6 +31,12 @@ WORKBOOK = """
|
|||||||
---
|
---
|
||||||
Version: '2.0'
|
Version: '2.0'
|
||||||
|
|
||||||
|
Actions:
|
||||||
|
concat:
|
||||||
|
base: std.echo
|
||||||
|
base-parameters:
|
||||||
|
output: "{$.str1}{$.str2}"
|
||||||
|
|
||||||
Workflows:
|
Workflows:
|
||||||
wf1:
|
wf1:
|
||||||
type: reverse
|
type: reverse
|
||||||
@ -62,6 +68,12 @@ UPDATED_WORKBOOK = """
|
|||||||
---
|
---
|
||||||
Version: '2.0'
|
Version: '2.0'
|
||||||
|
|
||||||
|
Actions:
|
||||||
|
concat:
|
||||||
|
base: std.echo
|
||||||
|
base-parameters:
|
||||||
|
output: "{$.str1}{$.str2}"
|
||||||
|
|
||||||
Workflows:
|
Workflows:
|
||||||
wf1:
|
wf1:
|
||||||
type: direct
|
type: direct
|
||||||
@ -104,6 +116,20 @@ class WorkbookServiceTest(base.EngineTestCase):
|
|||||||
self.assertIsNotNone(wb_db.spec)
|
self.assertIsNotNone(wb_db.spec)
|
||||||
self.assertListEqual(['test'], wb_db.tags)
|
self.assertListEqual(['test'], wb_db.tags)
|
||||||
|
|
||||||
|
db_actions = db_api.get_actions(name='my_wb.concat')
|
||||||
|
|
||||||
|
self.assertEqual(1, len(db_actions))
|
||||||
|
|
||||||
|
# Action.
|
||||||
|
action_db = self._assert_single_item(db_actions, name='my_wb.concat')
|
||||||
|
|
||||||
|
self.assertFalse(action_db.is_system)
|
||||||
|
|
||||||
|
action_spec = spec_parser.get_action_spec(action_db.spec)
|
||||||
|
|
||||||
|
self.assertEqual('concat', action_spec.get_name())
|
||||||
|
self.assertEqual('std.echo', action_spec.get_base())
|
||||||
|
|
||||||
db_wfs = db_api.get_workflows()
|
db_wfs = db_api.get_workflows()
|
||||||
|
|
||||||
self.assertEqual(2, len(db_wfs))
|
self.assertEqual(2, len(db_wfs))
|
||||||
|
Loading…
Reference in New Issue
Block a user