From: Yehuda Sadeh Date: Fri, 27 Jul 2018 23:21:33 +0000 (-0700) Subject: rgw: lifecycle utility coroutine X-Git-Tag: v14.1.0~616^2~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d80dc3296737ceeeafc0b8c368812ff4a3012786;p=ceph.git rgw: lifecycle utility coroutine Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_cr_tools.cc b/src/rgw/rgw_cr_tools.cc index a07e709a96b7..1d5565acf221 100644 --- a/src/rgw/rgw_cr_tools.cc +++ b/src/rgw/rgw_cr_tools.cc @@ -228,9 +228,11 @@ int RGWObjectSimplePutCR::Request::_send_request() { RGWDataAccess::ObjectRef obj; + CephContext *cct = store->ctx(); + int ret = params.bucket->get_object(params.key, &obj); if (ret < 0) { - cerr << "ERROR: failed to get object: " << cpp_strerror(-ret) << std::endl; + lderr(cct) << "ERROR: failed to get object: " << cpp_strerror(-ret) << dendl; return -ret; } @@ -240,7 +242,29 @@ int RGWObjectSimplePutCR::Request::_send_request() ret = obj->put(params.data, params.attrs); if (ret < 0) { - cerr << "ERROR: put object returned error: " << cpp_strerror(-ret) << std::endl; + lderr(cct) << "ERROR: put object returned error: " << cpp_strerror(-ret) << dendl; + } + + return 0; +} + +template<> +int RGWBucketLifecycleConfigCR::Request::_send_request() +{ + CephContext *cct = store->ctx(); + + RGWLC *lc = store->get_lc(); + if (!lc) { + lderr(cct) << "ERROR: lifecycle object is not initialized!" << dendl; + return -EIO; + } + + int ret = lc->set_bucket_config(params.bucket_info, + params.bucket_attrs, + ¶ms.config); + if (ret < 0) { + lderr(cct) << "ERROR: failed to set lifecycle on bucke: " << cpp_strerror(-ret) << dendl; + return -ret; } return 0; diff --git a/src/rgw/rgw_cr_tools.h b/src/rgw/rgw_cr_tools.h index 748fd94fd2c1..15d1830616ae 100644 --- a/src/rgw/rgw_cr_tools.h +++ b/src/rgw/rgw_cr_tools.h @@ -3,6 +3,7 @@ #include "rgw_cr_rados.h" #include "rgw_tools.h" +#include "rgw_lc.h" struct rgw_user_create_params { @@ -62,5 +63,13 @@ struct rgw_object_simple_put_params { using RGWObjectSimplePutCR = RGWSimpleWriteOnlyAsyncCR; +struct rgw_bucket_lifecycle_config_params { + RGWBucketInfo bucket_info; + map bucket_attrs; + RGWLifecycleConfiguration config; +}; + +using RGWBucketLifecycleConfigCR = RGWSimpleWriteOnlyAsyncCR; + #endif