Commit 6220467b by Czémán Arnold

Rename util.py --> ceph.py, copy ceph.py from vmdriver

parent b5f38f5c
......@@ -16,7 +16,7 @@ import requests
import rbd
from rbd import InvalidArgument, ImageNotFound
from util import CephConnection
from ceph import CephConnection
logger = logging.getLogger(__name__)
......
from disk import Disk, CephDisk
from util import CephConnection
from ceph import CephConnection
from storagecelery import celery
import os
from os import unlink, statvfs, listdir
......
import rados
import os
class CephConnection:
def __init__(self, pool_name, ceph_config=None):
self.pool_name = pool_name
self.ceph_config = ceph_config
self.cluster = None
self.ioctx = None
def __enter__(self):
try:
if self.ceph_config is None:
self.ceph_config = os.getenv("CEPH_CONFIG",
"/etc/ceph/ceph.conf")
self.cluster = rados.Rados(conffile=self.ceph_config)
self.cluster.connect(timeout=2)
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()
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