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
This commit is contained in:
parent
b1326d4490
commit
1727e773b9
@ -16,7 +16,7 @@ from translator.toscalib.functions import GetInput
|
|||||||
|
|
||||||
|
|
||||||
class ToscaBlockStorageAttachment(HotResource):
|
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):
|
def __init__(self, template, nodetemplates, instace_uuid, volume_id):
|
||||||
super(ToscaBlockStorageAttachment,
|
super(ToscaBlockStorageAttachment,
|
||||||
|
@ -162,7 +162,7 @@ class TranslateNodeTemplates():
|
|||||||
attach = False
|
attach = False
|
||||||
ntpl = self.nodetemplates
|
ntpl = self.nodetemplates
|
||||||
for key, value in node.relationships.items():
|
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':
|
if value.type == 'tosca.nodes.BlockStorage':
|
||||||
attach = True
|
attach = True
|
||||||
if attach:
|
if attach:
|
||||||
|
@ -39,7 +39,7 @@ node_templates:
|
|||||||
version: 18
|
version: 18
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: my_storage
|
- attachment: my_storage
|
||||||
type: AttachTo
|
type: AttachesTo
|
||||||
properties:
|
properties:
|
||||||
location: { get_input: storage_location }
|
location: { get_input: storage_location }
|
||||||
my_storage:
|
my_storage:
|
||||||
|
@ -69,7 +69,7 @@ node_templates:
|
|||||||
|
|
||||||
relationship_types:
|
relationship_types:
|
||||||
MyAttachTo:
|
MyAttachTo:
|
||||||
derived_from: tosca.relationships.AttachTo
|
derived_from: tosca.relationships.AttachesTo
|
||||||
properties: # follows the syntax of property definitions
|
properties: # follows the syntax of property definitions
|
||||||
location:
|
location:
|
||||||
type: string
|
type: string
|
||||||
|
@ -39,7 +39,7 @@ node_templates:
|
|||||||
version: 18
|
version: 18
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: my_storage
|
- attachment: my_storage
|
||||||
template: storage_attachto_1
|
template: storage_attachesto_1
|
||||||
|
|
||||||
my_web_app_tier_2:
|
my_web_app_tier_2:
|
||||||
type: tosca.nodes.Compute
|
type: tosca.nodes.Compute
|
||||||
@ -57,7 +57,7 @@ node_templates:
|
|||||||
version: 18
|
version: 18
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: my_storage
|
- attachment: my_storage
|
||||||
template: storage_attachto_2
|
template: storage_attachesto_2
|
||||||
|
|
||||||
my_storage:
|
my_storage:
|
||||||
type: tosca.nodes.BlockStorage
|
type: tosca.nodes.BlockStorage
|
||||||
@ -66,19 +66,19 @@ node_templates:
|
|||||||
snapshot_id: { get_input: storage_snapshot_id }
|
snapshot_id: { get_input: storage_snapshot_id }
|
||||||
|
|
||||||
relationship_templates:
|
relationship_templates:
|
||||||
storage_attachto_1:
|
storage_attachesto_1:
|
||||||
type: MyAttachTo
|
type: MyAttachTo
|
||||||
properties:
|
properties:
|
||||||
location: /my_data_location
|
location: /my_data_location
|
||||||
|
|
||||||
storage_attachto_2:
|
storage_attachesto_2:
|
||||||
type: MyAttachTo
|
type: MyAttachTo
|
||||||
properties:
|
properties:
|
||||||
location: /some_other_data_location
|
location: /some_other_data_location
|
||||||
|
|
||||||
relationship_types:
|
relationship_types:
|
||||||
MyAttachTo:
|
MyAttachTo:
|
||||||
derived_from: tosca.relationships.AttachTo
|
derived_from: tosca.relationships.AttachesTo
|
||||||
properties: # follows the syntax of property definitions
|
properties: # follows the syntax of property definitions
|
||||||
location:
|
location:
|
||||||
type: string
|
type: string
|
||||||
|
@ -37,7 +37,7 @@ node_templates:
|
|||||||
version: 18
|
version: 18
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: my_storage
|
- attachment: my_storage
|
||||||
type: AttachTo
|
type: AttachesTo
|
||||||
properties:
|
properties:
|
||||||
location: { get_input: storage_location }
|
location: { get_input: storage_location }
|
||||||
my_storage:
|
my_storage:
|
||||||
@ -62,7 +62,7 @@ node_templates:
|
|||||||
version: 18
|
version: 18
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: my_storage2
|
- attachment: my_storage2
|
||||||
type: AttachTo
|
type: AttachesTo
|
||||||
properties:
|
properties:
|
||||||
location: { get_input: storage_location }
|
location: { get_input: storage_location }
|
||||||
my_storage2:
|
my_storage2:
|
||||||
|
@ -32,7 +32,7 @@ class ToscaBlockStorageTest(TestCase):
|
|||||||
translate = TOSCATranslator(tosca, self.parsed_params)
|
translate = TOSCATranslator(tosca, self.parsed_params)
|
||||||
output = translate.translate()
|
output = translate.translate()
|
||||||
|
|
||||||
expected_resouce = {'attachto_1':
|
expected_resouce = {'attachesto_1':
|
||||||
{'type': 'OS::Cinder::VolumeAttachment',
|
{'type': 'OS::Cinder::VolumeAttachment',
|
||||||
'properties':
|
'properties':
|
||||||
{'instance_uuid': 'my_server',
|
{'instance_uuid': 'my_server',
|
||||||
@ -42,8 +42,8 @@ class ToscaBlockStorageTest(TestCase):
|
|||||||
output_dict = translator.toscalib.utils.yamlparser.simple_parse(output)
|
output_dict = translator.toscalib.utils.yamlparser.simple_parse(output)
|
||||||
|
|
||||||
resources = output_dict.get('resources')
|
resources = output_dict.get('resources')
|
||||||
translated_value = resources.get('attachto_1')
|
translated_value = resources.get('attachesto_1')
|
||||||
expected_value = expected_resouce.get('attachto_1')
|
expected_value = expected_resouce.get('attachesto_1')
|
||||||
self.assertEqual(translated_value, expected_value)
|
self.assertEqual(translated_value, expected_value)
|
||||||
|
|
||||||
outputs = output_dict['outputs']
|
outputs = output_dict['outputs']
|
||||||
@ -114,12 +114,12 @@ class ToscaBlockStorageTest(TestCase):
|
|||||||
resources = output_dict.get('resources')
|
resources = output_dict.get('resources')
|
||||||
# Resource name suffix depends on nodetemplates order in dict, which is
|
# Resource name suffix depends on nodetemplates order in dict, which is
|
||||||
# not certain. So we have two possibilities of resources name.
|
# not certain. So we have two possibilities of resources name.
|
||||||
if resources.get('storage_attachto_1_1'):
|
if resources.get('storage_attachesto_1_1'):
|
||||||
self.assertIn('storage_attachto_1_1', resources.keys())
|
self.assertIn('storage_attachesto_1_1', resources.keys())
|
||||||
self.assertIn('storage_attachto_2_2', resources.keys())
|
self.assertIn('storage_attachesto_2_2', resources.keys())
|
||||||
else:
|
else:
|
||||||
self.assertIn('storage_attachto_1_2', resources.keys())
|
self.assertIn('storage_attachesto_1_2', resources.keys())
|
||||||
self.assertIn('storage_attachto_2_1', resources.keys())
|
self.assertIn('storage_attachesto_2_1', resources.keys())
|
||||||
|
|
||||||
self.assertIn(expected_resource_1, resources.values())
|
self.assertIn(expected_resource_1, resources.values())
|
||||||
self.assertIn(expected_resource_2, 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)
|
output_dict = translator.toscalib.utils.yamlparser.simple_parse(output)
|
||||||
resources = output_dict.get('resources')
|
resources = output_dict.get('resources')
|
||||||
translated_volume_attachment.append(resources.get('attachto_1'))
|
translated_volume_attachment.append(resources.get('attachesto_1'))
|
||||||
translated_volume_attachment.append(resources.get('attachto_2'))
|
translated_volume_attachment.append(resources.get('attachesto_2'))
|
||||||
self.assertIn(expected_resource_1, translated_volume_attachment)
|
self.assertIn(expected_resource_1, translated_volume_attachment)
|
||||||
self.assertIn(expected_resource_2, translated_volume_attachment)
|
self.assertIn(expected_resource_2, translated_volume_attachment)
|
||||||
|
@ -67,7 +67,7 @@ tosca.nodes.Compute:
|
|||||||
type: tosca.capabilities.Scalable
|
type: tosca.capabilities.Scalable
|
||||||
requirements:
|
requirements:
|
||||||
- attachment: tosca.nodes.BlockStorage
|
- attachment: tosca.nodes.BlockStorage
|
||||||
type: AttachTo
|
type: AttachesTo
|
||||||
|
|
||||||
tosca.nodes.SoftwareComponent:
|
tosca.nodes.SoftwareComponent:
|
||||||
derived_from: tosca.nodes.Root
|
derived_from: tosca.nodes.Root
|
||||||
@ -304,7 +304,7 @@ tosca.relationships.ConnectsTo:
|
|||||||
derived_from: tosca.relationships.DependsOn
|
derived_from: tosca.relationships.DependsOn
|
||||||
valid_targets: [ tosca.capabilities.Endpoint ]
|
valid_targets: [ tosca.capabilities.Endpoint ]
|
||||||
|
|
||||||
tosca.relationships.AttachTo:
|
tosca.relationships.AttachesTo:
|
||||||
derived_from: tosca.relationships.Root
|
derived_from: tosca.relationships.Root
|
||||||
valid_targets: [ tosca.capabilities.Attachment ]
|
valid_targets: [ tosca.capabilities.Attachment ]
|
||||||
properties:
|
properties:
|
||||||
|
@ -35,12 +35,12 @@ class EntityType(object):
|
|||||||
|
|
||||||
TOSCA_DEF = loader(TOSCA_DEF_FILE)
|
TOSCA_DEF = loader(TOSCA_DEF_FILE)
|
||||||
|
|
||||||
RELATIONSHIP_TYPE = (DEPENDSON, HOSTEDON, CONNECTSTO, ATTACHTO,
|
RELATIONSHIP_TYPE = (DEPENDSON, HOSTEDON, CONNECTSTO, ATTACHESTO,
|
||||||
LINKSTO, BINDSTO) = \
|
LINKSTO, BINDSTO) = \
|
||||||
('tosca.relationships.DependsOn',
|
('tosca.relationships.DependsOn',
|
||||||
'tosca.relationships.HostedOn',
|
'tosca.relationships.HostedOn',
|
||||||
'tosca.relationships.ConnectsTo',
|
'tosca.relationships.ConnectsTo',
|
||||||
'tosca.relationships.AttachTo',
|
'tosca.relationships.AttachesTo',
|
||||||
'tosca.relationships.network.LinksTo',
|
'tosca.relationships.network.LinksTo',
|
||||||
'tosca.relationships.network.BindsTo')
|
'tosca.relationships.network.BindsTo')
|
||||||
|
|
||||||
|
@ -48,6 +48,6 @@ node_templates:
|
|||||||
|
|
||||||
relationship_templates:
|
relationship_templates:
|
||||||
storage_attachment:
|
storage_attachment:
|
||||||
type: tosca.relationships.AttachTo
|
type: tosca.relationships.AttachesTo
|
||||||
properties:
|
properties:
|
||||||
location: /temp
|
location: /temp
|
@ -251,7 +251,7 @@ class ToscaTemplateTest(TestCase):
|
|||||||
node in node_tpl.relationships.items()])
|
node in node_tpl.relationships.items()])
|
||||||
if node_tpl.name == 'my_server':
|
if node_tpl.name == 'my_server':
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[('tosca.relationships.AttachTo', 'my_storage')],
|
[('tosca.relationships.AttachesTo', 'my_storage')],
|
||||||
[(relation.type, node.name) for
|
[(relation.type, node.name) for
|
||||||
relation,
|
relation,
|
||||||
node in node_tpl.relationships.items()])
|
node in node_tpl.relationships.items()])
|
||||||
|
@ -395,7 +395,7 @@ class ToscaTemplateValidationTest(TestCase):
|
|||||||
tpl_snippet = '''
|
tpl_snippet = '''
|
||||||
relationship_templates:
|
relationship_templates:
|
||||||
storage_attachto:
|
storage_attachto:
|
||||||
type: AttachTo
|
type: AttachesTo
|
||||||
properties:
|
properties:
|
||||||
device: test_device
|
device: test_device
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user