]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rados: Fix binary omap values.
authorRobin H. Johnson <robin.johnson@dreamhost.com>
Fri, 9 Oct 2015 21:59:01 +0000 (14:59 -0700)
committerRobin H. Johnson <robin.johnson@dreamhost.com>
Fri, 9 Oct 2015 23:28:55 +0000 (16:28 -0700)
The prior code caused binary omap values to be discarded. This fixes
them to use the same model as the xattr iterator, and correctly return
binary data as python strings, eg:
'object_prefix': '\x15\x00\x00\x00rbd_data.449d2ae8944a'

Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
src/pybind/rados.py

index ccada723c3660838fa15b551cc20338026debb90..2172d023072096a958bba3039964599c78a74c9f 100644 (file)
@@ -846,17 +846,20 @@ class OmapIterator(object):
         Get the next key-value pair in the object
         :returns: next rados.OmapItem
         """
-        key = c_char_p()
-        value = c_char_p()
-        lens  = c_int()
-        run_in_thread(self.ioctx.librados.rados_omap_get_next,
-                      (self.ctx, pointer(key), pointer(value),
-                       pointer(lens)))
-        if key.value is None and value.value is None:
+        key_ = c_char_p(0)
+        val_ = c_char_p(0)
+        len_ = c_int(0)
+        ret = run_in_thread(self.ioctx.librados.rados_omap_get_next,
+                      (self.ctx, byref(key_), byref(val_), byref(len_)))
+        if (ret != 0):
+            raise make_ex(ret, "error iterating over the omap")
+        if key_.value is None:
             raise StopIteration()
-        if lens.value:
-            value.value = value.value[0:lens.value]
-        return (key.value, value.value)
+        key = ctypes.string_at(key_)
+        val = None
+        if val_.value is not None:
+            val = ctypes.string_at(val_, len_)
+        return (key, val)
 
     def __del__(self):
         run_in_thread(self.ioctx.librados.rados_omap_get_end, (self.ctx,))