You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by em...@apache.org on 2017/03/31 19:35:18 UTC

incubator-ariatosca git commit: ARIA-134 Parser populates service workflows

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-134-populate-workflows [created] 5edbf938d


ARIA-134 Parser populates service workflows


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/5edbf938
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5edbf938
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5edbf938

Branch: refs/heads/ARIA-134-populate-workflows
Commit: 5edbf938ddbcd8b3398411bbe7d3b486032bd275
Parents: 4400e30
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Mar 31 14:34:41 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Fri Mar 31 14:34:41 2017 -0500

----------------------------------------------------------------------
 aria/cli/dry.py                                 |  2 +-
 aria/modeling/service_instance.py               | 10 ++-----
 .../simple_v1_0/modeling/__init__.py            | 30 +++++++++++++++++++-
 3 files changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5edbf938/aria/cli/dry.py
----------------------------------------------------------------------
diff --git a/aria/cli/dry.py b/aria/cli/dry.py
index 82faf42..098638f 100644
--- a/aria/cli/dry.py
+++ b/aria/cli/dry.py
@@ -31,7 +31,7 @@ def convert_to_dry(service):
     interfaces) to run dryly.
     """
 
-    for workflow in service.workflows:
+    for workflow in service.workflows.itervalues():
         convert_operation_to_dry(workflow)
 
     for node in service.nodes.itervalues():

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5edbf938/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py
index e6c2b12..d15aa7e 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -121,6 +121,7 @@ class ServiceBase(InstanceModelMixin):
     # endregion
 
     # region one_to_many relationships
+
     @declared_attr
     def updates(cls):
         return relationship.one_to_many(cls, 'service_update')
@@ -134,10 +135,6 @@ class ServiceBase(InstanceModelMixin):
         return relationship.one_to_many(cls, 'execution')
 
     @declared_attr
-    def operations(cls):
-        return relationship.one_to_many(cls, 'operation')
-
-    @declared_attr
     def nodes(cls):
         return relationship.one_to_many(cls, 'node', dict_key='name')
 
@@ -164,6 +161,7 @@ class ServiceBase(InstanceModelMixin):
     # endregion
 
     # region many_to_many relationships
+
     @declared_attr
     def meta_data(cls):
         # Warning! We cannot use the attr name "metadata" because it's used by SQLAlchemy!
@@ -1666,7 +1664,7 @@ class OperationBase(InstanceModelMixin):
 
     @declared_attr
     def service(cls):
-        return relationship.many_to_one(cls, 'service')
+        return relationship.many_to_one(cls, 'service', back_populates='workflows')
 
     @declared_attr
     def interface(cls):
@@ -1693,8 +1691,6 @@ class OperationBase(InstanceModelMixin):
     max_retries = Column(Integer)
     retry_interval = Column(Integer)
 
-
-
     @property
     def as_raw(self):
         return collections.OrderedDict((

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5edbf938/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index d0a39e6..267f6de 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -85,9 +85,14 @@ def create_service_template_model(context): # pylint: disable=too-many-locals,to
     policies = context.presentation.get('service_template', 'topology_template', 'policies')
     if policies:
         for policy in policies.itervalues():
-            if model.policy_types.get_descendant(policy.type).role == 'plugin':
+            role = model.policy_types.get_descendant(policy.type).role
+            if role == 'plugin':
                 plugin_specification = create_plugin_specification_model(context, policy)
                 model.plugin_specifications[plugin_specification.name] = plugin_specification
+            elif role == 'workflow':
+                operation_template = create_workflow_operation_template_model(context,
+                                                                              model, policy)
+                model.workflow_templates[operation_template.name] = operation_template
 
     # Node templates
     node_templates = context.presentation.get('service_template', 'topology_template',
@@ -446,6 +451,29 @@ def create_plugin_specification_model(context, policy):
     return model
 
 
+def create_workflow_operation_template_model(context, service_template, policy):
+    model = OperationTemplate(name=policy._name,
+                              service_template=service_template)
+
+    if policy.description:
+        model.description = policy.description.value
+
+    properties = policy._get_property_values(context)
+    for prop_name, prop in properties.iteritems():
+        if prop_name == 'implementation':
+            model.plugin_specification, model.implementation = \
+                parse_implementation_string(context, service_template, prop.value)
+        elif prop_name == 'dependencies':
+            model.dependencies = prop.value
+        else:
+            model.inputs[prop_name] = Parameter(name=prop_name,
+                                                type_name=prop.type,
+                                                value=prop.value,
+                                                description=prop.description)
+
+    return model
+
+
 #
 # Utils
 #