Merge "images: Remove Libvirt specific configurable use from qemu_img_info"

This commit is contained in:
Zuul 2020-04-01 18:53:43 +00:00 committed by Gerrit Code Review
commit b9843e80da
2 changed files with 11 additions and 6 deletions

View File

@ -49,6 +49,15 @@ class QemuTestCase(test.NoDBTestCase):
self.assertTrue(image_info)
self.assertTrue(str(image_info))
@mock.patch('oslo_concurrency.processutils.execute',
return_value=('stdout', None))
def test_qemu_info_with_rbd_path(self, utils_execute):
# Assert that the use of a RBD URI as the path doesn't raise
# exception.DiskNotFound
image_info = images.qemu_img_info('rbd:volume/pool')
self.assertTrue(image_info)
self.assertTrue(str(image_info))
@mock.patch.object(compute_utils, 'disk_ops_semaphore')
@mock.patch('nova.privsep.utils.supports_direct_io', return_value=True)
@mock.patch.object(processutils, 'execute',

View File

@ -45,9 +45,7 @@ IMAGE_API = glance.API()
def qemu_img_info(path, format=None, output_format=None):
"""Return an object containing the parsed output from qemu-img info."""
# TODO(mikal): this code should not be referring to a libvirt specific
# flag.
if not os.path.exists(path) and CONF.libvirt.images_type != 'rbd':
if not os.path.exists(path) and not path.startswith('rbd:'):
raise exception.DiskNotFound(location=path)
info = nova.privsep.qemu.unprivileged_qemu_img_info(
@ -61,9 +59,7 @@ def qemu_img_info(path, format=None, output_format=None):
def privileged_qemu_img_info(path, format=None, output_format=None):
"""Return an object containing the parsed output from qemu-img info."""
# TODO(mikal): this code should not be referring to a libvirt specific
# flag.
if not os.path.exists(path) and CONF.libvirt.images_type != 'rbd':
if not os.path.exists(path) and not path.startswith('rbd:'):
raise exception.DiskNotFound(location=path)
info = nova.privsep.qemu.privileged_qemu_img_info(