char* PyBytes_AsString(PyObject *string) except NULL
int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
+ctypedef int (*librbd_progress_fn_t)(uint64_t offset, uint64_t total, void* ptr)
+
cdef extern from "rbd/librbd.h" nogil:
enum:
_RBD_FEATURE_LAYERING "RBD_FEATURE_LAYERING"
uint64_t size
char *name
-
void rbd_version(int *major, int *minor, int *extra)
void rbd_image_options_create(rbd_image_options_t* opts)
int *is_protected)
int rbd_snap_set(rbd_image_t image, const char *snapname)
int rbd_flatten(rbd_image_t image)
+ int rbd_rebuild_object_map(rbd_image_t image, librbd_progress_fn_t cb,
+ void *cbdata);
ssize_t rbd_list_children(rbd_image_t image, char *pools, size_t *pools_len,
char *images, size_t *images_len)
ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive,
cdef rados_ioctx_t convert_ioctx(ioctx) except? NULL:
return <rados_ioctx_t><uintptr_t>ioctx.io.value
+cdef int no_op_progress_callback(uint64_t offset, uint64_t total, void* ptr):
+ return 0
+
def cstr(val, name, encoding="utf-8", opt=False):
"""
Create a byte string from a Python string
if ret < 0:
raise make_ex(ret, "error flattening %s" % self.name)
+ def rebuild_object_map(self):
+ """
+ Rebuilds the object map for the image HEAD or currently set snapshot
+ """
+ cdef librbd_progress_fn_t prog_cb = &no_op_progress_callback
+ with nogil:
+ ret = rbd_rebuild_object_map(self.image, prog_cb, NULL)
+ if ret < 0:
+ raise make_ex(ret, "error rebuilding object map %s" % self.name)
+
def list_children(self):
"""
List children of the currently set snapshot (set via set_snap()).