Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
storagedriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
73d6473c
authored
Feb 19, 2021
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting fixes
parent
5997c4b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
disk.py
+25
-26
storagedriver.py
+5
-4
No files found.
disk.py
View file @
73d6473c
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
(),
...
...
storagedriver.py
View file @
73d6473c
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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment