From e66b0856a5eeabc78c356067f60c927ac1d47d8a Mon Sep 17 00:00:00 2001 From: Tom Swanson Date: Tue, 25 Aug 2015 15:13:31 -0500 Subject: [PATCH] Dell SC: init_volume stale volume info fix In init_volume the volume information becomes stale after the volume is mapped to a server. The volume should be updated before being sent to unmap. The unmap function was testing for the volume being active. This should not be required. It is unlikely an inactive volume will have mappings but not impossible. This check has been removed. Removed LOG.error from _find_mapping_profiles as the API returning an error is fine if the volume is inactive. Plus we were not failing on it. The LOG.debug is sufficient. Change-Id: I3ff8447360cea134e1008fa8db5cd912aa5effd3 --- cinder/tests/unit/test_dellscapi.py | 4 ++++ .../drivers/dell/dell_storagecenter_api.py | 21 ++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cinder/tests/unit/test_dellscapi.py b/cinder/tests/unit/test_dellscapi.py index 1fdbffaff..2847bbe0f 100644 --- a/cinder/tests/unit/test_dellscapi.py +++ b/cinder/tests/unit/test_dellscapi.py @@ -1906,6 +1906,9 @@ class DellSCSanAPITestCase(test.TestCase): self.assertTrue(mock_create_folder_path.called) self.assertEqual(self.FLDR, res, 'Unexpected Folder') + @mock.patch.object(dell_storagecenter_api.StorageCenterApi, + 'find_volume', + return_value=VOLUME) @mock.patch.object(dell_storagecenter_api.StorageCenterApi, 'unmap_volume', return_value=True) @@ -1923,6 +1926,7 @@ class DellSCSanAPITestCase(test.TestCase): mock_get_json, mock_map_volume, mock_unmap_volume, + mock_find_volume, mock_close_connection, mock_open_connection, mock_init): diff --git a/cinder/volume/drivers/dell/dell_storagecenter_api.py b/cinder/volume/drivers/dell/dell_storagecenter_api.py index 40bd6293f..dbd47d38a 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_api.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_api.py @@ -555,6 +555,8 @@ class StorageCenterApi(object): # Map to actually create the volume self.map_volume(scvolume, scserver) + # We have changed the volume so grab a new copy of it. + scvolume = self.find_volume(scvolume.get('name')) self.unmap_volume(scvolume, scserver) return @@ -1079,19 +1081,14 @@ class StorageCenterApi(object): :returns: A list of Dell mapping profile objects. """ mapping_profiles = [] - if scvolume.get('active', False): - r = self.client.get('StorageCenter/ScVolume/%s/MappingProfileList' - % self._get_id(scvolume)) - if r.status_code == 200: - mapping_profiles = self._get_json(r) - else: - LOG.debug('MappingProfileList error: %(code)d %(reason)s', - {'code': r.status_code, - 'reason': r.reason}) - LOG.error(_LE('Unable to find volume mapping profiles: %s'), - scvolume.get('name')) + r = self.client.get('StorageCenter/ScVolume/%s/MappingProfileList' + % self._get_id(scvolume)) + if r.status_code == 200: + mapping_profiles = self._get_json(r) else: - LOG.error(_LE('_find_mappings: volume is not active')) + LOG.debug('MappingProfileList error: %(code)d %(reason)s', + {'code': r.status_code, + 'reason': r.reason}) LOG.debug(mapping_profiles) return mapping_profiles -- 2.45.2