From e667abdb8415c3150264e93208af979c3c8f0b40 Mon Sep 17 00:00:00 2001 From: zhurong Date: Wed, 19 Jul 2017 09:21:58 +0800 Subject: [PATCH] Make cinder volume attachments available This commit is revert from Ib996bf50e1b7d542b98cf9d7125b824771c143d6, Change-Id: Ie866833d205c119254b811654426c586c338d7c8 Closes-Bug: #1703387 --- .../Classes/resources/CinderVolume.yaml | 3 +++ .../scenario/application_catalog/base.py | 25 +++++++++++-------- .../test_cinder_volumes.py | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/meta/io.murano/Classes/resources/CinderVolume.yaml b/meta/io.murano/Classes/resources/CinderVolume.yaml index bb40fd65..19fdde55 100644 --- a/meta/io.murano/Classes/resources/CinderVolume.yaml +++ b/meta/io.murano/Classes/resources/CinderVolume.yaml @@ -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: diff --git a/murano_tempest_tests/tests/scenario/application_catalog/base.py b/murano_tempest_tests/tests/scenario/application_catalog/base.py index 25d28a14..98f072ad 100644 --- a/murano_tempest_tests/tests/scenario/application_catalog/base.py +++ b/murano_tempest_tests/tests/scenario/application_catalog/base.py @@ -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) diff --git a/murano_tempest_tests/tests/scenario/application_catalog/test_cinder_volumes.py b/murano_tempest_tests/tests/scenario/application_catalog/test_cinder_volumes.py index 18e63739..e1eab971 100644 --- a/murano_tempest_tests/tests/scenario/application_catalog/test_cinder_volumes.py +++ b/murano_tempest_tests/tests/scenario/application_catalog/test_cinder_volumes.py @@ -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')