From 741cb2831b17d1924f71585508767960b4f32da6 Mon Sep 17 00:00:00 2001 From: spzala Date: Tue, 7 Jul 2015 08:51:09 -0700 Subject: [PATCH] Update TOSCA relationship valid targets The spec has added a new keyword to represent valid target types for TOSCA relationship as ideally it's not targets but capability types. Change-Id: Ib2531010a9f0fc5b529c9917bbf486d99e5ea339 --- .../toscalib/elements/TOSCA_definition_1_0_0.yaml | 10 +++++----- translator/toscalib/elements/relationshiptype.py | 4 ++-- translator/toscalib/functions.py | 2 +- translator/toscalib/tests/test_toscadef.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/translator/toscalib/elements/TOSCA_definition_1_0_0.yaml b/translator/toscalib/elements/TOSCA_definition_1_0_0.yaml index d537253a..90f9b66c 100644 --- a/translator/toscalib/elements/TOSCA_definition_1_0_0.yaml +++ b/translator/toscalib/elements/TOSCA_definition_1_0_0.yaml @@ -356,15 +356,15 @@ tosca.relationships.DependsOn: tosca.relationships.HostedOn: derived_from: tosca.relationships.DependsOn - valid_targets: [ tosca.capabilities.Container ] + valid_target_types: [ tosca.capabilities.Container ] tosca.relationships.ConnectsTo: derived_from: tosca.relationships.DependsOn - valid_targets: [ tosca.capabilities.Endpoint ] + valid_target_types: [ tosca.capabilities.Endpoint ] tosca.relationships.AttachesTo: derived_from: tosca.relationships.Root - valid_targets: [ tosca.capabilities.Attachment ] + valid_target_types: [ tosca.capabilities.Attachment ] properties: location: required: true @@ -377,11 +377,11 @@ tosca.relationships.AttachesTo: tosca.relationships.network.LinksTo: derived_from: tosca.relationships.DependsOn - valid_targets: [ tosca.capabilities.network.Linkable ] + valid_target_types: [ tosca.capabilities.network.Linkable ] tosca.relationships.network.BindsTo: derived_from: tosca.relationships.DependsOn - valid_targets: [ tosca.capabilities.network.Bindable ] + valid_target_types: [ tosca.capabilities.network.Bindable ] ########################################################################## # Capability Type. diff --git a/translator/toscalib/elements/relationshiptype.py b/translator/toscalib/elements/relationshiptype.py index 8c6349bc..c5ecdce2 100644 --- a/translator/toscalib/elements/relationshiptype.py +++ b/translator/toscalib/elements/relationshiptype.py @@ -29,5 +29,5 @@ class RelationshipType(StatefulEntityType): return RelationshipType(prel) @property - def valid_targets(self): - return self.entity_value(self.defs, 'valid_targets') + def valid_target_types(self): + return self.entity_value(self.defs, 'valid_target_types') diff --git a/translator/toscalib/functions.py b/translator/toscalib/functions.py index 456ab862..63cf65a4 100644 --- a/translator/toscalib/functions.py +++ b/translator/toscalib/functions.py @@ -168,7 +168,7 @@ class GetAttribute(Function): target_node = self._find_node_template(target_name) target_type = target_node.type_definition for capability in target_type.get_capabilities_objects(): - if capability.type in hosted_on_rel['valid_targets']: + if capability.type in hosted_on_rel['valid_target_types']: if self._attribute_exists_in_type(target_type): return target_node return self._find_host_containing_attribute( diff --git a/translator/toscalib/tests/test_toscadef.py b/translator/toscalib/tests/test_toscadef.py index 2481bce8..aca8e23c 100644 --- a/translator/toscalib/tests/test_toscadef.py +++ b/translator/toscalib/tests/test_toscadef.py @@ -145,7 +145,7 @@ class ToscaDefTest(TestCase): relation, node in component_type.relationship.items()]) self.assertIn( ('tosca.relationships.HostedOn', ['tosca.capabilities.Container']), - [(relation.type, relation.valid_targets) for + [(relation.type, relation.valid_target_types) for relation in list(component_type.relationship.keys())]) self.assertIn( ('tosca.relationships.network.BindsTo', 'tosca.nodes.Compute'),