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.
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:
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,
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.
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,
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.
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,
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