From 44d95acb744be64f12855032a2f83831374a5632 Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Tue, 16 Dec 2014 23:58:36 -0500 Subject: [PATCH] Persist volume uuid on VMAX array This change saves the volume uuid in the ElementName field of a SMI-S volume object so that it persists on the array. Closes-Bug: #1395903 Change-Id: I53945f2864e6cfab756afdaeb17d45dfdac38c02 --- cinder/tests/test_emc_vmax.py | 47 ++++++++++++++----- cinder/volume/drivers/emc/emc_vmax_common.py | 2 +- .../volume/drivers/emc/emc_vmax_provision.py | 1 + 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/cinder/tests/test_emc_vmax.py b/cinder/tests/test_emc_vmax.py index abd7aa7af..dce90919a 100644 --- a/cinder/tests/test_emc_vmax.py +++ b/cinder/tests/test_emc_vmax.py @@ -20,6 +20,7 @@ import time from xml.dom.minidom import Document import mock +import six from cinder import exception from cinder.openstack.common import log as logging @@ -214,19 +215,35 @@ class EMCVMAXCommonData(): 'size': 1, 'volume_name': 'vol1', 'id': '1', + 'device_id': '1', 'provider_auth': None, 'project_id': 'project', 'display_name': 'vol1', 'display_description': 'test volume', 'volume_type_id': 'abc', - 'provider_location': str(provider_location), + 'provider_location': six.text_type(provider_location), 'status': 'available', 'host': 'fake-host' } + test_volume_v2 = {'name': 'vol1', + 'size': 1, + 'volume_name': 'vol1', + 'id': 'vol1', + 'device_id': '1', + 'provider_auth': None, + 'project_id': 'project', + 'display_name': 'vol1', + 'display_description': 'test volume', + 'volume_type_id': 'abc', + 'provider_location': six.text_type(provider_location), + 'status': 'available', + 'host': 'fake-host' + } test_failed_volume = {'name': 'failed_vol', 'size': 1, 'volume_name': 'failed_vol', 'id': '4', + 'device_id': '4', 'provider_auth': None, 'project_id': 'project', 'display_name': 'failed_vol', @@ -237,22 +254,26 @@ class EMCVMAXCommonData(): 'size': '-1', 'volume_name': 'failed_delete_vol', 'id': '99999', + 'device_id': '99999', 'provider_auth': None, 'project_id': 'project', 'display_name': 'failed delete vol', 'display_description': 'failed delete volume', 'volume_type_id': 'abc', - 'provider_location': str(provider_location2)} + 'provider_location': six.text_type(provider_location2) + } test_source_volume = {'size': 1, 'volume_type_id': 'sourceid', 'display_name': 'sourceVolume', 'name': 'sourceVolume', 'volume_name': 'vmax-154326', + 'id': 'vmax-154326', 'provider_auth': None, 'project_id': 'project', 'id': '2', - 'provider_location': str(provider_location), + 'provider_location': + six.text_type(provider_location), 'display_description': 'snapshot source volume'} location_info = {'location_info': '000195900551#silver#None', @@ -548,10 +569,12 @@ class FakeEcomConnection(): vol = self.data.test_volume elif objectpath['type'] == 'failed_vol': vol = self.data.test_failed_volume + elif objectpath['type'] == 'TargetBaseVol': + vol = self.data.test_failed_volume else: return None - vol['DeviceID'] = vol['id'] + vol['DeviceID'] = vol['device_id'] assoc = self._getinstance_storagevolume(vol) assocs.append(assoc) return assocs @@ -1190,7 +1213,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): return_value=(None, EMCVMAXCommonData.storage_system)) def test_create_volume_no_fast_success( self, _mock_volume_type, mock_storage_system): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -1203,7 +1226,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): return_value=(None, EMCVMAXCommonData.storage_system)) def test_create_volume_no_fast_striped_success( self, _mock_volume_type, mock_storage_system): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -1639,7 +1662,7 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase): return_value=1) def test_create_volume_fast_success( self, _mock_volume_type, mock_storage_system, mock_pool_policy): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -1656,7 +1679,7 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase): return_value=1) def test_create_volume_fast_striped_success( self, _mock_volume_type, mock_storage_system, mock_pool_policy): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -2150,7 +2173,7 @@ class EMCVMAXFCDriverNoFastTestCase(test.TestCase): return_value=(None, EMCVMAXCommonData.storage_system)) def test_create_volume_no_fast_success( self, _mock_volume_type, mock_storage_system): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -2163,7 +2186,7 @@ class EMCVMAXFCDriverNoFastTestCase(test.TestCase): return_value=(None, EMCVMAXCommonData.storage_system)) def test_create_volume_no_fast_striped_success( self, _mock_volume_type, mock_storage_system): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -2494,7 +2517,7 @@ class EMCVMAXFCDriverFastTestCase(test.TestCase): return_value=1) def test_create_volume_fast_success( self, _mock_volume_type, mock_storage_system, mock_pool_policy): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, @@ -2511,7 +2534,7 @@ class EMCVMAXFCDriverFastTestCase(test.TestCase): return_value=1) def test_create_volume_fast_striped_success( self, _mock_volume_type, mock_storage_system, mock_pool_policy): - self.driver.create_volume(self.data.test_volume) + self.driver.create_volume(self.data.test_volume_v2) @mock.patch.object( volume_types, diff --git a/cinder/volume/drivers/emc/emc_vmax_common.py b/cinder/volume/drivers/emc/emc_vmax_common.py index 101894ee5..b7cfefd4c 100644 --- a/cinder/volume/drivers/emc/emc_vmax_common.py +++ b/cinder/volume/drivers/emc/emc_vmax_common.py @@ -113,7 +113,7 @@ class EMCVMAXCommon(object): :raises: VolumeBackendAPIException """ volumeSize = int(self.utils.convert_gb_to_bits(volume['size'])) - volumeName = volume['name'] + volumeName = volume['id'] extraSpecs = self._initial_setup(volume) self.conn = self._get_ecom_connection() diff --git a/cinder/volume/drivers/emc/emc_vmax_provision.py b/cinder/volume/drivers/emc/emc_vmax_provision.py index f305669f8..486abe98f 100644 --- a/cinder/volume/drivers/emc/emc_vmax_provision.py +++ b/cinder/volume/drivers/emc/emc_vmax_provision.py @@ -368,6 +368,7 @@ class EMCVMAXProvision(object): rc, job = conn.InvokeMethod( 'CreateOrModifyCompositeElement', elementCompositionService, + ElementName=volumeName, ElementType=self.utils.get_num(THINPROVISIONINGCOMPOSITE, '16'), Size=self.utils.get_num(volumeSize, '64'), ElementSource=self.utils.get_num(newMembers, '16'), -- 2.45.2