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
a5ddf866
authored
Jun 23, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing ceph.py, add python-cephlibs requirement
parent
6220467b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
ceph.py
+47
-0
requirements/base.txt
+1
-0
No files found.
ceph.py
0 → 100644
View file @
a5ddf866
import
rados
import
os
class
CephConfig
:
def
__init__
(
self
,
user
=
None
,
config_path
=
None
,
keyring_path
=
None
):
self
.
user
=
user
or
"admin"
self
.
config_path
=
(
config_path
or
os
.
getenv
(
"CEPH_CONFIG"
,
"/etc/ceph/ceph.conf"
))
default_keyring
=
"/etc/ceph/ceph.client.
%
s.keyring"
%
self
.
user
self
.
keyring_path
=
(
keyring_path
or
os
.
getenv
(
"CEPH_KEYRING"
,
default_keyring
))
def
cmd_args
(
self
):
return
[
"--keyring"
,
self
.
keyring_path
,
"--id"
,
self
.
user
,
"--conf"
,
self
.
config_path
]
class
CephConnection
:
def
__init__
(
self
,
pool_name
,
conf
=
None
,
**
kwargs
):
self
.
pool_name
=
pool_name
self
.
conf
=
conf
or
CephConfig
(
**
kwargs
)
self
.
cluster
=
None
self
.
ioctx
=
None
def
__enter__
(
self
):
try
:
self
.
cluster
=
rados
.
Rados
(
conffile
=
self
.
conf
.
config_path
,
conf
=
dict
(
keyring
=
self
.
conf
.
keyring_path
))
timeout
=
os
.
getenv
(
"CEPH_TIMEOUT"
,
2
)
self
.
cluster
.
connect
(
timeout
=
timeout
)
self
.
ioctx
=
self
.
cluster
.
open_ioctx
(
self
.
pool_name
)
except
rados
.
InterruptedOrTimeoutError
as
e
:
raise
Exception
(
e
)
return
self
def
__exit__
(
self
,
type
,
value
,
traceback
):
self
.
ioctx
.
close
()
self
.
cluster
.
shutdown
()
requirements/base.txt
View file @
a5ddf866
celery==3.1.17
requests==2.5.3
filemagic==1.6
python-cephlibs==0.94.5-1
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