From 1727e773b97c139a735a28f0c7996e5d06993ebe Mon Sep 17 00:00:00 2001 From: spzala Date: Tue, 7 Apr 2015 12:16:29 -0700 Subject: [PATCH] Rename TOSCA AttachTo relationship The AttachTo relationship name has been changed to AttachesTo per the latest TOSCA spec to be consistent with naming like BindsTo, ConnectsTo etc. Change-Id: Ibd0e0232a06b02c494def452755422ab94c4024e --- .../tosca/tosca_block_storage_attachment.py | 2 +- translator/hot/translate_node_templates.py | 2 +- .../tosca_blockstorage_with_attachment.yaml | 2 +- ...lockstorage_with_attachment_notation1.yaml | 2 +- ...lockstorage_with_attachment_notation2.yaml | 10 +++++----- ...multiple_blockstorage_with_attachment.yaml | 4 ++-- translator/tests/test_blockstorage.py | 20 +++++++++---------- .../toscalib/elements/TOSCA_definition.yaml | 4 ++-- translator/toscalib/elements/entitytype.py | 4 ++-- .../tests/data/test_requirements.yaml | 2 +- translator/toscalib/tests/test_toscatpl.py | 2 +- .../toscalib/tests/test_toscatplvalidation.py | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/translator/hot/tosca/tosca_block_storage_attachment.py b/translator/hot/tosca/tosca_block_storage_attachment.py index 2b474bb2..7db987a4 100644 --- a/translator/hot/tosca/tosca_block_storage_attachment.py +++ b/translator/hot/tosca/tosca_block_storage_attachment.py @@ -16,7 +16,7 @@ from translator.toscalib.functions import GetInput class ToscaBlockStorageAttachment(HotResource): - '''Translate TOSCA relationship AttachTo for Compute and BlockStorage.''' + '''Translate TOSCA relationship AttachesTo for Compute and BlockStorage.''' def __init__(self, template, nodetemplates, instace_uuid, volume_id): super(ToscaBlockStorageAttachment, diff --git a/translator/hot/translate_node_templates.py b/translator/hot/translate_node_templates.py index 71474270..c31ae130 100644 --- a/translator/hot/translate_node_templates.py +++ b/translator/hot/translate_node_templates.py @@ -162,7 +162,7 @@ class TranslateNodeTemplates(): attach = False ntpl = self.nodetemplates for key, value in node.relationships.items(): - if key.type == 'tosca.relationships.AttachTo': + if key.type == 'tosca.relationships.AttachesTo': if value.type == 'tosca.nodes.BlockStorage': attach = True if attach: diff --git a/translator/tests/data/tosca_blockstorage_with_attachment.yaml b/translator/tests/data/tosca_blockstorage_with_attachment.yaml index a02ae62f..9d1baf62 100644 --- a/translator/tests/data/tosca_blockstorage_with_attachment.yaml +++ b/translator/tests/data/tosca_blockstorage_with_attachment.yaml @@ -39,7 +39,7 @@ node_templates: version: 18 requirements: - attachment: my_storage - type: AttachTo + type: AttachesTo properties: location: { get_input: storage_location } my_storage: diff --git a/translator/tests/data/tosca_blockstorage_with_attachment_notation1.yaml b/translator/tests/data/tosca_blockstorage_with_attachment_notation1.yaml index 9e8ccab4..09490243 100644 --- a/translator/tests/data/tosca_blockstorage_with_attachment_notation1.yaml +++ b/translator/tests/data/tosca_blockstorage_with_attachment_notation1.yaml @@ -69,7 +69,7 @@ node_templates: relationship_types: MyAttachTo: - derived_from: tosca.relationships.AttachTo + derived_from: tosca.relationships.AttachesTo properties: # follows the syntax of property definitions location: type: string diff --git a/translator/tests/data/tosca_blockstorage_with_attachment_notation2.yaml b/translator/tests/data/tosca_blockstorage_with_attachment_notation2.yaml index c1f103e3..5fa8b504 100644 --- a/translator/tests/data/tosca_blockstorage_with_attachment_notation2.yaml +++ b/translator/tests/data/tosca_blockstorage_with_attachment_notation2.yaml @@ -39,7 +39,7 @@ node_templates: version: 18 requirements: - attachment: my_storage - template: storage_attachto_1 + template: storage_attachesto_1 my_web_app_tier_2: type: tosca.nodes.Compute @@ -57,7 +57,7 @@ node_templates: version: 18 requirements: - attachment: my_storage - template: storage_attachto_2 + template: storage_attachesto_2 my_storage: type: tosca.nodes.BlockStorage @@ -66,19 +66,19 @@ node_templates: snapshot_id: { get_input: storage_snapshot_id } relationship_templates: - storage_attachto_1: + storage_attachesto_1: type: MyAttachTo properties: location: /my_data_location - storage_attachto_2: + storage_attachesto_2: type: MyAttachTo properties: location: /some_other_data_location relationship_types: MyAttachTo: - derived_from: tosca.relationships.AttachTo + derived_from: tosca.relationships.AttachesTo properties: # follows the syntax of property definitions location: type: string diff --git a/translator/tests/data/tosca_multiple_blockstorage_with_attachment.yaml b/translator/tests/data/tosca_multiple_blockstorage_with_attachment.yaml index d6df1812..a884fe12 100644 --- a/translator/tests/data/tosca_multiple_blockstorage_with_attachment.yaml +++ b/translator/tests/data/tosca_multiple_blockstorage_with_attachment.yaml @@ -37,7 +37,7 @@ node_templates: version: 18 requirements: - attachment: my_storage - type: AttachTo + type: AttachesTo properties: location: { get_input: storage_location } my_storage: @@ -62,7 +62,7 @@ node_templates: version: 18 requirements: - attachment: my_storage2 - type: AttachTo + type: AttachesTo properties: location: { get_input: storage_location } my_storage2: diff --git a/translator/tests/test_blockstorage.py b/translator/tests/test_blockstorage.py index 67873318..9fd07ab0 100644 --- a/translator/tests/test_blockstorage.py +++ b/translator/tests/test_blockstorage.py @@ -32,7 +32,7 @@ class ToscaBlockStorageTest(TestCase): translate = TOSCATranslator(tosca, self.parsed_params) output = translate.translate() - expected_resouce = {'attachto_1': + expected_resouce = {'attachesto_1': {'type': 'OS::Cinder::VolumeAttachment', 'properties': {'instance_uuid': 'my_server', @@ -42,8 +42,8 @@ class ToscaBlockStorageTest(TestCase): output_dict = translator.toscalib.utils.yamlparser.simple_parse(output) resources = output_dict.get('resources') - translated_value = resources.get('attachto_1') - expected_value = expected_resouce.get('attachto_1') + translated_value = resources.get('attachesto_1') + expected_value = expected_resouce.get('attachesto_1') self.assertEqual(translated_value, expected_value) outputs = output_dict['outputs'] @@ -114,12 +114,12 @@ class ToscaBlockStorageTest(TestCase): resources = output_dict.get('resources') # Resource name suffix depends on nodetemplates order in dict, which is # not certain. So we have two possibilities of resources name. - if resources.get('storage_attachto_1_1'): - self.assertIn('storage_attachto_1_1', resources.keys()) - self.assertIn('storage_attachto_2_2', resources.keys()) + if resources.get('storage_attachesto_1_1'): + self.assertIn('storage_attachesto_1_1', resources.keys()) + self.assertIn('storage_attachesto_2_2', resources.keys()) else: - self.assertIn('storage_attachto_1_2', resources.keys()) - self.assertIn('storage_attachto_2_1', resources.keys()) + self.assertIn('storage_attachesto_1_2', resources.keys()) + self.assertIn('storage_attachesto_2_1', resources.keys()) self.assertIn(expected_resource_1, resources.values()) self.assertIn(expected_resource_2, resources.values()) @@ -148,7 +148,7 @@ class ToscaBlockStorageTest(TestCase): output_dict = translator.toscalib.utils.yamlparser.simple_parse(output) resources = output_dict.get('resources') - translated_volume_attachment.append(resources.get('attachto_1')) - translated_volume_attachment.append(resources.get('attachto_2')) + translated_volume_attachment.append(resources.get('attachesto_1')) + translated_volume_attachment.append(resources.get('attachesto_2')) self.assertIn(expected_resource_1, translated_volume_attachment) self.assertIn(expected_resource_2, translated_volume_attachment) diff --git a/translator/toscalib/elements/TOSCA_definition.yaml b/translator/toscalib/elements/TOSCA_definition.yaml index 94f50a03..fbfd6843 100644 --- a/translator/toscalib/elements/TOSCA_definition.yaml +++ b/translator/toscalib/elements/TOSCA_definition.yaml @@ -67,7 +67,7 @@ tosca.nodes.Compute: type: tosca.capabilities.Scalable requirements: - attachment: tosca.nodes.BlockStorage - type: AttachTo + type: AttachesTo tosca.nodes.SoftwareComponent: derived_from: tosca.nodes.Root @@ -304,7 +304,7 @@ tosca.relationships.ConnectsTo: derived_from: tosca.relationships.DependsOn valid_targets: [ tosca.capabilities.Endpoint ] -tosca.relationships.AttachTo: +tosca.relationships.AttachesTo: derived_from: tosca.relationships.Root valid_targets: [ tosca.capabilities.Attachment ] properties: diff --git a/translator/toscalib/elements/entitytype.py b/translator/toscalib/elements/entitytype.py index 9d04582f..56d1e783 100644 --- a/translator/toscalib/elements/entitytype.py +++ b/translator/toscalib/elements/entitytype.py @@ -35,12 +35,12 @@ class EntityType(object): TOSCA_DEF = loader(TOSCA_DEF_FILE) - RELATIONSHIP_TYPE = (DEPENDSON, HOSTEDON, CONNECTSTO, ATTACHTO, + RELATIONSHIP_TYPE = (DEPENDSON, HOSTEDON, CONNECTSTO, ATTACHESTO, LINKSTO, BINDSTO) = \ ('tosca.relationships.DependsOn', 'tosca.relationships.HostedOn', 'tosca.relationships.ConnectsTo', - 'tosca.relationships.AttachTo', + 'tosca.relationships.AttachesTo', 'tosca.relationships.network.LinksTo', 'tosca.relationships.network.BindsTo') diff --git a/translator/toscalib/tests/data/test_requirements.yaml b/translator/toscalib/tests/data/test_requirements.yaml index f717ee69..6a9a1089 100644 --- a/translator/toscalib/tests/data/test_requirements.yaml +++ b/translator/toscalib/tests/data/test_requirements.yaml @@ -48,6 +48,6 @@ node_templates: relationship_templates: storage_attachment: - type: tosca.relationships.AttachTo + type: tosca.relationships.AttachesTo properties: location: /temp \ No newline at end of file diff --git a/translator/toscalib/tests/test_toscatpl.py b/translator/toscalib/tests/test_toscatpl.py index 800360fc..e68d80d7 100644 --- a/translator/toscalib/tests/test_toscatpl.py +++ b/translator/toscalib/tests/test_toscatpl.py @@ -251,7 +251,7 @@ class ToscaTemplateTest(TestCase): node in node_tpl.relationships.items()]) if node_tpl.name == 'my_server': self.assertEqual( - [('tosca.relationships.AttachTo', 'my_storage')], + [('tosca.relationships.AttachesTo', 'my_storage')], [(relation.type, node.name) for relation, node in node_tpl.relationships.items()]) diff --git a/translator/toscalib/tests/test_toscatplvalidation.py b/translator/toscalib/tests/test_toscatplvalidation.py index 38a24e36..b41f4b4c 100644 --- a/translator/toscalib/tests/test_toscatplvalidation.py +++ b/translator/toscalib/tests/test_toscatplvalidation.py @@ -395,7 +395,7 @@ class ToscaTemplateValidationTest(TestCase): tpl_snippet = ''' relationship_templates: storage_attachto: - type: AttachTo + type: AttachesTo properties: device: test_device '''