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
a2d1cd02
authored
May 01, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix CephDisk.download(), remove CephDisk.merge_disk_with_base(), fix exists() and make_free_space()
parent
3746c537
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
30 deletions
+12
-30
disk.py
+3
-26
storagedriver.py
+9
-4
No files found.
disk.py
View file @
a2d1cd02
...
...
@@ -553,7 +553,9 @@ class CephDisk(Disk):
with
CephConnection
(
self
.
dir
)
as
conn
:
rbd_inst
=
rbd
.
RBD
()
# keep calm, Ceph Block Device uses thin-provisioning
rbd_inst
.
create
(
conn
.
ioctx
,
self
.
name
,
int
(
MAXIMUM_SIZE
))
rbd_inst
.
create
(
conn
.
ioctx
,
self
.
name
,
int
(
MAXIMUM_SIZE
),
old_format
=
False
,
features
=
rbd
.
RBD_FEATURE_LAYERING
)
with
rbd
.
Image
(
conn
.
ioctx
,
self
.
name
)
as
image
:
offset
=
0
actsize
=
0
...
...
@@ -633,28 +635,6 @@ class CephDisk(Disk):
self
.
__with_ceph_connection
(
self
.
__snapshot
)
def
merge_disk_with_base
(
self
,
ioctx
,
task
,
new_disk
,
parent_id
=
None
):
with
rbd
.
Image
(
ioctx
,
self
.
name
)
as
image
:
logger
.
debug
(
"Merging
%
s into
%
s."
,
self
.
get_path
(),
new_disk
.
get_path
())
image
.
create_snap
(
new_disk
.
name
)
image
.
protect_snap
(
new_disk
.
name
)
if
not
task
.
is_aborted
():
task
.
update_state
(
task_id
=
parent_id
,
state
=
task
.
AsyncResult
(
parent_id
)
.
state
,
meta
=
{
'size'
:
new_disk
.
size
,
'percent'
:
100
})
else
:
logger
.
warning
(
"Merging new disk
%
s is aborted by user."
,
new_disk
.
get_path
())
logger
.
warning
(
"Aborted merge job, removing
%
s"
,
new_disk
.
get_path
())
with
rbd
.
Image
(
ioctx
,
self
.
name
)
as
image
:
image
.
remove_snap
(
new_disk
.
name
)
def
merge_disk_without_base
(
self
,
ioctx
,
task
,
new_disk
,
parent_id
=
None
,
length
=
1024
*
1024
):
...
...
@@ -688,9 +668,6 @@ class CephDisk(Disk):
if
task
.
is_aborted
():
raise
AbortException
()
# if self.base_name:
# self.merge_disk_with_base(ioctx, task, new_disk, parent_id)
# else:
self
.
merge_disk_without_base
(
ioctx
,
task
,
new_disk
,
parent_id
)
def
merge
(
self
,
task
,
new_disk
,
parent_id
=
None
):
...
...
storagedriver.py
View file @
a2d1cd02
...
...
@@ -62,7 +62,6 @@ def delete(disk_desc):
@celery.task
()
def
delete_dump
(
data_store_type
,
dir
,
filename
):
if
data_store_type
==
"ceph_block"
:
with
CephConnection
(
str
(
dir
))
as
conn
:
rbd_inst
=
rbd
.
RBD
()
...
...
@@ -135,7 +134,7 @@ def exists(data_store_type, path, disk_name):
if
data_store_type
==
"ceph_block"
:
try
:
with
CephConnection
(
str
(
path
))
as
conn
:
with
rbd
.
Image
(
conn
.
ioctx
,
disk_name
):
with
rbd
.
Image
(
conn
.
ioctx
,
str
(
disk_name
)
):
pass
except
rbd
.
ImageNotFound
:
return
False
...
...
@@ -163,10 +162,16 @@ def make_free_space(data_store_type, path, deletable_disks, percent=10):
if
ds_type
==
"ceph_block"
:
with
CephConnection
(
str
(
path
))
as
conn
:
rbd_inst
=
rbd
.
RBD
()
rbd_inst
.
remove
(
conn
.
ioctx
,
f
)
with
rbd
.
Image
(
conn
.
ioctx
,
str
(
f
))
as
image
:
for
snapshot
in
image
.
list_snaps
():
name
=
snapshot
[
"name"
]
image
.
unprotect_snap
(
name
)
image
.
remove_snap
(
name
)
rbd_inst
.
remove
(
conn
.
ioctx
,
str
(
f
))
else
:
unlink
(
os
.
path
.
join
(
path
,
f
))
logger
.
info
(
'Image:
%
s removed.'
%
f
)
except
IndexError
:
raise
Exception
(
"Has no deletable disk."
)
logger
.
warning
(
"Has no deletable disk."
)
return
False
return
True
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