]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: don't set the default values for the options not specified in cloning
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Thu, 2 Jun 2016 09:38:15 +0000 (05:38 -0400)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Fri, 22 Jul 2016 11:04:09 +0000 (07:04 -0400)
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/pybind/rbd/rbd.pyx

index ebf4ed1eb8e23f8007e3bae7b373112c16dd9b44..889ec24f86e12efcf3b337728dfdf4ea8a400011 100644 (file)
@@ -669,7 +669,7 @@ class RBD(object):
             raise make_ex(ret, 'error creating image')
 
     def clone(self, p_ioctx, p_name, p_snapname, c_ioctx, c_name,
-              features=None, order=None, stripe_unit=0, stripe_count=0):
+              features=None, order=None, stripe_unit=None, stripe_count=None):
         """
         Clone a parent rbd snapshot into a COW sparse child.
 
@@ -687,7 +687,7 @@ class RBD(object):
         :type features: int
         :param order: the image is split into (2**order) byte objects
         :type order: int
-        :param stripe_unit: stripe unit in bytes (default 0 for object size)
+        :param stripe_unit: stripe unit in bytes (default None to let librbd decide)
         :type stripe_unit: int
         :param stripe_count: objects to stripe over before looping
         :type stripe_count: int
@@ -707,20 +707,21 @@ class RBD(object):
             char *_p_snapname = p_snapname
             char *_c_name = c_name
             rbd_image_options_t opts
-        if order is None:
-            order = 0
 
         rbd_image_options_create(&opts)
         try:
             if features is not None:
                 rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_FEATURES,
                                              features)
-            rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_ORDER,
-                                         order)
-            rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_UNIT,
-                                         stripe_unit)
-            rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_COUNT,
-                                         stripe_count)
+            if order is not None:
+                rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_ORDER,
+                                             order)
+            if stripe_unit is not None:
+                rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_UNIT,
+                                             stripe_unit)
+            if stripe_count is not None:
+                rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_COUNT,
+                                             stripe_count)
             with nogil:
                 ret = rbd_clone3(_p_ioctx, _p_name, _p_snapname,
                                  _c_ioctx, _c_name, opts)