Raise error if qemu image already exist when creating disk

This commit is contained in:
Julien Duponchelle committed 2015-07-28 16:15:01 +02:00
1 parent 54448ab936
commit e92d9ca5ff
2 files changed
+18 -1

No files matched your search

+3 -1
View File
@@ -205,6 +205,8 @@ class Qemu(BaseManager):
directory = self.get_images_directory()
os.makedirs(directory, exist_ok=True)
path = os.path.join(directory, os.path.basename(path))
if os.path.exists(path):
raise QemuError("Could not create disk image {} already exist".format(path))
command = [qemu_img, "create", "-f", img_format]
for option in sorted(options.keys()):
@@ -215,4 +217,4 @@ class Qemu(BaseManager):
process = yield from asyncio.create_subprocess_exec(*command)
yield from process.wait()
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could create disk image {}:{}".format(path, e))
raise QemuError("Could not create disk image {}:{}".format(path, e))