Fix wrong command for _rescan_multipath

The _run_multipath command is wrong in [1], it should be 'multipath -r'
not 'multipath - r'. And adds test for this.

[1]: https://github.com/openstack/nova/blob/master/nova/virt/libvirt/volume.py#L590

Change-Id: I3c5d12cc11988d65a8fc9e6143d26c2d1220d253
Closes-bug: 1362916
(cherry picked from commit 51f3eb66ef)
This commit is contained in:
liyingjun 2014-08-08 15:54:17 +08:00 committed by Lee Yarwood
parent c8edfc095b
commit ac9f5c7d8b
2 changed files with 7 additions and 1 deletions

View File

@ -238,6 +238,12 @@ class LibvirtVolumeTestCase(test.NoDBTestCase):
}
}
def test_rescan_multipath(self):
libvirt_driver = volume.LibvirtISCSIVolumeDriver(self.fake_conn)
libvirt_driver._rescan_multipath()
expected_multipath_cmd = ('multipath', '-r')
self.assertIn(expected_multipath_cmd, self.executes)
def test_libvirt_iscsi_driver(self):
# NOTE(vish) exists is to make driver assume connecting worked
self.stubs.Set(os.path, 'exists', lambda x: True)

View File

@ -599,7 +599,7 @@ class LibvirtISCSIVolumeDriver(LibvirtBaseVolumeDriver):
check_exit_code=[0, 1, 21, 255])
def _rescan_multipath(self):
self._run_multipath('-r', check_exit_code=[0, 1, 21])
self._run_multipath(['-r'], check_exit_code=[0, 1, 21])
def _get_host_device(self, iscsi_properties):
return ("/dev/disk/by-path/ip-%s-iscsi-%s-lun-%s" %