]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: lifecycle utility coroutine
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 27 Jul 2018 23:21:33 +0000 (16:21 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 11 Dec 2018 08:10:43 +0000 (00:10 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_tools.cc
src/rgw/rgw_cr_tools.h

index a07e709a96b757700d142c261db3e5bb573c1a28..1d5565acf2219fda3cc814bcf98e2f7eec0387bf 100644 (file)
@@ -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,
+                                  &params.config);
+  if (ret < 0) {
+    lderr(cct) << "ERROR: failed to set lifecycle on bucke: " << cpp_strerror(-ret) << dendl;
+    return -ret;
   }
 
   return 0;
index 748fd94fd2c19fff76d800014b4af41466429c2c..15d1830616ae45a3e711f0f4cbe525da6c83849a 100644 (file)
@@ -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<rgw_object_simple_put_params>;
 
 
+struct rgw_bucket_lifecycle_config_params {
+  RGWBucketInfo bucket_info;
+  map<string, bufferlist> bucket_attrs;
+  RGWLifecycleConfiguration config;
+};
+
+using RGWBucketLifecycleConfigCR = RGWSimpleWriteOnlyAsyncCR<rgw_bucket_lifecycle_config_params>;
+
 
 #endif