]> 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 creating
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Thu, 2 Jun 2016 09:34:22 +0000 (05:34 -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 52727bf39e481f3ee5cbbe0e3e4f9a17b036d9f8..ebf4ed1eb8e23f8007e3bae7b373112c16dd9b44 100644 (file)
@@ -598,7 +598,7 @@ class RBD(object):
         return (major, minor, extra)
 
     def create(self, ioctx, name, size, order=None, old_format=True,
-               features=None, stripe_unit=0, stripe_count=0):
+               features=None, stripe_unit=None, stripe_count=None):
         """
         Create an rbd image.
 
@@ -616,7 +616,7 @@ class RBD(object):
         :type old_format: bool
         :param features: bitmask of features to enable
         :type features: 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
@@ -635,7 +635,9 @@ class RBD(object):
         if order is not None:
             _order = order
         if old_format:
-            if features or stripe_unit != 0 or stripe_count != 0:
+            if (features or
+                ((stripe_unit is not None) and stripe_unit != 0) or
+                ((stripe_count is not None) and stripe_count != 0)):
                 raise InvalidArgument('format 1 images do not support feature'
                                       ' masks or non-default striping')
             with nogil:
@@ -649,13 +651,16 @@ class RBD(object):
                     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_create4(_ioctx, _name, _size, opts)
             finally: