From: Ricardo Dias Date: Thu, 12 Apr 2018 00:34:23 +0000 (+0100) Subject: mgr/dashboard: rbd: image copy implementation X-Git-Tag: v13.1.0~234^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9dbe25427a7c9c2c8428323e3ddbf26f95db38a4;p=ceph-ci.git mgr/dashboard: rbd: image copy implementation Signed-off-by: Ricardo Dias --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index daeab560e76..254f4402af9 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -313,6 +313,34 @@ class Rbd(RESTController): return _rbd_image_call(pool_name, image_name, _edit) + @RbdTask('copy', + {'src_pool_name': '{pool_name}', + 'src_image_name': '{image_name}', + 'dest_pool_name': '{dest_pool_name}', + 'dest_image_name': '{dest_image_name}'}, 2.0) + @RESTController.resource(['POST']) + @RESTController.args_from_json + def copy(self, pool_name, image_name, dest_pool_name, dest_image_name, + obj_size=None, features=None, stripe_unit=None, + stripe_count=None, data_pool=None): + + def _src_copy(s_ioctx, s_img): + def _copy(d_ioctx): + # Set order + l_order = None + if obj_size and obj_size > 0: + l_order = int(round(math.log(float(obj_size), 2))) + + # Set features + feature_bitmask = _format_features(features) + + s_img.copy(d_ioctx, dest_image_name, feature_bitmask, l_order, + stripe_unit, stripe_count, data_pool) + + return _rbd_call(dest_pool_name, _copy) + + return _rbd_image_call(pool_name, image_name, _src_copy) + @ApiController('rbd/:pool_name/:image_name/snap') class RbdSnapshot(RESTController):