Commit a5ddf866 by Czémán Arnold

add missing ceph.py, add python-cephlibs requirement

parent 6220467b
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()
celery==3.1.17
requests==2.5.3
filemagic==1.6
python-cephlibs==0.94.5-1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment