images: Remove Libvirt specific configurable use from qemu_img_info

This change addresses an old TODO in the images module by dropping the
use of a Libvirt specific configurable from the qemu_img_info function.
We can identify RBD based volumes by checking for 'rbd:' at the start of
the path provided to the function instead of using the configurable.

Change-Id: Ife9e67d5c71f4cca825dff713f54ec955508f6e6
This commit is contained in:
Lee Yarwood 2020-02-12 19:45:12 +00:00 committed by Stephen Finucane
parent b1b0f1be18
commit dce9bc03c4
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(