Fix setting the multipath_id

This fixes the logic in how we set the multipath_id in the device_info.
If the returned multipath_id is None, we didn't find a multipath device
and we don't set the multipath_id.  This is exactly what we do for FC.

Change-Id: Ic1f598da59ccda634b765d65706e02d1a4caff30
Closes-Bug: #1547539
This commit is contained in:
Walter A. Boring IV 2016-02-19 00:12:25 -08:00
parent 0d25bbb5b5
commit c84dfef1f2
2 changed files with 34 additions and 3 deletions

View File

@ -1437,11 +1437,9 @@ class FibreChannelConnector(InitiatorConnector):
FibreChannelConnector, self)._discover_mpath_device(
device_wwn, connection_properties, self.device_name))
if multipath_id:
# only set the multipath_id if we found one
device_info['multipath_id'] = multipath_id
if device_path and device_info['multipath_id'] is None:
device_info['multipath_id'] = device_wwn
else:
device_path = self.host_device

View File

@ -1338,6 +1338,7 @@ class FibreChannelConnectorTestCase(ConnectorTestCase):
self.connector.connect_volume(connection_info['data'])
self.assertEqual(should_wait_for_rw, wait_for_rw_mock.called)
return connection_info
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device')
@mock.patch.object(linuxscsi.LinuxSCSI, 'wait_for_rw')
@ -1433,6 +1434,38 @@ class FibreChannelConnectorTestCase(ConnectorTestCase):
'ro',
False)
@mock.patch.object(connector.InitiatorConnector, '_discover_mpath_device')
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device')
@mock.patch.object(linuxscsi.LinuxSCSI, 'wait_for_rw')
@mock.patch.object(os.path, 'exists', return_value=True)
@mock.patch.object(os.path, 'realpath', return_value='/dev/sdb')
@mock.patch.object(linuxfc.LinuxFibreChannel, 'get_fc_hbas')
@mock.patch.object(linuxfc.LinuxFibreChannel, 'get_fc_hbas_info')
@mock.patch.object(linuxscsi.LinuxSCSI, 'remove_scsi_device')
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_scsi_wwn')
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_device_info')
def test_connect_volume_multipath_not_found(self,
get_device_info_mock,
get_scsi_wwn_mock,
remove_device_mock,
get_fc_hbas_info_mock,
get_fc_hbas_mock,
realpath_mock,
exists_mock,
wait_for_rw_mock,
find_mp_dev_mock,
discover_mp_dev_mock):
discover_mp_dev_mock.return_value = ("/dev/disk/by-path/something",
None)
connection_info = self._test_connect_volume_multipath(
get_device_info_mock, get_scsi_wwn_mock, remove_device_mock,
get_fc_hbas_info_mock, get_fc_hbas_mock, realpath_mock,
exists_mock, wait_for_rw_mock, find_mp_dev_mock,
'rw', False)
self.assertNotIn('multipathd_id', connection_info['data'])
@mock.patch.object(connector.FibreChannelConnector, 'get_volume_paths')
def test_extend_volume_no_path(self, mock_volume_paths):
mock_volume_paths.return_value = []