You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by mx...@apache.org on 2017/07/30 15:18:45 UTC
incubator-ariatosca git commit: fixed issue with reqs and caps issue
where target capability types are not properly satisfied
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-174-Refactor-instantiation-phase d6b268958 -> 4b6e51b0a
fixed issue with reqs and caps issue where target capability types are not properly satisfied
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/4b6e51b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/4b6e51b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/4b6e51b0
Branch: refs/heads/ARIA-174-Refactor-instantiation-phase
Commit: 4b6e51b0a589de8978ee6e90dd84a05f38387f50
Parents: d6b2689
Author: max-orlov <ma...@gigaspaces.com>
Authored: Sun Jul 30 18:17:07 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Sun Jul 30 18:17:07 2017 +0300
----------------------------------------------------------------------
aria/orchestrator/topology/instance_handler.py | 8 ++++
tests/parser/service_templates.py | 18 +++++++--
tests/parser/test_reqs_caps.py | 29 ++++++++++++++
.../tosca-simple-1.0/reqs_caps/reqs_caps1.yaml | 40 ++++++++++++++++++++
4 files changed, 91 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4b6e51b0/aria/orchestrator/topology/instance_handler.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/instance_handler.py b/aria/orchestrator/topology/instance_handler.py
index 2c32466..dbebf48 100644
--- a/aria/orchestrator/topology/instance_handler.py
+++ b/aria/orchestrator/topology/instance_handler.py
@@ -289,6 +289,14 @@ class Node(common._OperatorHolderHandlerMixin):
return target_node_template, target_node_capability
+ elif requirement_template.target_capability_type is not None:
+ for target_node_template in \
+ self._model.node_template.service_template.node_templates.itervalues():
+ target_node_capability = \
+ self._get_capability(requirement_template, target_node_template)
+ if target_node_capability:
+ return target_node_template, target_node_capability
+
return None, None
def _get_capability(self, requirement_template, target_node_template=None):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4b6e51b0/tests/parser/service_templates.py
----------------------------------------------------------------------
diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py
index 13712df..6b12576 100644
--- a/tests/parser/service_templates.py
+++ b/tests/parser/service_templates.py
@@ -49,13 +49,23 @@ def consume_use_case(use_case_name, consumer_class_name='instance', cache=True):
def consume_node_cellar(consumer_class_name='instance', cache=True):
+ consume_test_case(
+ get_service_template_uri('tosca-simple-1.0', 'node-cellar', 'node-cellar.yaml'),
+ consumer_class_name=consumer_class_name,
+ inputs_uri=get_service_template_uri('tosca-simple-1.0', 'node-cellar', 'inputs.yaml'),
+ cache=cache
+
+ )
+
+
+def consume_test_case(uri, inputs_uri=None, consumer_class_name='instance', cache=True):
cachedmethod.ENABLED = cache
- uri = get_service_template_uri('tosca-simple-1.0', 'node-cellar', 'node-cellar.yaml')
+ uri = get_service_template_uri(uri)
context = create_context(uri)
- context.args.append('--inputs=' + get_service_template_uri('tosca-simple-1.0', 'node-cellar',
- 'inputs.yaml'))
+ if inputs_uri:
+ context.args.append('--inputs=' + get_service_template_uri(inputs_uri))
consumer, dumper = create_consumer(context, consumer_class_name)
consumer.consume()
context.validation.dump_issues()
assert not context.validation.has_issues
- return context, dumper
+ return context, dumper
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4b6e51b0/tests/parser/test_reqs_caps.py
----------------------------------------------------------------------
diff --git a/tests/parser/test_reqs_caps.py b/tests/parser/test_reqs_caps.py
new file mode 100644
index 0000000..0af2487
--- /dev/null
+++ b/tests/parser/test_reqs_caps.py
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .service_templates import consume_test_case
+from ..helpers import get_service_template_uri
+
+
+def test_satisfy_capability_type():
+ consume_reqs_caps_template('instance')
+
+
+def consume_reqs_caps_template(consumer_class_name, cache=True):
+ consume_test_case(
+ get_service_template_uri('tosca-simple-1.0', 'reqs_caps', 'reqs_caps1.yaml'),
+ consumer_class_name=consumer_class_name,
+ cache=cache
+ )
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4b6e51b0/tests/resources/service-templates/tosca-simple-1.0/reqs_caps/reqs_caps1.yaml
----------------------------------------------------------------------
diff --git a/tests/resources/service-templates/tosca-simple-1.0/reqs_caps/reqs_caps1.yaml b/tests/resources/service-templates/tosca-simple-1.0/reqs_caps/reqs_caps1.yaml
new file mode 100644
index 0000000..466a78e
--- /dev/null
+++ b/tests/resources/service-templates/tosca-simple-1.0/reqs_caps/reqs_caps1.yaml
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+capability_types:
+ Socket:
+ derived_from: tosca.capabilities.Root
+
+node_types:
+ Socket:
+ derived_from: tosca.nodes.Root
+ capabilities:
+ socket: Socket
+
+ Plug:
+ derived_from: tosca.nodes.Root
+ requirements:
+ - plug:
+ capability: Socket
+
+topology_template:
+ node_templates:
+ socket:
+ type: Socket
+
+ plug:
+ type: Plug
\ No newline at end of file