Fujitsu Driver: Fix exception in terminate_connection with no connector
Force-detach should be ok when connector is None. When connector is None, we change the driver to detach the volume from anything its attached to. Change-Id: I244e392ff00ef333a4ea823fb7b27da457c4fcea Closes-Bug: #1708329
This commit is contained in:
parent
d0be7d8b26
commit
2d88867081
|
@ -761,8 +761,17 @@ class FJFCDriverTestCase(test.TestCase):
|
||||||
info = self.driver.initialize_connection(TEST_VOLUME,
|
info = self.driver.initialize_connection(TEST_VOLUME,
|
||||||
TEST_CONNECTOR)
|
TEST_CONNECTOR)
|
||||||
self.assertEqual(fake_info, info)
|
self.assertEqual(fake_info, info)
|
||||||
|
# Call terminate_connection with connector.
|
||||||
self.driver.terminate_connection(TEST_VOLUME,
|
self.driver.terminate_connection(TEST_VOLUME,
|
||||||
TEST_CONNECTOR)
|
TEST_CONNECTOR)
|
||||||
|
|
||||||
|
info = self.driver.initialize_connection(TEST_VOLUME,
|
||||||
|
TEST_CONNECTOR)
|
||||||
|
self.assertEqual(fake_info, info)
|
||||||
|
# Call terminate_connection without connector.
|
||||||
|
self.driver.terminate_connection(TEST_VOLUME,
|
||||||
|
None)
|
||||||
|
|
||||||
self.driver.delete_volume(TEST_VOLUME)
|
self.driver.delete_volume(TEST_VOLUME)
|
||||||
|
|
||||||
def test_create_and_delete_snapshot(self):
|
def test_create_and_delete_snapshot(self):
|
||||||
|
@ -879,8 +888,16 @@ class FJISCSIDriverTestCase(test.TestCase):
|
||||||
info = self.driver.initialize_connection(TEST_VOLUME,
|
info = self.driver.initialize_connection(TEST_VOLUME,
|
||||||
TEST_CONNECTOR)
|
TEST_CONNECTOR)
|
||||||
self.assertEqual(fake_info, info)
|
self.assertEqual(fake_info, info)
|
||||||
|
# Call terminate_connection with connector.
|
||||||
self.driver.terminate_connection(TEST_VOLUME,
|
self.driver.terminate_connection(TEST_VOLUME,
|
||||||
TEST_CONNECTOR)
|
TEST_CONNECTOR)
|
||||||
|
|
||||||
|
info = self.driver.initialize_connection(TEST_VOLUME,
|
||||||
|
TEST_CONNECTOR)
|
||||||
|
self.assertEqual(fake_info, info)
|
||||||
|
# Call terminate_connection without connector.
|
||||||
|
self.driver.terminate_connection(TEST_VOLUME,
|
||||||
|
None)
|
||||||
self.driver.delete_volume(TEST_VOLUME)
|
self.driver.delete_volume(TEST_VOLUME)
|
||||||
|
|
||||||
def test_create_and_delete_snapshot(self):
|
def test_create_and_delete_snapshot(self):
|
||||||
|
|
|
@ -728,7 +728,8 @@ class FJDXCommon(object):
|
||||||
{'vid': volume['id'], 'prtcl': self.protocol, 'frc': force})
|
{'vid': volume['id'], 'prtcl': self.protocol, 'frc': force})
|
||||||
|
|
||||||
self.conn = self._get_eternus_connection()
|
self.conn = self._get_eternus_connection()
|
||||||
map_exist = self._unmap_lun(volume, connector)
|
force = True if not connector else force
|
||||||
|
map_exist = self._unmap_lun(volume, connector, force)
|
||||||
|
|
||||||
LOG.debug('terminate_connection, map_exist: %s.', map_exist)
|
LOG.debug('terminate_connection, map_exist: %s.', map_exist)
|
||||||
return map_exist
|
return map_exist
|
||||||
|
|
|
@ -171,20 +171,23 @@ class FJDXFCDriver(driver.FibreChannelDriver):
|
||||||
@fczm_utils.remove_fc_zone
|
@fczm_utils.remove_fc_zone
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Disallow connection from connector."""
|
"""Disallow connection from connector."""
|
||||||
|
wwpns = connector.get('wwpns') if connector else None
|
||||||
|
|
||||||
LOG.debug('terminate_connection, volume id: %(vid)s, '
|
LOG.debug('terminate_connection, volume id: %(vid)s, '
|
||||||
'wwpns: %(wwpns)s, enter method.',
|
'wwpns: %(wwpns)s, enter method.',
|
||||||
{'vid': volume['id'], 'wwpns': connector['wwpns']})
|
{'vid': volume['id'], 'wwpns': wwpns})
|
||||||
|
|
||||||
map_exist = self.common.terminate_connection(volume, connector)
|
map_exist = self.common.terminate_connection(volume, connector)
|
||||||
attached = self.common.check_attached_volume_in_zone(connector)
|
|
||||||
|
|
||||||
info = {'driver_volume_type': 'fibre_channel',
|
info = {'driver_volume_type': 'fibre_channel',
|
||||||
'data': {}}
|
'data': {}}
|
||||||
|
|
||||||
if not attached:
|
if connector:
|
||||||
# No more volumes attached to the host
|
attached = self.common.check_attached_volume_in_zone(connector)
|
||||||
init_tgt_map = self.common.build_fc_init_tgt_map(connector)
|
if not attached:
|
||||||
info['data'] = {'initiator_target_map': init_tgt_map}
|
# No more volumes attached to the host
|
||||||
|
init_tgt_map = self.common.build_fc_init_tgt_map(connector)
|
||||||
|
info['data'] = {'initiator_target_map': init_tgt_map}
|
||||||
|
|
||||||
LOG.debug('terminate_connection, unmap: %(unmap)s, '
|
LOG.debug('terminate_connection, unmap: %(unmap)s, '
|
||||||
'connection info: %(info)s, exit method',
|
'connection info: %(info)s, exit method',
|
||||||
|
|
|
@ -173,9 +173,11 @@ class FJDXISCSIDriver(driver.ISCSIDriver):
|
||||||
|
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Disallow connection from connector."""
|
"""Disallow connection from connector."""
|
||||||
|
initiator = connector.get('initiator') if connector else None
|
||||||
|
|
||||||
LOG.info('terminate_connection, volume id: %(vid)s, '
|
LOG.info('terminate_connection, volume id: %(vid)s, '
|
||||||
'initiator: %(initiator)s, Enter method.',
|
'initiator: %(initiator)s, Enter method.',
|
||||||
{'vid': volume['id'], 'initiator': connector['initiator']})
|
{'vid': volume['id'], 'initiator': initiator})
|
||||||
|
|
||||||
map_exist = self.common.terminate_connection(volume, connector)
|
map_exist = self.common.terminate_connection(volume, connector)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue