From feac52b6efecd17dbcc161f6da749b4819a8f477 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Wed, 2 Mar 2016 03:05:29 -0800 Subject: [PATCH] 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. Master Change id: Ide0ce373a14f348a554688dee9b699feed3c5f26 Change-Id: If40b842e59e384db6eee11e9fa843e4ead6411d4 Closes-Bug: #1551994 --- cinder/tests/unit/test_hp3par.py | 12 +++++++---- .../volume/drivers/san/hp/hp_3par_common.py | 20 +++++++++++++------ cinder/volume/drivers/san/hp/hp_3par_iscsi.py | 12 +++++++++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/cinder/tests/unit/test_hp3par.py b/cinder/tests/unit/test_hp3par.py index c80d8b80729..fb9413bfc85 100644 --- a/cinder/tests/unit/test_hp3par.py +++ b/cinder/tests/unit/test_hp3par.py @@ -3599,7 +3599,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, 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( @@ -3692,7 +3693,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, 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( @@ -3765,7 +3767,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, 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( @@ -4593,7 +4596,8 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, 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/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index c6c09da87d1..3081c3399b6 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -203,10 +203,11 @@ class HP3PARCommon(object): 2.0.51 - Adds consistency group support 2.0.52 - Added update_migrated_volume. bug #1492023 2.0.53 - Fix volume size conversion. bug #1513158 + 2.0.54 - Use same LUN ID for each VLUN path #1551994 """ - VERSION = "2.0.53" + VERSION = "2.0.54" stats = {} @@ -802,16 +803,22 @@ class HP3PARCommon(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: @@ -1026,13 +1033,14 @@ class HP3PARCommon(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/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index cc5a4a4feb1..2d99063ca67 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -100,10 +100,11 @@ class HP3PARISCSIDriver(driver.TransferVD, 2.0.21 - Adds consistency group support 2.0.22 - Update driver to use ABC metaclasses 2.0.23 - Added update_migrated_volume. bug # 1492023 + 2.0.24 - Use same LUN ID for each VLUN path #1551994 """ - VERSION = "2.0.23" + VERSION = "2.0.24" def __init__(self, *args, **kwargs): super(HP3PARISCSIDriver, self).__init__(*args, **kwargs) @@ -318,6 +319,7 @@ class HP3PARISCSIDriver(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: @@ -333,7 +335,13 @@ class HP3PARISCSIDriver(driver.TransferVD, break else: vlun = common.create_vlun( - volume, host, self.iscsi_ips[iscsi_ip]['nsp']) + volume, host, self.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, self.iscsi_ips[iscsi_ip]['ip_port']) target_portals.append(iscsi_ip_port)