DS8K: correct behavior and return value for terminate_connection method

In terminate_connection method, if the host can't be found in the
storage and the lun type is non-replication, driver will log an error
instead of raising an exception and the return value should be
lowercase.

Change-Id: Idf4e9b966a1b0f9154ca600e088ceb6929a1fb0e
Closes-Bug: 1776227
This commit is contained in:
Peng Wang 2018-06-26 23:32:08 -07:00
parent fc19a0dca8
commit 97f71915d1
3 changed files with 10 additions and 13 deletions
cinder
tests/unit/volume/drivers/ibm
volume/drivers/ibm/ibm_storage

@ -2707,11 +2707,8 @@ class DS8KProxyTest(test.TestCase):
map_data = self.driver.initialize_connection(volume, TEST_CONNECTOR)
self.assertEqual(int(TEST_LUN_ID), map_data['data']['target_lun'])
self.assertTrue(
list(map_data['data']['initiator_target_map'].keys())[0] in
[TEST_SOURCE_WWPN_1, TEST_SOURCE_WWPN_2])
self.assertTrue(
list(map_data['data']['initiator_target_map'].keys())[1] in
self.assertEqual(sorted(list(
map_data['data']['initiator_target_map'].keys()), key=str.lower),
[TEST_SOURCE_WWPN_1, TEST_SOURCE_WWPN_2])
def test_initialize_connection_of_eckd_volume(self):
@ -2876,9 +2873,7 @@ class DS8KProxyTest(test.TestCase):
}
]
mock_get_host_ports.side_effect = [host_ports]
self.assertRaises(exception.VolumeDriverException,
self.driver.terminate_connection, volume,
TEST_CONNECTOR)
self.driver.terminate_connection(volume, TEST_CONNECTOR)
@mock.patch.object(helper.DS8KCommonHelper, '_get_host_ports')
@mock.patch.object(helper.DS8KCommonHelper, '_get_mappings')
@ -2918,7 +2913,10 @@ class DS8KProxyTest(test.TestCase):
]
mock_get_host_ports.side_effect = [host_ports]
mock_get_mappings.side_effect = [mappings]
self.driver.terminate_connection(volume, TEST_CONNECTOR)
ret_info = self.driver.terminate_connection(volume, TEST_CONNECTOR)
self.assertEqual(sorted(list(
ret_info['data']['initiator_target_map'].keys()), key=str.lower),
[TEST_SOURCE_WWPN_1, TEST_SOURCE_WWPN_2])
@mock.patch.object(helper.DS8KCommonHelper, '_get_host_ports')
@mock.patch.object(helper.DS8KCommonHelper, '_get_mappings')

@ -696,7 +696,7 @@ class DS8KCommonHelper(object):
self._delete_host_ports(port)
self._delete_host(host_id)
target_ports = [p['wwpn'] for p in self._get_ioports()]
target_map = {initiator.upper(): target_ports
target_map = {initiator: target_ports
for initiator in connector['wwpns']}
ret_info['data']['initiator_target_map'] = target_map
return ret_info

@ -1080,9 +1080,8 @@ class DS8KProxy(proxy.IBMStorageProxy):
backend_helper.check_vol_mapped_to_host(connector, lun.ds_id))
if host_id is None or not vol_mapped:
if host_id is None and not lun.type_replication:
msg = (_('Failed to find the Host information.'))
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
LOG.warning('Failed to find the Host information.')
return ret_info
if host_id and not lun.type_replication and not vol_mapped:
LOG.warning("Volume %(vol)s is already not mapped to "
"host %(host)s.",