Merge "Make CinderVolume attachment info available"

This commit is contained in:
Jenkins 2017-04-17 09:48:08 +00:00 committed by Gerrit Code Review
commit 928db440f2
4 changed files with 46 additions and 2 deletions

View File

@ -51,6 +51,10 @@ Properties:
sourceVolumeBackup:
Contract: $.class(CinderVolumeBackup)
attachments:
Contract: []
Usage: Out
Methods:
buildResourceDefinition:
Body:
@ -95,6 +99,9 @@ Methods:
outputs:
format('vol-{0}-id', id($)):
value: $.getRef()
format('vol-{0}-attachments', id($)):
value:
get_attr: [$.getResourceName(), attachments_list]
deploy:
Body:
@ -132,13 +139,25 @@ Methods:
- $region.stack.push()
- $.setAttr(lastTemplate, null)
- $.openstackId: null
- $.attachments: null
getRef:
Body:
Return:
get_resource: format('vol-{0}', id($))
getResourceName:
Body:
Return:
format('vol-{0}', id($))
getResourceType:
Body:
- Return: 'OS::Cinder::Volume'
setAttachments:
Arguments:
- attachments:
Contract: []
Body:
- $.attachments: $attachments

View File

@ -186,6 +186,10 @@ Methods:
- $region: $.getRegion()
- $region.stack.push()
- $outputs: $region.stack.output()
- For: blockDevice
In: $.blockDevices
Do:
- $blockDevice.volume.setAttachments($outputs.get(format('{0}-attachments', $blockDevice.volume.getResourceName())))
- $.openstackId: $outputs.get(format('{0}-id', $this.name))
- If: $._floatingIpOutputName != null
Then:

View File

@ -338,10 +338,29 @@ class BaseApplicationCatalogScenarioTest(base.BaseTestCase):
stack_outputs = self.orchestration_client.\
show_stack(stack)['stack']['outputs']
for output in stack_outputs:
if 'vol' in output['output_key']:
if (output['output_key'].startswith('vol-') and
output['output_key'].endswith('-id')):
volume_id = output['output_value']
return self.volumes_client.show_volume(volume_id)['volume']
def get_volume_attachments(self, environment_id):
stack = self.get_stack_id(environment_id)
stack_outputs = self.orchestration_client.\
show_stack(stack)['stack']['outputs']
for output in stack_outputs:
if (output['output_key'].startswith('vol-') and
output['output_key'].endswith('-attachments')):
return output['output_value']
def check_volume_attachments(self, environment_id):
volume_attachments = self.get_volume_attachments(environment_id)
self.assertIsInstance(volume_attachments, list)
self.assertGreater(len(volume_attachments), 0)
instance_id = self.get_instance_id('testMurano')
for attachment in volume_attachments:
self.assertEqual(attachment.get('server_id'), instance_id)
self.assertTrue(attachment.get('device').startswith('/dev/'))
def check_volume_attached(self, name, volume_id):
instance_id = self.get_instance_id(name)
attached_volumes = self.servers_client.\

View File

@ -172,7 +172,8 @@ class TestCinderVolumes(base.BaseApplicationCatalogScenarioTest):
4. Make sure that deployment finished successfully
5. Check that application is accessible
6. Check that volume is attached to the instance and has size 1GiB
7. Delete environment
7. Check that we can access some attachment info about the volume
8. Delete environment
"""
name = utils.generate_name('testMurano')
environment = self.application_catalog_client.\
@ -196,6 +197,7 @@ class TestCinderVolumes(base.BaseApplicationCatalogScenarioTest):
volume_data = self.get_volume(environment['id'])
self.check_volume_attached('testMurano', volume_data['id'])
self.check_volume_attachments(environment['id'])
self.assertEqual(volume_data['size'], 1)
@testtools.testcase.attr('smoke')