Merge "iSCSI single path: Don't fail if there's no WWN"
This commit is contained in:
commit
e0a3b09a4c
@ -571,10 +571,12 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector):
|
||||
for __ in range(10):
|
||||
wwn = self._linuxscsi.get_sysfs_wwn(found_devs)
|
||||
if wwn:
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
LOG.debug('Could not find the WWN for %s.', found_devs[0])
|
||||
return self._get_connect_result(connection_properties,
|
||||
wwn, found_devs)
|
||||
time.sleep(1)
|
||||
LOG.debug('Could not find the WWN for %s.', found_devs[0])
|
||||
|
||||
# If we failed we must cleanup the connection, as we could be
|
||||
# leaving the node entry if it's not being used by another device.
|
||||
|
@ -1111,6 +1111,27 @@ Setting up iSCSI targets: unused
|
||||
(('ip1:port1', 'tgt1', 4),),
|
||||
force=True, ignore_errors=True)
|
||||
|
||||
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_sysfs_wwn', return_value='')
|
||||
@mock.patch.object(iscsi.ISCSIConnector, '_connect_vol')
|
||||
@mock.patch.object(iscsi.ISCSIConnector, '_cleanup_connection')
|
||||
@mock.patch('time.sleep')
|
||||
def test_connect_single_volume_no_wwn(self, sleep_mock, cleanup_mock,
|
||||
connect_mock, get_wwn_mock):
|
||||
def my_connect(rescans, props, data):
|
||||
data['found_devices'].append('sdz')
|
||||
|
||||
connect_mock.side_effect = my_connect
|
||||
|
||||
res = self.connector._connect_single_volume(self.CON_PROPS)
|
||||
|
||||
expected = {'type': 'block', 'scsi_wwn': '', 'path': '/dev/sdz'}
|
||||
self.assertEqual(expected, res)
|
||||
get_wwn_mock.assert_has_calls([mock.call(['sdz'])] * 10)
|
||||
self.assertEqual(10, get_wwn_mock.call_count)
|
||||
sleep_mock.assert_has_calls([mock.call(1)] * 10)
|
||||
self.assertEqual(10, sleep_mock.call_count)
|
||||
cleanup_mock.assert_not_called()
|
||||
|
||||
@staticmethod
|
||||
def _get_connect_vol_data():
|
||||
return {'stop_connecting': False, 'num_logins': 0, 'failed_logins': 0,
|
||||
|
Loading…
Reference in New Issue
Block a user