]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd.py: add support for creating images in the new format
authorJosh Durgin <josh.durgin@inktank.com>
Fri, 8 Jun 2012 15:09:35 +0000 (08:09 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Sun, 10 Jun 2012 00:24:50 +0000 (17:24 -0700)
The new arguments are optional, so they are backwards compatible.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/pybind/rbd.py

index 55a9d67b7f58ed4fe3dda9e64ade8d814bacd0c4..9fc537ea1366ef0f9e0dc90cee9bf186c1d73428 100644 (file)
@@ -120,7 +120,8 @@ class RBD(object):
         self.librbd.rbd_version(byref(major), byref(minor), byref(extra))
         return (major.value, minor.value, extra.value)
 
-    def create(self, ioctx, name, size, order=None):
+    def create(self, ioctx, name, size, order=None, old_format=True,
+               features=0):
         """
         Create an rbd image.
 
@@ -132,14 +133,27 @@ class RBD(object):
         :type size: int
         :param order: the image is split into (2**order) byte objects
         :type order: int
+        :param old_format: whether to create an old-style image that
+                           is accessible by old clients, but can't
+                           use more advanced features like layering.
+        :type old_format: bool
+        :param features: bitmask of features to enable
+        :type features: int
         :raises: :class:`ImageExists`
         """
         if order is None:
             order = 0
         if not isinstance(name, str):
             raise TypeError('name must be a string')
-        ret = self.librbd.rbd_create(ioctx.io, c_char_p(name), c_uint64(size),
-                                     byref(c_int(order)))
+        if old_format:
+            ret = self.librbd.rbd_create(ioctx.io, c_char_p(name),
+                                         c_uint64(size),
+                                         byref(c_int(order)))
+        else:
+            ret = self.librbd.rbd_create2(ioctx.io, c_char_p(name),
+                                          c_uint64(size),
+                                          c_uint64(features),
+                                          byref(c_int(order)))
         if ret < 0:
             raise make_ex(ret, 'error creating image')