]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: create/clone/copy: default to None for features param 9258/head
authorMykola Golub <mgolub@mirantis.com>
Mon, 23 May 2016 06:18:34 +0000 (09:18 +0300)
committerMykola Golub <mgolub@mirantis.com>
Mon, 23 May 2016 06:23:11 +0000 (09:23 +0300)
If None is specified don't set the features so that the defaults is
used.

Fixes: http://tracker.ceph.com/issues/15982
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/pybind/rbd/rbd.pyx
src/test/pybind/test_rbd.py

index 92a708bd308326d4a5e4e022e2f24e57e580b02c..5dadc37b72a972c0475cb760bd630a2b0daacf61 100644 (file)
@@ -462,7 +462,7 @@ class RBD(object):
         return (major, minor, extra)
 
     def create(self, ioctx, name, size, order=None, old_format=True,
-               features=0, stripe_unit=0, stripe_count=0):
+               features=None, stripe_unit=0, stripe_count=0):
         """
         Create an rbd image.
 
@@ -499,7 +499,7 @@ class RBD(object):
         if order is not None:
             _order = order
         if old_format:
-            if features != 0 or stripe_unit != 0 or stripe_count != 0:
+            if features or stripe_unit != 0 or stripe_count != 0:
                 raise InvalidArgument('format 1 images do not support feature'
                                       ' masks or non-default striping')
             with nogil:
@@ -509,8 +509,10 @@ class RBD(object):
             try:
                 rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_FORMAT,
                                              1 if old_format else 2)
-                rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_FEATURES,
-                                             features)
+                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,
@@ -526,7 +528,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=0, order=None, stripe_unit=0, stripe_count=0):
+              features=None, order=None, stripe_unit=0, stripe_count=0):
         """
         Clone a parent rbd snapshot into a COW sparse child.
 
@@ -569,8 +571,9 @@ class RBD(object):
 
         rbd_image_options_create(&opts)
         try:
-            rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_FEATURES,
-                                         features)
+            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,
@@ -1259,8 +1262,8 @@ cdef class Image(object):
             raise make_ex(ret, 'error getting lock status for image' % (self.name))
         return owner == 1
 
-    def copy(self, dest_ioctx, dest_name, features=0, order=None, stripe_unit=0,
-             stripe_count=0):
+    def copy(self, dest_ioctx, dest_name, features=None, order=None,
+             stripe_unit=0, stripe_count=0):
         """
         Copy the image to another location.
 
@@ -1292,8 +1295,9 @@ cdef class Image(object):
 
         rbd_image_options_create(&opts)
         try:
-            rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_FEATURES,
-                                         features)
+            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,
index b60f09fba62f7ea722ab83ce0f7d91966228fdab..5b760e14d6cd0000cb3a37fe5613f42e9a73f042 100644 (file)
@@ -753,19 +753,43 @@ class TestClone(object):
         self.image.close()
         remove_image()
 
-    @require_features([RBD_FEATURE_STRIPINGV2])
-    def test_with_params(self):
-        global features
+    def _test_with_params(self, features=None, order=None, stripe_unit=None,
+                          stripe_count=None):
         self.image.create_snap('snap2')
         self.image.protect_snap('snap2')
         clone_name2 = get_temp_image_name()
-        self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
-                       features, self.image.stat()['order'],
-                       self.image.stripe_unit(), self.image.stripe_count())
+        if features is None:
+            self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2)
+        elif order is None:
+            self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
+                           features)
+        elif stripe_unit is None:
+            self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
+                           features, order)
+        elif stripe_count is None:
+            self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
+                           features, order, stripe_unit)
+        else:
+            self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
+                           features, order, stripe_unit, stripe_count)
         self.rbd.remove(ioctx, clone_name2)
         self.image.unprotect_snap('snap2')
         self.image.remove_snap('snap2')
 
+    def test_with_params(self):
+        self._test_with_params()
+
+    def test_with_params2(self):
+        global features
+        self._test_with_params(features, self.image.stat()['order'])
+
+    @require_features([RBD_FEATURE_STRIPINGV2])
+    def test_with_params3(self):
+        global features
+        self._test_with_params(features, self.image.stat()['order'],
+                               self.image.stripe_unit(),
+                               self.image.stripe_count())
+
     def test_unprotected(self):
         self.image.create_snap('snap2')
         global features