diff --git a/nova/tests/unit/virt/test_images.py b/nova/tests/unit/virt/test_images.py index 9dacc828ad..296aa24b09 100644 --- a/nova/tests/unit/virt/test_images.py +++ b/nova/tests/unit/virt/test_images.py @@ -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', diff --git a/nova/virt/images.py b/nova/virt/images.py index 85ce6ce2fb..54db59df5c 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -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(