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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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
json
import
os
import
subprocess
import
logging
import
logging
import
magic
import
subprocess
from
hashlib
import
md5
from
shutil
import
move
,
copyfileobj
from
shutil
import
move
,
copyfileobj
from
zipfile
import
ZipFile
,
is_zipfile
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
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__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -294,9 +294,8 @@ class Disk(object):
...
@@ -294,9 +294,8 @@ class Disk(object):
if
'qcow'
in
ftype
.
lower
():
if
'qcow'
in
ftype
.
lower
():
move
(
downloaded_file
,
self
.
get_path
())
move
(
downloaded_file
,
self
.
get_path
())
else
:
else
:
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'qemu-img'
,
'convert'
,
'convert'
,
'-m'
,
'4'
,
'-O'
,
'qcow2'
,
'-m'
,
'4'
,
'-O'
,
'qcow2'
,
downloaded_file
,
downloaded_file
,
self
.
get_path
()]
self
.
get_path
()]
...
@@ -326,13 +325,12 @@ class Disk(object):
...
@@ -326,13 +325,12 @@ class Disk(object):
def
export
(
self
,
task
,
disk_format
,
exported_name
,
upload_link
,
parent_id
):
def
export
(
self
,
task
,
disk_format
,
exported_name
,
upload_link
,
parent_id
):
exported_path
=
self
.
get_path
()
+
'.'
+
disk_format
exported_path
=
self
.
get_path
()
+
'.'
+
disk_format
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'qemu-img'
,
'convert'
]
'convert'
]
if
disk_format
==
'qcow2'
:
if
disk_format
==
'qcow2'
:
cmdline
.
append
(
'-c'
)
cmdline
+=
[
'-c'
]
cmdline
.
extend
([
'-m'
,
'4'
,
'-O'
,
disk_format
,
cmdline
+=
[
'-m'
,
'4'
,
'-O'
,
disk_format
,
self
.
get_path
(),
self
.
get_path
(),
exported_path
])
exported_path
]
subprocess
.
check_output
(
cmdline
)
subprocess
.
check_output
(
cmdline
)
size
=
os
.
path
.
getsize
(
exported_path
)
size
=
os
.
path
.
getsize
(
exported_path
)
...
@@ -414,8 +412,7 @@ class Disk(object):
...
@@ -414,8 +412,7 @@ class Disk(object):
raise
NotImplemented
()
raise
NotImplemented
()
else
:
else
:
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'qemu-img'
,
'create'
,
'create'
,
'-b'
,
self
.
get_base
(),
'-b'
,
self
.
get_base
(),
'-f'
,
self
.
format
,
'-f'
,
self
.
format
,
self
.
get_path
()]
self
.
get_path
()]
...
@@ -425,10 +422,12 @@ class Disk(object):
...
@@ -425,10 +422,12 @@ class Disk(object):
def
merge_disk_with_base
(
self
,
task
,
new_disk
,
parent_id
=
None
):
def
merge_disk_with_base
(
self
,
task
,
new_disk
,
parent_id
=
None
):
proc
=
None
proc
=
None
try
:
try
:
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'convert'
,
'-m'
,
'4'
]
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
if
new_disk
.
format
==
'qcow2'
:
'qemu-img'
,
'convert'
,
'-m'
,
'4'
]
cmdline
+=
[
'-c'
]
if
new_disk
.
format
==
'qcow2'
:
cmdline
+=
[
'-O'
,
new_disk
.
format
,
self
.
get_path
(),
new_disk
.
get_path
()]
cmdline
.
append
(
'-c'
)
cmdline
.
extend
([
'-O'
,
new_disk
.
format
,
self
.
get_path
(),
new_disk
.
get_path
()])
# Call subprocess
# Call subprocess
logger
.
debug
(
logger
.
debug
(
"Merging
%
s into
%
s.
%
s"
,
self
.
get_path
(),
"Merging
%
s into
%
s.
%
s"
,
self
.
get_path
(),
...
...
storagedriver.py
View file @
73d6473c
from
disk
import
Disk
import
logging
from
storagecelery
import
celery
from
os
import
path
,
unlink
,
statvfs
,
listdir
,
mkdir
from
os
import
path
,
unlink
,
statvfs
,
listdir
,
mkdir
from
shutil
import
move
from
shutil
import
move
from
celery.contrib.abortable
import
AbortableTask
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"
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