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
5d8b4cac
authored
Dec 04, 2015
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storagedriver: rework get_storage_stat, add ceph specific implementation
parent
1ddad930
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
+10
-1
storagedriver.py
+10
-1
No files found.
storagedriver.py
View file @
5d8b4cac
...
@@ -109,11 +109,20 @@ def get(json_data):
...
@@ -109,11 +109,20 @@ def get(json_data):
@celery.task
()
@celery.task
()
def
get_storage_stat
(
path
):
def
get_storage_stat
(
data_store_type
,
path
):
''' Return free disk space avaliable at path in bytes and percent.'''
''' Return free disk space avaliable at path in bytes and percent.'''
all_space
=
1
free_space
=
0
if
data_store_type
==
"ceph_block"
:
with
CephConnection
(
str
(
path
))
as
conn
:
stat
=
conn
.
cluster
.
get_cluster_stats
()
all_space
=
stat
[
"kb"
]
free_space
=
stat
[
"kb_avail"
]
else
:
s
=
statvfs
(
path
)
s
=
statvfs
(
path
)
all_space
=
s
.
f_bsize
*
s
.
f_blocks
all_space
=
s
.
f_bsize
*
s
.
f_blocks
free_space
=
s
.
f_bavail
*
s
.
f_frsize
free_space
=
s
.
f_bavail
*
s
.
f_frsize
free_space_percent
=
100.0
*
free_space
/
all_space
free_space_percent
=
100.0
*
free_space
/
all_space
return
{
'free_space'
:
free_space
,
return
{
'free_space'
:
free_space
,
'free_percent'
:
free_space_percent
}
'free_percent'
:
free_space_percent
}
...
...
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