Merge "Make guestfs' Tpool usage optional"
This commit is contained in:
@@ -334,7 +334,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
|
||||
@mock.patch('os.access')
|
||||
@mock.patch('os.uname', return_value=os_uname(
|
||||
'Linux', '', 'kernel_name', '', ''))
|
||||
def test_appliance_setup_inspect_capabilties_fail_with_ubuntu(
|
||||
def test_appliance_setup_inspect_capabilities_fail_with_ubuntu(
|
||||
self, mock_uname, mock_access,
|
||||
):
|
||||
# In ubuntu os will default host kernel as 600 permission
|
||||
@@ -343,7 +343,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
|
||||
vfs = vfsimpl.VFSGuestFS(self.qcowfile)
|
||||
mock_access.return_value = False
|
||||
self.flags(debug=False, group='guestfs')
|
||||
with mock.patch('eventlet.tpool.Proxy', return_value=m) as tpool_mock:
|
||||
with mock.patch('nova.utils.tpool_wrap', return_value=m) as target:
|
||||
self.assertRaises(exception.LibguestfsCannotReadKernel,
|
||||
vfs.inspect_capabilities)
|
||||
m.add_drive.assert_called_once_with('/dev/null')
|
||||
@@ -351,7 +351,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
|
||||
mock_access.assert_called_once_with('/boot/vmlinuz-kernel_name',
|
||||
mock.ANY)
|
||||
mock_uname.assert_called_once_with()
|
||||
self.assertEqual(1, tpool_mock.call_count)
|
||||
self.assertEqual(1, target.call_count)
|
||||
|
||||
def test_appliance_setup_inspect_capabilties_debug_mode(self):
|
||||
"""Asserts that we do not use an eventlet thread pool when guestfs
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
import os
|
||||
|
||||
from eventlet import tpool
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import utils
|
||||
from nova.virt.disk.vfs import api as vfs
|
||||
from nova.virt.image import model as imgmodel
|
||||
|
||||
@@ -82,7 +82,7 @@ class VFSGuestFS(vfs.VFS):
|
||||
LOG.debug('Inspecting guestfs capabilities non-threaded.')
|
||||
g = guestfs.GuestFS()
|
||||
else:
|
||||
g = tpool.Proxy(guestfs.GuestFS())
|
||||
g = utils.tpool_wrap(guestfs.GuestFS())
|
||||
g.add_drive("/dev/null") # sic
|
||||
g.launch()
|
||||
except Exception as e:
|
||||
@@ -181,7 +181,7 @@ class VFSGuestFS(vfs.VFS):
|
||||
LOG.debug("Setting up appliance for %(image)s",
|
||||
{'image': self.image})
|
||||
try:
|
||||
self.handle = tpool.Proxy(
|
||||
self.handle = utils.tpool_wrap(
|
||||
guestfs.GuestFS(python_return_dict=False,
|
||||
close_on_exit=False))
|
||||
except TypeError as e:
|
||||
@@ -189,7 +189,7 @@ class VFSGuestFS(vfs.VFS):
|
||||
# NOTE(russellb) In case we're not using a version of
|
||||
# libguestfs new enough to support parameters close_on_exit
|
||||
# and python_return_dict which were added in libguestfs 1.20.
|
||||
self.handle = tpool.Proxy(guestfs.GuestFS())
|
||||
self.handle = utils.tpool_wrap(guestfs.GuestFS())
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user