Hyper-V: fix tgt iSCSI targets disconnect issue
When detaching volumes, the Hyper-V driver decides whether the iSCSI target should be disconnected or not by comparing the number of volumes being disconnected and the total number of available LUNs of the according iSCSI target. This causes problems as tgt exports one extra reserved LUN. For this reason, the according iSCSI target won't be disconnected when a volume exported by TGT is detached. The fix consists in checking the disk types when counting the available LUNs of a target. Change-Id: I0c2a723b94dae5b1c3838b9644537324606128e5 Closes-Bug: #1395063
This commit is contained in:
parent
036046558f
commit
16484eca96
|
@ -125,11 +125,15 @@ class BaseVolumeUtilsTestCase(test.NoDBTestCase):
|
|||
'_get_devices_for_target')
|
||||
def test_get_target_lun_count(self, fake_get_devices):
|
||||
init_session = self._create_initiator_session()
|
||||
fake_get_devices.return_value = [init_session]
|
||||
# Only disk devices are being counted.
|
||||
disk_device = mock.Mock(DeviceType=self._volutils._FILE_DEVICE_DISK)
|
||||
init_session.Devices.append(disk_device)
|
||||
fake_get_devices.return_value = init_session.Devices
|
||||
|
||||
lun_count = self._volutils.get_target_lun_count(
|
||||
mock.sentinel.FAKE_IQN)
|
||||
|
||||
self.assertEqual(len(init_session.Devices), lun_count)
|
||||
self.assertEqual(1, lun_count)
|
||||
|
||||
@mock.patch.object(basevolumeutils.BaseVolumeUtils,
|
||||
"_get_drive_number_from_disk_path")
|
||||
|
|
|
@ -36,6 +36,7 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class BaseVolumeUtils(object):
|
||||
_FILE_DEVICE_DISK = 7
|
||||
|
||||
def __init__(self, host='.'):
|
||||
if sys.platform == 'win32':
|
||||
|
@ -137,7 +138,9 @@ class BaseVolumeUtils(object):
|
|||
|
||||
def get_target_lun_count(self, target_iqn):
|
||||
devices = self._get_devices_for_target(target_iqn)
|
||||
return len(devices)
|
||||
disk_devices = [device for device in devices
|
||||
if device.DeviceType == self._FILE_DEVICE_DISK]
|
||||
return len(disk_devices)
|
||||
|
||||
def get_target_from_disk_path(self, disk_path):
|
||||
initiator_sessions = self._conn_wmi.MSiSCSIInitiator_SessionClass()
|
||||
|
|
Loading…
Reference in New Issue