From 96f4c24792a3096f7669c49304f4c8f2ac8688b4 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Tue, 31 Jan 2012 20:53:24 -0500 Subject: [PATCH] Add support for LXC volumes. This introduces volume support for LXC containers in Nova. The way that this works is that when a device is attached to an LXC container is that, the xml is parsed to find out which device to connect to the LXC container, binds the device to the LXC container, and allow the device through cgroups. This bug fixes LP: #924601. Change-Id: I00b41426ae8354b3cd4212655ecb48319a63aa9b Signed-off-by: Chuck Short --- nova/tests/test_libvirt.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 4ce88299..c83e5f8e 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -195,6 +195,27 @@ class LibvirtVolumeTestCase(test.TestCase): libvirt_driver.disconnect_volume(connection_info, mount_device) connection_info = vol_driver.terminate_connection(vol, self.connr) + def test_libvirt_lxc_volume(self): + self.stubs.Set(os.path, 'exists', lambda x: True) + vol_driver = volume_driver.ISCSIDriver() + libvirt_driver = volume.LibvirtISCSIVolumeDriver(self.fake_conn) + location = '10.0.2.15:3260' + name = 'volume-00000001' + iqn = 'iqn.2010-10.org.openstack:%s' % name + vol = {'id': 1, + 'name': name, + 'provider_auth': None, + 'provider_location': '%s,fake %s' % (location, iqn)} + connection_info = vol_driver.initialize_connection(vol, self.connr) + mount_device = "vde" + xml = libvirt_driver.connect_volume(connection_info, mount_device) + tree = xml_to_tree(xml) + dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn) + self.assertEqual(tree.get('type'), 'block') + self.assertEqual(tree.find('./source').get('dev'), dev_str) + libvirt_driver.disconnect_volume(connection_info, mount_device) + connection_info = vol_driver.terminate_connection(vol, self.connr) + class CacheConcurrencyTestCase(test.TestCase): def setUp(self):