From fc786dd469a15bda1b9d3c7bacf9f1771b9b9956 Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Sat, 11 May 2013 09:48:18 -0400 Subject: Detach volume fails when using multipath iscsi Enabled multipath for libvirt iscsi volume driver. Attach volume worked, however, detach volume failed. It failed because it can't find multipath device "/dev/mapper/xxxxxxxx" from connection_info and block device mapping table. The fix is to retrieve multipath device info dynamically at detach time. Fixes: bug #1178893 Change-Id: I53a3888daef93b57bf7f57438f74cee05e794b52 --- nova/tests/test_libvirt_volume.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_libvirt_volume.py b/nova/tests/test_libvirt_volume.py index 1186ed268..6d2dc9dce 100644 --- a/nova/tests/test_libvirt_volume.py +++ b/nova/tests/test_libvirt_volume.py @@ -389,6 +389,36 @@ class LibvirtVolumeTestCase(test.TestCase): self.assertEqual(tree.find('./source').get('dev'), mpdev_filepath) libvirt_driver.disconnect_volume(connection_info, 'vde') + def test_libvirt_kvm_volume_with_multipath_getmpdev(self): + self.flags(libvirt_iscsi_use_multipath=True) + self.stubs.Set(os.path, 'exists', lambda x: True) + libvirt_driver = volume.LibvirtISCSIVolumeDriver(self.fake_conn) + name0 = 'volume-00000000' + location0 = '10.0.2.15:3260' + iqn0 = 'iqn.2010-10.org.openstack:%s' % name0 + vol0 = {'id': 0, 'name': name0} + dev0 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location0, iqn0) + name = 'volume-00000001' + location = '10.0.2.15:3260' + iqn = 'iqn.2010-10.org.openstack:%s' % name + vol = {'id': 1, 'name': name} + dev = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-1' % (location, iqn) + devs = [dev0, dev] + self.stubs.Set(self.fake_conn, 'get_all_block_devices', lambda: devs) + connection_info = self.iscsi_connection(vol, location, iqn) + mpdev_filepath = '/dev/mapper/foo' + disk_info = { + "bus": "virtio", + "dev": "vde", + "type": "disk", + } + target_portals = ['fake_portal1', 'fake_portal2'] + libvirt_driver._get_multipath_device_name = lambda x: mpdev_filepath + conf = libvirt_driver.connect_volume(connection_info, disk_info) + tree = conf.format_dom() + self.assertEqual(tree.find('./source').get('dev'), mpdev_filepath) + libvirt_driver.disconnect_volume(connection_info, 'vde') + def test_libvirt_nfs_driver(self): # NOTE(vish) exists is to make driver assume connecting worked mnt_base = '/mnt' -- cgit