"""
from ctypes import CDLL, c_char_p, c_size_t, c_void_p, c_int, c_long, c_uint, c_ulong, \
create_string_buffer, byref, Structure
+from ctypes.util import find_library
import errno
class Error(Exception):
"CephFS object in state %s." % (self.state))
def __init__(self, conf=None, conffile=None):
- self.libcephfs = CDLL('libcephfs.so.1')
+ libcephfs_path = find_library('cephfs')
+ if not libcephfs_path:
+ raise EnvironmentError("Unable to find libcephfs")
+ self.libcephfs = CDLL(libcephfs_path)
self.cluster = c_void_p()
if conffile is not None and not isinstance(conffile, str):
from ctypes import CDLL, c_char, c_char_p, c_size_t, c_void_p, c_int, \
create_string_buffer, byref, Structure, c_uint64, c_int64, c_uint8, \
CFUNCTYPE
+from ctypes.util import find_library
import ctypes
import errno
("size", c_uint64),
("name", c_char_p)]
+def load_librbd():
+ """
+ Load the librbd shared library.
+ """
+ librbd_path = find_library('rbd')
+ if not librbd_path:
+ raise EnvironmentError("Unable to find librbd")
+ return CDLL(librbd_path)
+
class RBD(object):
"""
This class wraps librbd CRUD functions.
"""
def __init__(self):
- self.librbd = CDLL('librbd.so.1')
+ self.librbd = load_librbd()
def version(self):
"""
:type read_only: bool
"""
self.closed = True
- self.librbd = CDLL('librbd.so.1')
+ self.librbd = load_librbd()
self.image = c_void_p()
self.name = name
if not isinstance(name, str):