Make cinder volume attachments available

This commit is revert from Ib996bf50e1b7d542b98cf9d7125b824771c143d6,

Change-Id: Ie866833d205c119254b811654426c586c338d7c8
Closes-Bug: #1703387
This commit is contained in:
zhurong 2017-07-19 09:21:58 +08:00
parent 95c3326587
commit e667abdb84
3 changed files with 19 additions and 11 deletions

View File

@ -99,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:

View File

@ -357,23 +357,28 @@ class BaseApplicationCatalogScenarioTest(test.BaseTestCase):
volume_id = output['output_value']
return self.volumes_client.show_volume(volume_id)['volume']
def get_volume_attachments(self, name):
instance_id = self.get_instance_id(name)
attached_volumes = self.servers_client.\
list_volume_attachments(instance_id)['volumeAttachments']
return attached_volumes
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, name):
volume_attachments = self.get_volume_attachments(name)
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(name)
instance_id = self.get_instance_id('testMurano')
for attachment in volume_attachments:
self.assertEqual(attachment.get('serverId'), instance_id)
self.assertEqual(attachment.get('server_id'), instance_id)
self.assertTrue(attachment.get('device').startswith('/dev/'))
def check_volume_attached(self, name, volume_id):
attached_volumes = self.get_volume_attachments(name)
instance_id = self.get_instance_id(name)
attached_volumes = self.servers_client.\
list_volume_attachments(instance_id)['volumeAttachments']
self.assertEqual(attached_volumes[0]['id'], volume_id)

View File

@ -197,7 +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('testMurano')
self.check_volume_attachments(environment['id'])
self.assertEqual(volume_data['size'], 1)
@testtools.testcase.attr('smoke')