]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: create/clone/copy: default to None for features param 9553/head
authorMykola Golub <mgolub@mirantis.com>
Mon, 23 May 2016 06:18:34 +0000 (09:18 +0300)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Tue, 7 Jun 2016 13:44:59 +0000 (19:14 +0530)
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>
(cherry picked from commit b8b3a9757f7d517210a91f2893b0961b6b35afab)

src/pybind/rbd/rbd.pyx
src/test/pybind/test_rbd.py

index 23a9895cfcb8f8dfc1976b31332ec5e9255fe9d9..1d40f94e9795097d9a74c35dff5a2ab72775a39c 100644 (file)
@@ -368,7 +368,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.
 
@@ -405,7 +405,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:
@@ -415,8 +415,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,
@@ -432,7 +434,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.
 
@@ -475,8 +477,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,
@@ -857,8 +860,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.
 
@@ -890,8 +893,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 04a3a3820da920861e7cb1f4d0f66bb311ea2f9e..aae7fd02103868a5bf6b11f980c5daae3dcca7b0 100644 (file)
@@ -750,19 +750,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