Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
storagedriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3746c537
authored
Apr 22, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make shorter some functions
parent
8cf3e80b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
40 deletions
+14
-40
storagedriver.py
+14
-40
No files found.
storagedriver.py
View file @
3746c537
...
@@ -15,11 +15,8 @@ trash_directory = "trash"
...
@@ -15,11 +15,8 @@ trash_directory = "trash"
@celery.task
()
@celery.task
()
def
list
(
data_store_type
,
dir
):
def
list
(
data_store_type
,
dir
):
cls
=
CephDisk
if
data_store_type
==
"ceph_block"
else
Disk
if
data_store_type
==
"ceph_block"
:
return
[
d
.
get_desc
()
for
d
in
cls
.
list
(
dir
)]
return
[
d
.
get_desc
()
for
d
in
CephDisk
.
list
(
dir
)]
return
[
d
.
get_desc
()
for
d
in
Disk
.
list
(
dir
)]
@celery.task
()
@celery.task
()
...
@@ -36,12 +33,8 @@ def list_files(data_store_type, dir):
...
@@ -36,12 +33,8 @@ def list_files(data_store_type, dir):
@celery.task
()
@celery.task
()
def
create
(
disk_desc
):
def
create
(
disk_desc
):
disk
=
None
cls
=
CephDisk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
else
Disk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
:
disk
=
cls
.
deserialize
(
disk_desc
)
disk
=
CephDisk
.
deserialize
(
disk_desc
)
else
:
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
create
()
disk
.
create
()
...
@@ -52,12 +45,8 @@ class download(AbortableTask):
...
@@ -52,12 +45,8 @@ class download(AbortableTask):
disk_desc
=
kwargs
[
'disk'
]
disk_desc
=
kwargs
[
'disk'
]
url
=
kwargs
[
'url'
]
url
=
kwargs
[
'url'
]
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
disk
=
None
c
=
CephDisk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
else
Disk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
:
disk
=
c
.
deserialize
(
disk_desc
)
disk
=
CephDisk
.
deserialize
(
disk_desc
)
else
:
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
download
(
self
,
url
,
parent_id
)
disk
.
download
(
self
,
url
,
parent_id
)
return
{
'size'
:
disk
.
size
,
return
{
'size'
:
disk
.
size
,
'type'
:
disk
.
format
,
'type'
:
disk
.
format
,
...
@@ -66,12 +55,8 @@ class download(AbortableTask):
...
@@ -66,12 +55,8 @@ class download(AbortableTask):
@celery.task
()
@celery.task
()
def
delete
(
disk_desc
):
def
delete
(
disk_desc
):
disk
=
None
cls
=
CephDisk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
else
Disk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
:
disk
=
cls
.
deserialize
(
disk_desc
)
disk
=
CephDisk
.
deserialize
(
disk_desc
)
else
:
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
delete
()
disk
.
delete
()
...
@@ -90,12 +75,8 @@ def delete_dump(data_store_type, dir, filename):
...
@@ -90,12 +75,8 @@ def delete_dump(data_store_type, dir, filename):
@celery.task
()
@celery.task
()
def
snapshot
(
disk_desc
):
def
snapshot
(
disk_desc
):
disk
=
None
cls
=
CephDisk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
else
Disk
if
disk_desc
[
"data_store_type"
]
==
"ceph_block"
:
disk
=
cls
.
deserialize
(
disk_desc
)
disk
=
CephDisk
.
deserialize
(
disk_desc
)
else
:
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
snapshot
()
disk
.
snapshot
()
...
@@ -106,16 +87,9 @@ class merge(AbortableTask):
...
@@ -106,16 +87,9 @@ class merge(AbortableTask):
old_json
=
kwargs
[
'old_json'
]
old_json
=
kwargs
[
'old_json'
]
new_json
=
kwargs
[
'new_json'
]
new_json
=
kwargs
[
'new_json'
]
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
cls
=
CephDisk
if
old_json
[
"data_store_type"
]
==
"ceph_block"
else
Disk
disk
=
None
disk
=
cls
.
deserialize
(
old_json
)
new_disk
=
None
new_disk
=
cls
.
deserialize
(
new_json
)
if
old_json
[
"data_store_type"
]
==
"ceph_block"
:
disk
=
CephDisk
.
deserialize
(
old_json
)
new_disk
=
CephDisk
.
deserialize
(
new_json
)
else
:
disk
=
Disk
.
deserialize
(
old_json
)
new_disk
=
Disk
.
deserialize
(
new_json
)
disk
.
merge
(
self
,
new_disk
,
parent_id
=
parent_id
)
disk
.
merge
(
self
,
new_disk
,
parent_id
=
parent_id
)
...
@@ -155,7 +129,7 @@ def get_storage_stat(data_store_type, path):
...
@@ -155,7 +129,7 @@ def get_storage_stat(data_store_type, path):
@celery.task
@celery.task
def
is_
exists
(
data_store_type
,
path
,
disk_name
):
def
exists
(
data_store_type
,
path
,
disk_name
):
''' Recover named disk from the trash directory.
''' Recover named disk from the trash directory.
'''
'''
if
data_store_type
==
"ceph_block"
:
if
data_store_type
==
"ceph_block"
:
...
...
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