Commit 73d6473c by Máhonfai Bálint

Formatting fixes

parent 5997c4b1
import json
import os
import subprocess
import logging
import magic
import subprocess
from hashlib import md5
from shutil import move, copyfileobj
from zipfile import ZipFile, is_zipfile
from zlib import decompressobj, MAX_WBITS
from bz2 import BZ2Decompressor
from time import sleep
from hashlib import md5
import re
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
import magic
import os
import paramiko
import re
import requests
from bz2 import BZ2Decompressor
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from time import sleep
from zlib import decompressobj, MAX_WBITS
logger = logging.getLogger(__name__)
......@@ -294,9 +294,8 @@ class Disk(object):
if 'qcow' in ftype.lower():
move(downloaded_file, self.get_path())
else:
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'convert',
cmdline = ['ionice', '-c', 'idle',
'qemu-img', 'convert',
'-m', '4', '-O', 'qcow2',
downloaded_file,
self.get_path()]
......@@ -326,13 +325,12 @@ class Disk(object):
def export(self, task, disk_format, exported_name, upload_link, parent_id):
exported_path = self.get_path() + '.' + disk_format
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'convert']
if disk_format == 'qcow2':
cmdline += ['-c']
cmdline += ['-m', '4', '-O', disk_format,
self.get_path(),
exported_path]
'qemu-img', 'convert']
if disk_format == 'qcow2':
cmdline.append('-c')
cmdline.extend(['-m', '4', '-O', disk_format,
self.get_path(),
exported_path])
subprocess.check_output(cmdline)
size = os.path.getsize(exported_path)
......@@ -414,8 +412,7 @@ class Disk(object):
raise NotImplemented()
else:
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'create',
'qemu-img', 'create',
'-b', self.get_base(),
'-f', self.format,
self.get_path()]
......@@ -425,10 +422,12 @@ class Disk(object):
def merge_disk_with_base(self, task, new_disk, parent_id=None):
proc = None
try:
cmdline = ['ionice', '-c', 'idle', 'qemu-img', 'convert', '-m', '4']
if new_disk.format == 'qcow2':
cmdline += ['-c']
cmdline += ['-O', new_disk.format, self.get_path(), new_disk.get_path()]
cmdline = ['ionice', '-c', 'idle',
'qemu-img', 'convert', '-m', '4']
if new_disk.format == 'qcow2':
cmdline.append('-c')
cmdline.extend(['-O', new_disk.format,
self.get_path(), new_disk.get_path()])
# Call subprocess
logger.debug(
"Merging %s into %s. %s", self.get_path(),
......
from disk import Disk
from storagecelery import celery
import logging
from os import path, unlink, statvfs, listdir, mkdir
from shutil import move
from celery.contrib.abortable import AbortableTask
import logging
logger = logging.getLogger(__name__)
from disk import Disk
from storagecelery import celery
logger = logging.getLogger(__name__)
trash_directory = "trash"
......
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