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
1d313f3d
authored
Oct 23, 2026
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fured fix
parent
cccc1d5d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
+16
-12
celeryconfig.py
+2
-1
disk.py
+6
-4
storagedriver.py
+8
-7
No files found.
celeryconfig.py
View file @
1d313f3d
...
...
@@ -6,6 +6,7 @@ CELERY_TASK_RESULT_EXPIRES = 300
#CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
CELERY_ACCEPT_CONTENT
=
[
'json'
,
'pickle_v2'
,
'pickle'
]
CELERY_TASK_SERIALIZER
=
'json'
CELERY_RESULT_SERIALIZER
=
'pickle_v2'
CELERY_RESULT_SERIALIZER
=
'pickle'
#CELERY_RESULT_SERIALIZER = 'pickle_v2'
CELERY_STORE_ERRORS_EVEN_IF_IGNORED
=
True
disk.py
View file @
1d313f3d
...
...
@@ -19,7 +19,7 @@ re_qemu_img = re.compile(r'(file format: (?P<format>(qcow2|raw))|'
r'virtual size: \w+ \((?P<size>[0-9]+) bytes\)|'
r'backing file: \S+ \(actual path: (?P<base>\S+)\))$'
)
maximum_size
=
float
(
os
.
getenv
(
"DOWNLOAD_MAX_SIZE"
,
1024
*
1024
*
1024
*
10
))
maximum_size
=
float
(
os
.
getenv
(
"DOWNLOAD_MAX_SIZE"
,
1024
*
1024
*
1024
*
10
0
))
class
AbortException
(
Exception
):
...
...
@@ -27,7 +27,8 @@ class AbortException(Exception):
class
FileTooBig
(
Exception
):
pass
def
__init__
(
self
):
super
(
Exception
,
self
)
.
__init__
(
'max size is:
%
s GB'
%
(
maximum_size
/
(
1024
*
1024
*
1024
)))
class
Disk
(
object
):
...
...
@@ -36,7 +37,7 @@ class Disk(object):
TYPES, CREATE_TYPES, SNAPSHOT_TYPES are hand managed restrictions.
"""
TYPES
=
[
'snapshot'
,
'normal'
]
FORMATS
=
[
'qcow2'
,
'raw'
,
'iso'
]
FORMATS
=
[
'qcow2'
,
'raw'
,
'iso'
,
'qcow'
]
CREATE_FORMATS
=
[
'qcow2'
,
'raw'
]
def
__init__
(
self
,
dir
,
name
,
format
,
type
,
size
,
...
...
@@ -268,6 +269,7 @@ class Disk(object):
def
import_disk
(
self
,
task
,
url
,
port
=
22
):
downloaded_file
=
os
.
path
.
join
(
self
.
dir
,
re
.
split
(
'[:/]'
,
url
)[
-
1
])
cmdline
=
[
'scp'
,
'-B'
,
'-P'
,
str
(
port
),
url
,
downloaded_file
]
logger
.
info
(
"Import of disk from
%
s "
%
url
)
proc
=
subprocess
.
Popen
(
cmdline
)
try
:
...
...
@@ -287,7 +289,7 @@ class Disk(object):
else
:
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'convert'
,
'-m'
,
'
4
'
,
'-O'
,
'qcow2'
,
'-m'
,
'
2
'
,
'-O'
,
'qcow2'
,
downloaded_file
,
self
.
get_path
()]
subprocess
.
check_output
(
cmdline
)
...
...
storagedriver.py
View file @
1d313f3d
...
...
@@ -15,12 +15,13 @@ trash_directory = "trash"
def
list
(
dir
):
return
[
d
.
get_desc
()
for
d
in
Disk
.
list
(
dir
)]
@celery.task
()
def
list_files
(
datastore
):
def
_list_files
(
datastore
):
return
[
l
for
l
in
listdir
(
datastore
)
if
path
.
isfile
(
path
.
join
(
datastore
,
l
))]
@celery.task
()
def
list_files
(
datastore
):
return
_list_files
(
datastore
)
@celery.task
()
def
create
(
disk_desc
):
...
...
@@ -119,15 +120,15 @@ def get_storage_stat(path):
@celery.task
()
def
get_file_statistics
(
datastore
):
disks
=
[
Disk
.
get
(
datastore
,
name
)
.
get_desc
()
for
name
in
listdir
(
datastore
)
if
not
name
.
endswith
((
".dump"
,
"trash"
,
"found"
,
"mnt"
,
"download"
,
"pub"
,
))]
for
name
in
_list_files
(
datastore
)
if
not
name
.
endswith
((
".dump"
,
))]
dumps
=
[{
'name'
:
name
,
'size'
:
path
.
getsize
(
path
.
join
(
datastore
,
name
))}
for
name
in
listdir
(
datastore
)
if
name
.
endswith
(
".dump"
)]
for
name
in
_list_files
(
datastore
)
if
name
.
endswith
(
".dump"
)]
trash
=
[{
'name'
:
name
,
'size'
:
path
.
getsize
(
path
.
join
(
datastore
,
trash_directory
,
name
))}
for
name
in
listdir
(
path
.
join
(
datastore
,
trash_directory
))]
for
name
in
_list_files
(
path
.
join
(
datastore
,
trash_directory
))]
return
{
'dumps'
:
dumps
,
'trash'
:
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