From: Walter A. Boring IV Date: Tue, 1 Mar 2016 15:22:21 +0000 (-0800) Subject: 3PAR use same LUN id for each export path X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f813bde3c5b2ec357a51b8172db64e31a967cc35;p=openstack-build%2Fcinder-build.git 3PAR use same LUN id for each export path When multipath is enabled, and the 3PAR driver is configured to export a VLUN over N iSCSI IP(ports), we now use the same LUN ID for each iSCSI IP export. Previously, when we would export a volume over N iSCSI ports, we would get a new LUN ID for each iSCSI port. Change-Id: Ide0ce373a14f348a554688dee9b699feed3c5f26 Closes-Bug: #1551994 --- diff --git a/cinder/tests/unit/test_hpe3par.py b/cinder/tests/unit/test_hpe3par.py index 747b17952..e2b428c33 100644 --- a/cinder/tests/unit/test_hpe3par.py +++ b/cinder/tests/unit/test_hpe3par.py @@ -4474,7 +4474,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase): mock.call.createVLUN( self.VOLUME_3PAR_NAME, auto=True, - hostname=self.FAKE_HOST), + hostname=self.FAKE_HOST, + lun=None), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( @@ -4567,7 +4568,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase): self.VOLUME_3PAR_NAME, auto=True, hostname=self.FAKE_HOST, - portPos={'node': 7, 'slot': 1, 'cardPort': 1}), + portPos={'node': 7, 'slot': 1, 'cardPort': 1}, + lun=None), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( @@ -4640,7 +4642,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase): mock.call.createVLUN( self.VOLUME_3PAR_NAME, auto=True, - hostname=self.FAKE_HOST), + hostname=self.FAKE_HOST, + lun=None), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( @@ -5520,7 +5523,8 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase): self.VOLUME_3PAR_NAME, auto=True, hostname=self.FAKE_HOST, - portPos=self.FAKE_ISCSI_PORT['portPos']), + portPos=self.FAKE_ISCSI_PORT['portPos'], + lun=None), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 27dbd59e4..79e1e384a 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -228,10 +228,11 @@ class HPE3PARCommon(object): 3.0.13 - Support creating a cg from a source cg 3.0.14 - Comparison of WWNs now handles case difference. bug #1546453 3.0.15 - Update replication to version 2.1 + 3.0.16 - Use same LUN ID for each VLUN path #1551994 """ - VERSION = "3.0.15" + VERSION = "3.0.16" stats = {} @@ -1104,16 +1105,22 @@ class HPE3PARCommon(object): def _delete_3par_host(self, hostname): self.client.deleteHost(hostname) - def _create_3par_vlun(self, volume, hostname, nsp): + def _create_3par_vlun(self, volume, hostname, nsp, lun_id=None): try: location = None + auto = True + + if lun_id: + auto = False + if nsp is None: location = self.client.createVLUN(volume, hostname=hostname, - auto=True) + auto=auto, lun=lun_id) else: port = self.build_portPos(nsp) location = self.client.createVLUN(volume, hostname=hostname, - auto=True, portPos=port) + auto=auto, portPos=port, + lun=lun_id) vlun_info = None if location: @@ -1364,13 +1371,14 @@ class HPE3PARCommon(object): {'name': volume_name, 'host': hostname}) return found_vlun - def create_vlun(self, volume, host, nsp=None): + def create_vlun(self, volume, host, nsp=None, lun_id=None): """Create a VLUN. In order to export a volume on a 3PAR box, we have to create a VLUN. """ volume_name = self._get_3par_vol_name(volume['id']) - vlun_info = self._create_3par_vlun(volume_name, host['name'], nsp) + vlun_info = self._create_3par_vlun(volume_name, host['name'], nsp, + lun_id=lun_id) return self._get_vlun(volume_name, host['name'], vlun_info['lun_id'], diff --git a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py index 4873ca62d..d7979207f 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py @@ -109,10 +109,11 @@ class HPE3PARISCSIDriver(driver.TransferVD, 3.0.6 - Adding manage/unmanage snapshot support 3.0.7 - Optimize array ID retrieval 3.0.8 - Update replication to version 2.1 + 3.0.9 - Use same LUN ID for each VLUN path #1551994 """ - VERSION = "3.0.8" + VERSION = "3.0.9" def __init__(self, *args, **kwargs): super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs) @@ -355,6 +356,7 @@ class HPE3PARISCSIDriver(driver.TransferVD, # Cycle through each ready iSCSI port and determine if a new # VLUN should be created or an existing one used. + lun_id = None for port in ready_ports: iscsi_ip = port['IPAddr'] if iscsi_ip in target_portal_ips: @@ -370,7 +372,12 @@ class HPE3PARISCSIDriver(driver.TransferVD, break else: vlun = common.create_vlun( - volume, host, iscsi_ips[iscsi_ip]['nsp']) + volume, host, iscsi_ips[iscsi_ip]['nsp'], + lun_id=lun_id) + + # We want to use the same LUN ID for every port + if lun_id is None: + lun_id = vlun['lun'] iscsi_ip_port = "%s:%s" % ( iscsi_ip, iscsi_ips[iscsi_ip]['ip_port']) target_portals.append(iscsi_ip_port)