Make CinderVolume attachment info available

Make the 'attachments' attribute of OS::Cinder::Volume available in
MuranoPL.

Users can do the following in their applications:

  - For: blockDevice
    In: $this.instance.blockDevices
    Do:
      - For: attachment
        In: $blockDevice.volume.attachments
        Do:
          - $reporter.report($this, attachment.device)
          - $reporter.report($this, attachment.attachment_id)
          ...

Implements: blueprint devicename-from-volume-attachment
Change-Id: I2986efde085dd8029f2520cb5744e75f6a66f282
This commit is contained in:
Paul Bourke 2017-03-28 13:59:04 +01:00
parent c25e1619ca
commit 852935684b
2 changed files with 23 additions and 2 deletions

View File

@ -340,10 +340,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')