Add storage pool support

LXD has grown support for multiple storage pools
defined by name and type (btrfs, zfs, lvm, etc)
and we would like to support this in nova-lxd

Change-Id: I702d1600fdf70bfd1e2402e3455dd868e25214c0
This commit is contained in:
Chris MacNaughton
2017-04-26 17:12:54 +02:00
parent ff1c8cd12c
commit d883fa99eb
4 changed files with 58 additions and 3 deletions

View File

@@ -128,6 +128,7 @@ class LXDDriverTest(test.NoDBTestCase):
self.patchers.append(CONF2_patcher)
self.CONF2 = CONF2_patcher.start()
self.CONF2.lxd.root_dir = '/lxd'
self.CONF2.lxd.pool = None
self.CONF2.instances_path = '/i'
# LXDDriver._after_reboot reads from the database and syncs container

View File

@@ -41,6 +41,11 @@ class ToProfileTest(test.NoDBTestCase):
self.CONF = CONF_patcher.start()
self.CONF.instances_path = '/i'
CONF_patcher = mock.patch('nova.virt.lxd.flavor.CONF')
self.patchers.append(CONF_patcher)
self.CONF2 = CONF_patcher.start()
self.CONF2.lxd.pool = None
def tearDown(self):
super(ToProfileTest, self).tearDown()
for patcher in self.patchers:
@@ -104,6 +109,35 @@ class ToProfileTest(test.NoDBTestCase):
self.client.profiles.create.assert_called_once_with(
instance.name, expected_config, expected_devices)
def test_storage_pools(self):
self.client.host_info['api_extensions'].append('storage')
self.CONF2.lxd.pool = 'test_pool'
ctx = context.get_admin_context()
instance = fake_instance.fake_instance_obj(
ctx, name='test', memory_mb=0)
network_info = []
block_info = []
expected_config = {
'environment.product_name': 'OpenStack Nova',
'limits.cpu': '1',
'limits.memory': '0MB',
'raw.lxc': (
'lxc.console.logfile=/var/log/lxd/{}/console.log\n'.format(
instance.name))
}
expected_devices = {
'root': {
'path': '/',
'type': 'disk',
'pool': 'test_pool',
'size': '0GB'
},
}
flavor.to_profile(self.client, instance, network_info, block_info)
self.client.profiles.create.assert_called_once_with(
instance.name, expected_config, expected_devices)
def test_to_profile_security(self):
self.client.host_info['api_extensions'].append('id_map')