Unity: fail to detach lun when auto zone enabled

When the lun is the last one attached to the host and it is detached,
the attribute `host.host_luns` is None. Use `not` in if statement which
is pythonic in checking None and empty list of `host.host_luns`.

Change-Id: I5d8f63f9a78d001bc699af538f586aab8d73a5cf
Closes-bug: #1759175
(cherry picked from commit c816be897e)
(cherry picked from commit febe57cfee)
This commit is contained in:
Ryan Liang 2018-03-28 07:30:39 +00:00 committed by Ryan Liang
parent 6510cb6c53
commit ead818199e
5 changed files with 29 additions and 2 deletions

View File

@ -785,6 +785,19 @@ class FCAdapterTest(unittest.TestCase):
target_wwn = ['100000051e55a100', '100000051e55a121']
self.assertListEqual(target_wwn, data['target_wwn'])
def test_terminate_connection_auto_zone_enabled_none_host_luns(self):
connector = {'host': 'host-no-host_luns', 'wwpns': 'abcdefg'}
volume = MockOSResource(provider_location='id^lun_41', id='id_41')
ret = self.adapter.terminate_connection(volume, connector)
self.assertEqual('fibre_channel', ret['driver_volume_type'])
data = ret['data']
target_map = {
'200000051e55a100': ('100000051e55a100', '100000051e55a121'),
'200000051e55a121': ('100000051e55a100', '100000051e55a121')}
self.assertDictEqual(target_map, data['initiator_target_map'])
target_wwn = ['100000051e55a100', '100000051e55a121']
self.assertListEqual(target_wwn, data['target_wwn'])
def test_validate_ports_whitelist_none(self):
ports = self.adapter.validate_ports(None)
self.assertEqual(set(('spa_iom_0_fc0', 'spa_iom_0_fc1')), set(ports))

View File

@ -161,6 +161,8 @@ class MockResource(object):
@property
def host_luns(self):
if self.name == 'host-no-host_luns':
return None
return []
@property

View File

@ -748,7 +748,7 @@ class FCAdapter(CommonAdapter):
'data': {}
}
host = self.client.create_host(connector['host'])
if len(host.host_luns) == 0:
if not host.host_luns:
targets = self.client.get_fc_target_info(
logged_in_only=True, allowed_ports=self.allowed_ports)
ret['data'] = self._get_fc_zone_info(connector['wwpns'],

View File

@ -49,11 +49,16 @@ class UnityDriver(driver.ManageableVD,
"""Unity Driver.
Version history:
.. code-block:: none
1.0.0 - Initial version
2.0.0 - Add thin clone support
2.0.1 - Fixes bug 1759175 to detach the lun correctly when auto zone
was enabled and the lun was the last one attached to the host.
"""
VERSION = '02.00.00'
VERSION = '02.00.01'
VENDOR = 'Dell EMC'
# ThirdPartySystems wiki page
CI_WIKI_NAME = "EMC_UNITY_CI"

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Dell EMC Unity Driver: Fixes `bug 1759175
<https://bugs.launchpad.net/cinder/+bug/1759175>`__
to detach the lun correctly when auto zone was enabled and the lun was the
last one attached to the host.