driver: add missing use_cache parameter for get_info()

With 19cb8280232 The driver interface has been updated. Now that the
method get_info() has an extra parameter 'use_cache'. That one is
currently not going to be used in lxd driver since we don't cache such
info.

Also, to ensure that the unit tests pass on a machine with lxd installed
as a snap, there are some additional mocks needed.

Closes-Bug: #1824300
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
(cherry picked from commit d0faf787d9)

Change-Id: I13a451ba95e0fd2485f94327d55ea1c0a7ed1f1d
This commit is contained in:
Sahid Orentino Ferdjaoui 2019-04-12 12:16:13 +00:00 committed by Alex Kavanagh
parent be6befedeb
commit 36b72b016b
3 changed files with 9 additions and 2 deletions

View File

@ -643,13 +643,15 @@ class LXDDriverTest(test.NoDBTestCase):
self.client.containers.get.assert_called_once_with(instance.name)
@mock.patch('nova.virt.lxd.common.is_snap_lxd')
@mock.patch('nova.virt.lxd.driver.network')
@mock.patch('pwd.getpwuid', mock.Mock(return_value=mock.Mock(pw_uid=1234)))
@mock.patch('os.getuid', mock.Mock())
@mock.patch('os.path.exists', mock.Mock(return_value=True))
@mock.patch('six.moves.builtins.open')
@mock.patch.object(driver.utils, 'execute')
def test_get_console_output(self, execute, _open, _):
def test_get_console_output(self, execute, _open, _, is_snap_lxd):
is_snap_lxd.return_value = False
ctx = context.get_admin_context()
instance = fake_instance.fake_instance_obj(
ctx, name='test', memory_mb=0)

View File

@ -48,6 +48,11 @@ class ToProfileTest(test.NoDBTestCase):
self.CONF2.lxd.pool = None
self.CONF2.lxd.root_dir = ''
is_snap_lxd_patch = mock.patch('nova.virt.lxd.common.is_snap_lxd')
self.patchers.append(is_snap_lxd_patch)
self.is_snap_lxd = is_snap_lxd_patch.start()
self.is_snap_lxd.return_value = False
def tearDown(self):
super(ToProfileTest, self).tearDown()
for patcher in self.patchers:

View File

@ -480,7 +480,7 @@ class LXDDriver(driver.ComputeDriver):
information.
"""
def get_info(self, instance):
def get_info(self, instance, use_cache=True):
"""Return an InstanceInfo object for the instance."""
try:
container = self.client.containers.get(instance.name)