Raise on non-existing file in qemu_img_info
I'm not sure why we silence the exception, right now it causes us a very hard to debug failure. No code in Ironic seems to rely on this behavior. Change-Id: I3740b600c60ed1b39808d18af2b5074e7e07a149
This commit is contained in:
parent
5e1ca2a437
commit
87a739fe17
@ -488,7 +488,7 @@ def dd(src, dst, conv_flags=None):
|
||||
def qemu_img_info(path):
|
||||
"""Return an object containing the parsed output from qemu-img info."""
|
||||
if not os.path.exists(path):
|
||||
return imageutils.QemuImgInfo()
|
||||
raise FileNotFoundError(_("File %s does not exist") % path)
|
||||
|
||||
out, err = utils.execute('env', 'LC_ALL=C', 'LANG=C',
|
||||
'qemu-img', 'info', path,
|
||||
|
@ -603,13 +603,10 @@ class OtherFunctionTestCase(base.IronicLibTestCase):
|
||||
disk_utils.is_block_device, device)
|
||||
mock_os.assert_has_calls([mock.call(device)] * 2)
|
||||
|
||||
@mock.patch.object(imageutils, 'QemuImgInfo', autospec=True)
|
||||
@mock.patch.object(os.path, 'exists', return_value=False, autospec=True)
|
||||
def test_qemu_img_info_path_doesnt_exist(self, path_exists_mock,
|
||||
qemu_img_info_mock):
|
||||
disk_utils.qemu_img_info('noimg')
|
||||
def test_qemu_img_info_path_doesnt_exist(self, path_exists_mock):
|
||||
self.assertRaises(FileNotFoundError, disk_utils.qemu_img_info, 'noimg')
|
||||
path_exists_mock.assert_called_once_with('noimg')
|
||||
qemu_img_info_mock.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(utils, 'execute', return_value=('out', 'err'),
|
||||
autospec=True)
|
||||
|
Loading…
Reference in New Issue
Block a user