Windows iSCSI: ensure disks are claimed by MPIO
This change ensures that the retrieved disks are claimed by the MPIO service, when multipath is requested. At the same time, we're attempting to retrieve the disks only after connecting all the requested targets. Change-Id: I5e9e01d42aee1cedd59e620be35fe98b2085e5e9 Related-Bug: #1694671
This commit is contained in:
parent
b8db5c0af7
commit
314b76edcd
|
@ -80,7 +80,9 @@ class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
|
|||
|
||||
@utils.trace
|
||||
def connect_volume(self, connection_properties):
|
||||
connected_target_mappings = set()
|
||||
volume_connected = False
|
||||
|
||||
for (initiator_name,
|
||||
target_portal,
|
||||
target_iqn,
|
||||
|
@ -103,24 +105,30 @@ class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
|
|||
mpio_enabled=self.use_multipath,
|
||||
initiator_name=initiator_name,
|
||||
ensure_lun_available=False)
|
||||
self._iscsi_utils.ensure_lun_available(
|
||||
target_iqn=target_iqn,
|
||||
target_lun=target_lun,
|
||||
rescan_attempts=self.device_scan_attempts,
|
||||
retry_interval=self.device_scan_interval)
|
||||
|
||||
if not volume_connected:
|
||||
(device_number,
|
||||
device_path) = (
|
||||
self._iscsi_utils.get_device_number_and_path(
|
||||
target_iqn, target_lun))
|
||||
volume_connected = True
|
||||
connected_target_mappings.add((target_iqn, target_lun))
|
||||
|
||||
if not self.use_multipath:
|
||||
break
|
||||
except os_win_exc.OSWinException:
|
||||
LOG.exception("Could not establish the iSCSI session.")
|
||||
|
||||
for target_iqn, target_lun in connected_target_mappings:
|
||||
try:
|
||||
(device_number,
|
||||
device_path) = self._iscsi_utils.get_device_number_and_path(
|
||||
target_iqn, target_lun,
|
||||
retry_attempts=self.device_scan_attempts,
|
||||
retry_interval=self.device_scan_interval,
|
||||
rescan_disks=True,
|
||||
ensure_mpio_claimed=self.use_multipath)
|
||||
volume_connected = True
|
||||
except os_win_exc.OSWinException:
|
||||
LOG.exception("Could not retrieve device path for target "
|
||||
"%(target_iqn)s and lun %(target_lun)s.",
|
||||
dict(target_iqn=target_iqn,
|
||||
target_lun=target_lun))
|
||||
|
||||
if not volume_connected:
|
||||
raise exception.BrickException(
|
||||
_("Could not connect volume %s.") % connection_properties)
|
||||
|
@ -158,7 +166,8 @@ class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
|
|||
|
||||
(device_number,
|
||||
device_path) = self._iscsi_utils.get_device_number_and_path(
|
||||
target_iqn, target_lun)
|
||||
target_iqn, target_lun,
|
||||
ensure_mpio_claimed=self.use_multipath)
|
||||
if device_path:
|
||||
device_paths.add(device_path)
|
||||
|
||||
|
|
|
@ -131,16 +131,12 @@ class WindowsISCSIConnectorTestCase(test_base.WindowsConnectorTestBase):
|
|||
initiator_name=mock.sentinel.initiator_name,
|
||||
ensure_lun_available=False)] *
|
||||
expected_login_attempts)
|
||||
self._iscsi_utils.ensure_lun_available.assert_has_calls(
|
||||
[mock.call(target_iqn=mock.sentinel.target_iqn,
|
||||
target_lun=mock.sentinel.target_lun,
|
||||
rescan_attempts=(
|
||||
self._connector.device_scan_attempts),
|
||||
retry_interval=mock.sentinel.rescan_interval)] *
|
||||
(expected_login_attempts - 1))
|
||||
|
||||
self._iscsi_utils.get_device_number_and_path.assert_called_once_with(
|
||||
mock.sentinel.target_iqn, mock.sentinel.target_lun)
|
||||
mock.sentinel.target_iqn, mock.sentinel.target_lun,
|
||||
retry_attempts=self._connector.device_scan_attempts,
|
||||
retry_interval=self._connector.device_scan_interval,
|
||||
rescan_disks=True,
|
||||
ensure_mpio_claimed=use_multipath)
|
||||
mock_get_scsi_wwn.assert_called_once_with(mock.sentinel.device_number)
|
||||
|
||||
@mock.patch.object(iscsi.WindowsISCSIConnector, '_get_all_paths')
|
||||
|
|
Loading…
Reference in New Issue