]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: es: api to delete bucket mdsearch config
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 31 Mar 2017 22:56:06 +0000 (15:56 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:24:44 +0000 (13:24 -0700)
DELETE /bucket?mdsearch

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index f7543656485245df92faa0b9b1c0e9651462240b..608b9fa6444e20eec79c2a01779263104eb048f0 100644 (file)
@@ -468,6 +468,7 @@ enum RGWOpType {
   RGW_OP_METADATA_SEARCH,
   RGW_OP_CONFIG_BUCKET_META_SEARCH,
   RGW_OP_GET_BUCKET_META_SEARCH,
+  RGW_OP_DEL_BUCKET_META_SEARCH,
 };
 
 class RGWAccessControlPolicy;
index fe6b7027a2b2abf512fa46aa4d014e226cfd2e6d..d4a9326c3dd02a0ae020e062498acfb528cd23bf 100644 (file)
@@ -6353,6 +6353,31 @@ void RGWGetBucketMetaSearch::pre_exec()
   rgw_bucket_object_pre_exec(s);
 }
 
+int RGWDelBucketMetaSearch::verify_permission()
+{
+  if (!s->auth.identity->is_owner_of(s->bucket_owner.get_id())) {
+    return -EACCES;
+  }
+
+  return 0;
+}
+
+void RGWDelBucketMetaSearch::pre_exec()
+{
+  rgw_bucket_object_pre_exec(s);
+}
+
+void RGWDelBucketMetaSearch::execute()
+{
+  s->bucket_info.mdsearch_config.clear();
+
+  op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(), &s->bucket_attrs);
+  if (op_ret < 0) {
+    ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name << " returned err=" << op_ret << dendl;
+    return;
+  }
+}
+
 
 RGWHandler::~RGWHandler()
 {
index bbb0bdb0390caf88022f484c39561ff49c1ccb6f..62c71fd98e7948a55850db32bbfb8b6eaa45ce4e 100644 (file)
@@ -2046,4 +2046,18 @@ public:
   virtual uint32_t op_mask() { return RGW_OP_TYPE_READ; }
 };
 
+class RGWDelBucketMetaSearch : public RGWOp {
+public:
+  RGWDelBucketMetaSearch() {}
+
+  int verify_permission();
+  void pre_exec();
+  void execute();
+
+  virtual void send_response() = 0;
+  virtual const string name() { return "delete_bucket_meta_search"; }
+  virtual RGWOpType delete_type() { return RGW_OP_DEL_BUCKET_META_SEARCH; }
+  virtual uint32_t op_mask() { return RGW_OP_TYPE_WRITE; }
+};
+
 #endif /* CEPH_RGW_OP_H */
index 8dd6ba6055bf2df8e0b732438953fd9eb2dddb30..a948cf1548f605aa802fd5a0aa9263e2762a4df8 100644 (file)
@@ -2794,8 +2794,8 @@ void RGWGetBucketMetaSearch_ObjStore_S3::send_response()
 
   Formatter *f = s->formatter;
   f->open_array_section("GetBucketMetaSearchResult");
-  f->open_object_section("Entry");
   for (auto& e : s->bucket_info.mdsearch_config) {
+    f->open_object_section("Entry");
     string k = string("x-amz-meta-") + e.first;
     f->dump_string("Key", k.c_str());
     const char *type;
@@ -2810,12 +2810,20 @@ void RGWGetBucketMetaSearch_ObjStore_S3::send_response()
         type = "str";
     }
     f->dump_string("Type", type);
+    f->close_section();
   }
   f->close_section();
-  f->close_section();
   rgw_flush_formatter(s, f);
 }
 
+void RGWDelBucketMetaSearch_ObjStore_S3::send_response()
+{
+  if (op_ret)
+    set_req_state_err(s, op_ret);
+  dump_errno(s);
+  end_header(s, this);
+}
+
 
 RGWOp *RGWHandler_REST_Service_S3::op_get()
 {
@@ -2958,6 +2966,10 @@ RGWOp *RGWHandler_REST_Bucket_S3::op_delete()
     return new RGWDeleteBucketWebsite_ObjStore_S3;
   }
 
+  if (s->info.args.exists("mdsearch")) {
+    return new RGWDelBucketMetaSearch_ObjStore_S3;
+  }
+
   return new RGWDeleteBucket_ObjStore_S3;
 }
 
index d362d07bd65b3061c11bec9b5073b86b622123da..d426b3d40caac8f5eb59f37f4062ec368606a93e 100644 (file)
@@ -435,6 +435,14 @@ public:
   void send_response() override;
 };
 
+class RGWDelBucketMetaSearch_ObjStore_S3 : public RGWDelBucketMetaSearch {
+public:
+  RGWDelBucketMetaSearch_ObjStore_S3() {}
+  ~RGWDelBucketMetaSearch_ObjStore_S3() {}
+
+  void send_response() override;
+};
+
 class RGW_Auth_S3 {
 private:
   static int authorize_v2(RGWRados *store,