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/04/05 15:58:26 UTC
[6/6] incubator-ariatosca git commit: ARIA-134 Parser populates
service workflows
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/3a56f122
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3a56f122
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3a56f122
Branch: refs/heads/ARIA-134-populate-workflows
Commit: 3a56f122b9adc591a790d76d38edef269b503fc8
Parents: 422574e
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Mar 31 14:34:41 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Apr 5 10:58:06 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/3a56f122/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/3a56f122/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/3a56f122/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
#