From 07d8c04a0e4e1d482e8ec8aed3e05821509447de Mon Sep 17 00:00:00 2001 From: Jeegn Chen Date: Tue, 14 Apr 2015 14:19:12 +0800 Subject: [PATCH] Remove redundant code from VNX Cinder Driver The logic on read-only volume in cinder/volume/drivers/emc/emc_vnx_cli.py is duplicate to the logic in cinder/volume/manager.py. This patch is to remove it. Change-Id: Ib1a740a6065dbc8f3412d9dcf2e0d9025ab32d87 Closes-Bug: #1439531 --- cinder/tests/unit/test_emc_vnxdirect.py | 47 ++++++------------------ cinder/volume/drivers/emc/emc_vnx_cli.py | 16 +------- 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/cinder/tests/unit/test_emc_vnxdirect.py b/cinder/tests/unit/test_emc_vnxdirect.py index ab4a71879..34fcd80e6 100644 --- a/cinder/tests/unit/test_emc_vnxdirect.py +++ b/cinder/tests/unit/test_emc_vnxdirect.py @@ -47,8 +47,7 @@ class EMCVNXCLIDriverTestData(object): 'display_name': 'vol1', 'display_description': 'test volume', 'volume_type_id': None, - 'consistencygroup_id': None, - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}] + 'consistencygroup_id': None } test_legacy_volume = { @@ -63,8 +62,7 @@ class EMCVNXCLIDriverTestData(object): 'display_name': 'vol1', 'display_description': 'test volume', 'volume_type_id': None, - 'consistencygroup_id': None, - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}] + 'consistencygroup_id': None } test_volume_clone_cg = { @@ -78,8 +76,7 @@ class EMCVNXCLIDriverTestData(object): 'display_name': 'vol1', 'display_description': 'test volume', 'volume_type_id': None, - 'consistencygroup_id': None, - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}] + 'consistencygroup_id': None } test_volume_cg = { @@ -93,8 +90,7 @@ class EMCVNXCLIDriverTestData(object): 'display_name': 'vol1', 'display_description': 'test volume', 'volume_type_id': None, - 'consistencygroup_id': 'cg_id', - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}] + 'consistencygroup_id': 'cg_id' } test_volume_rw = { @@ -109,8 +105,6 @@ class EMCVNXCLIDriverTestData(object): 'display_description': 'test volume', 'volume_type_id': None, 'consistencygroup_id': None, - 'volume_admin_metadata': [{'key': 'attached_mode', 'value': 'rw'}, - {'key': 'readonly', 'value': 'False'}], 'provider_location': 'system^FNM11111|type^lun|id^1|version^05.03.00', } @@ -259,7 +253,6 @@ class EMCVNXCLIDriverTestData(object): 'id': '1181d1b2-cea3-4f55-8fa8-3360d026ce24', 'name': 'vol3', 'size': 2, - 'volume_admin_metadata': [], 'status': 'available', 'volume_type_id': '19fdd0dd-03b3-4d7c-b541-f4df46f308c8', @@ -294,7 +287,6 @@ class EMCVNXCLIDriverTestData(object): 'id': '1181d1b2-cea3-4f55-8fa8-3360d026ce24', 'name': 'vol4', 'size': 2L, - 'volume_admin_metadata': [], 'status': 'available', 'volume_type_id': '19fdd0dd-03b3-4d7c-b541-f4df46f308c8', @@ -313,7 +305,6 @@ class EMCVNXCLIDriverTestData(object): 'name_id': '1181d1b2-cea3-4f55-8fa8-3360d026ce25', 'name': 'vol5', 'size': 1, - 'volume_admin_metadata': [], 'status': 'available', 'volume_type_id': '19fdd0dd-03b3-4d7c-b541-f4df46f308c8', @@ -697,19 +688,8 @@ State: Ready "Port WWN: iqn.1992-04.com.emc:cx.fnm00124000215.a5\n" + "iSCSI Alias: 0215.a5\n", 0) - iscsi_connection_info_ro = \ - {'data': {'access_mode': 'ro', - 'target_discovered': True, - 'target_iqn': - 'iqn.1992-04.com.emc:cx.fnm00124000215.a4', - 'target_lun': 2, - 'target_portal': '10.244.214.118:3260', - 'volume_id': '1'}, - 'driver_volume_type': 'iscsi'} - - iscsi_connection_info_rw = \ - {'data': {'access_mode': 'rw', - 'target_discovered': True, + iscsi_connection_info = \ + {'data': {'target_discovered': True, 'target_iqn': 'iqn.1992-04.com.emc:cx.fnm00124000215.a4', 'target_lun': 2, @@ -718,8 +698,7 @@ State: Ready 'driver_volume_type': 'iscsi'} iscsi_connection_info_mp = \ - {'data': {'access_mode': 'rw', - 'target_discovered': True, + {'data': {'target_discovered': True, 'target_iqns': [ 'iqn.1992-04.com.emc:cx.fnm00124000215.a4', 'iqn.1992-04.com.emc:cx.fnm00124000215.a5'], @@ -1595,7 +1574,7 @@ Time Remaining: 0 second(s) self.testData.test_volume, self.testData.connector) - self.assertEqual(self.testData.iscsi_connection_info_ro, + self.assertEqual(self.testData.iscsi_connection_info, connection_info) expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', @@ -1634,7 +1613,7 @@ Time Remaining: 0 second(s) test_volume_rw, self.testData.connector) - self.assertEqual(self.testData.iscsi_connection_info_rw, + self.assertEqual(self.testData.iscsi_connection_info, connection_info) expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', @@ -1668,7 +1647,7 @@ Time Remaining: 0 second(s) test_volume_rw, self.testData.connector) - self.assertEqual(self.testData.iscsi_connection_info_rw, + self.assertEqual(self.testData.iscsi_connection_info, connection_info) expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', @@ -2908,8 +2887,7 @@ Time Remaining: 0 second(s) 'project_id': 'project', 'display_name': 'vol_01', 'display_description': 'test volume', - 'volume_type_id': None, - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}]} + 'volume_type_id': None} self.assertEqual(4, self.driver.cli.get_lun_id(volume_01)) @mock.patch( @@ -2928,8 +2906,7 @@ Time Remaining: 0 second(s) 'project_id': 'project', 'display_name': 'vol_02', 'display_description': 'test volume', - 'volume_type_id': None, - 'volume_admin_metadata': [{'key': 'readonly', 'value': 'True'}]} + 'volume_type_id': None} self.assertEqual(2, self.driver.cli.get_lun_id(volume_02)) def test_create_consistency_group(self): diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index aa915d809..0e0a12dba 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -1656,7 +1656,7 @@ class CommandLineHelper(object): class EMCVnxCliBase(object): """This class defines the functions to use the native CLI functionality.""" - VERSION = '05.03.06' + VERSION = '05.03.07' stats = {'driver_version': VERSION, 'storage_protocol': None, 'vendor_name': 'EMC', @@ -2801,18 +2801,6 @@ class EMCVnxCliBase(object): return fc_properties def initialize_connection(self, volume, connector): - volume_metadata = {} - for metadata in volume['volume_admin_metadata']: - volume_metadata[metadata['key']] = metadata['value'] - access_mode = volume_metadata.get('attached_mode') - if access_mode is None: - access_mode = ('ro' - if volume_metadata.get('readonly') == 'True' - else 'rw') - LOG.debug('Volume %(vol)s Access mode is: %(access)s.', - {'vol': volume['name'], - 'access': access_mode}) - """Initializes the connection and returns connection info.""" @lockutils.synchronized('emc-connection-' + connector['host'], "emc-connection-", True) @@ -2828,7 +2816,6 @@ class EMCVnxCliBase(object): device_number, sg_data['raw_output'] ) - iscsi_properties['access_mode'] = access_mode data = {'driver_volume_type': 'iscsi', 'data': iscsi_properties} elif self.protocol == 'FC': @@ -2836,7 +2823,6 @@ class EMCVnxCliBase(object): fc_properties = self.vnx_get_fc_properties(connector, device_number) fc_properties['volume_id'] = volume['id'] - fc_properties['access_mode'] = access_mode data = {'driver_volume_type': 'fibre_channel', 'data': fc_properties} -- 2.45.2