Enable _get_explicit_relationship to maintain original relationship type name
Related-Bug #189726 Change-Id: I843fa7dfc928cb811ffd2fd8145644663e239976
This commit is contained in:
parent
6b92c81835
commit
b598d9cfe4
@ -37,6 +37,10 @@ class RelationshipType(StatefulEntityType):
|
||||
if prel:
|
||||
return RelationshipType(prel, self.custom_def)
|
||||
|
||||
@property
|
||||
def interfaces(self):
|
||||
return self.get_value(self.INTERFACES)
|
||||
|
||||
@property
|
||||
def valid_target_types(self):
|
||||
return self.entity_value(self.defs, 'valid_target_types')
|
||||
|
@ -160,7 +160,7 @@ class NodeTemplate(EntityTemplate):
|
||||
explicit_relation[rtype] = related_tpl
|
||||
related_tpl.\
|
||||
_add_relationship_template(
|
||||
req, rtype.type, self)
|
||||
req, relationship, self)
|
||||
return explicit_relation
|
||||
|
||||
def _add_relationship_template(self, requirement, rtype, source):
|
||||
|
32
toscaparser/tests/data/test_tosca_custom_rel.yaml
Normal file
32
toscaparser/tests/data/test_tosca_custom_rel.yaml
Normal file
@ -0,0 +1,32 @@
|
||||
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||
|
||||
topology_template:
|
||||
|
||||
node_templates:
|
||||
|
||||
my_block_storage:
|
||||
type: BlockStorage
|
||||
properties:
|
||||
size: 10 MB
|
||||
|
||||
some_compute:
|
||||
type: Compute
|
||||
requirements:
|
||||
- local_storage:
|
||||
node: my_block_storage
|
||||
relationship:
|
||||
type: MyAttachesTo
|
||||
properties:
|
||||
location: /some_other_data_location
|
||||
|
||||
relationship_types:
|
||||
|
||||
MyAttachesTo:
|
||||
derived_from: AttachesTo
|
||||
properties:
|
||||
location: /default_location
|
||||
interfaces:
|
||||
Configure:
|
||||
post_configure_target:
|
||||
implementation: default_script.sh
|
||||
|
@ -995,3 +995,14 @@ class ToscaTemplateTest(TestCase):
|
||||
flavours.append(flavour)
|
||||
self.assertEqual(flavours[0]['flavour_id'], 'simple')
|
||||
self.assertEqual(flavours[1]['flavour_id'], 'complex')
|
||||
|
||||
def test_custom_rel_get_type(self):
|
||||
tosca_tpl = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"data/test_tosca_custom_rel.yaml")
|
||||
tosca = ToscaTemplate(tosca_tpl)
|
||||
for src in tosca.nodetemplates:
|
||||
for rel, trgt in src.relationships.items():
|
||||
rel_tpls = trgt.get_relationship_template()
|
||||
|
||||
self.assertEqual(rel_tpls[0].type, "MyAttachesTo")
|
||||
|
Loading…
x
Reference in New Issue
Block a user