Commit 55ad9722 by Guba Sándor

updated merge to handle base image saving

parent 7292c3e8
...@@ -3,7 +3,7 @@ import os ...@@ -3,7 +3,7 @@ import os
import subprocess import subprocess
import re import re
import logging import logging
from shutil import move, copyfileobj from shutil import move, copy, copyfileobj
from zipfile import ZipFile, is_zipfile from zipfile import ZipFile, is_zipfile
from zlib import decompressobj, MAX_WBITS from zlib import decompressobj, MAX_WBITS
from bz2 import BZ2Decompressor from bz2 import BZ2Decompressor
...@@ -226,10 +226,7 @@ class Disk(object): ...@@ -226,10 +226,7 @@ class Disk(object):
# Check if file already exists # Check if file already exists
if os.path.isfile(new_disk.get_path()): if os.path.isfile(new_disk.get_path()):
raise Exception('File already exists: %s' % self.get_path()) raise Exception('File already exists: %s' % self.get_path())
# Check if base file exist if self.base_name:
if not os.path.isfile(self.get_base()):
raise Exception('Original image does not exists: %s'
% self.get_base())
cmdline = ['qemu-img', cmdline = ['qemu-img',
'convert', 'convert',
self.get_path(), self.get_path(),
...@@ -237,6 +234,8 @@ class Disk(object): ...@@ -237,6 +234,8 @@ class Disk(object):
new_disk.get_path()] new_disk.get_path()]
# Call subprocess # Call subprocess
subprocess.check_output(cmdline) subprocess.check_output(cmdline)
else:
copy(self.get_path(), new_disk.get_path())
def delete(self): def delete(self):
''' Delete file ''' Delete file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment