Fix Lun ID 0 in HPE 3PAR driver

If Lun ID is set to 0, auto is not disabled.
Instead, we checked if Lun_id is not None to disable auto.
Added unittest to verify auto

Closes-Bug: #1573298
Change-Id: I67c509c828cadbd0585b6badca733039d697eeea
This commit is contained in:
Jay Mehta 2016-04-21 16:09:44 -07:00
parent 8091e9f737
commit 4649d3d830
2 changed files with 60 additions and 2 deletions

View File

@ -2848,6 +2848,63 @@ class HPE3PARBaseDriver(object):
None)
self.assertEqual(expected_info, vlun_info)
def test_create_vlun_vlunid_zero(self):
# This will test "auto" for deactive when Lun ID is 0
host = 'fake-host'
lun_id = 0
nsp = '0:1:1'
port = {'node': 0, 'slot': 1, 'cardPort': 1}
mock_client = self.setup_driver()
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
# _create_3par_vlun with nsp
location = ("%(name)s,%(lunid)s,%(host)s,%(nsp)s" %
{'name': self.VOLUME_NAME,
'lunid': lun_id,
'host': host,
'nsp': nsp})
mock_client.createVLUN.return_value = location
expected_info = {'volume_name': self.VOLUME_NAME,
'lun_id': lun_id,
'host_name': host,
'nsp': nsp}
common = self.driver._login()
vlun_info = common._create_3par_vlun(
self.VOLUME_NAME,
host,
nsp,
lun_id=lun_id)
self.assertEqual(expected_info, vlun_info)
mock_client.createVLUN.assert_called_once_with(self.VOLUME_NAME,
hostname=host,
auto=False,
portPos=port,
lun=lun_id)
# _create_3par_vlun without nsp
mock_client.reset_mock()
location = ("%(name)s,%(lunid)s,%(host)s" %
{'name': self.VOLUME_NAME,
'lunid': lun_id,
'host': host})
mock_client.createVLUN.return_value = location
expected_info = {'volume_name': self.VOLUME_NAME,
'lun_id': lun_id,
'host_name': host}
vlun_info = common._create_3par_vlun(
self.VOLUME_NAME,
host,
None,
lun_id=lun_id)
self.assertEqual(expected_info, vlun_info)
mock_client.createVLUN.assert_called_once_with(self.VOLUME_NAME,
hostname=host,
auto=False,
lun=lun_id)
def test__get_existing_volume_ref_name(self):
mock_client = self.setup_driver()
with mock.patch.object(hpecommon.HPE3PARCommon,

View File

@ -235,10 +235,11 @@ class HPE3PARCommon(object):
3.0.17 - Don't fail on clearing 3PAR object volume key. bug #1546392
3.0.18 - create_cloned_volume account for larger size. bug #1554740
3.0.19 - Remove metadata that tracks the instance ID. bug #1572665
3.0.20 - Fix lun_id of 0 issue. bug #1573298
"""
VERSION = "3.0.19"
VERSION = "3.0.20"
stats = {}
@ -1116,7 +1117,7 @@ class HPE3PARCommon(object):
location = None
auto = True
if lun_id:
if lun_id is not None:
auto = False
if nsp is None: