]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add cr to send DELETE to remove endpoint
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 24 Aug 2016 17:56:43 +0000 (10:56 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Oct 2016 17:31:26 +0000 (10:31 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_rest.h
src/rgw/rgw_rest_conn.h

index 346c3383fcbb21c1a585d8e40c982050bc952c2b..d30c4816ac0f82428bf5d9a4d96dc32a9b3808dd 100644 (file)
@@ -108,7 +108,7 @@ public:
 
     int ret = op->aio_send(bl);
     if (ret < 0) {
-      lsubdout(cct, rgw, 0) << "ERROR: failed to send post request" << dendl;
+      lsubdout(cct, rgw, 0) << "ERROR: failed to send request" << dendl;
       op->put();
       return ret;
     }
@@ -169,4 +169,68 @@ public:
                             _params, _input, _result) {}
 };
 
+class RGWDeleteRESTResourceCR : public RGWSimpleCoroutine {
+  RGWRESTConn *conn;
+  RGWHTTPManager *http_manager;
+  string path;
+  param_vec_t params;
+
+  boost::intrusive_ptr<RGWRESTDeleteResource> http_op;
+
+public:
+  RGWDeleteRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                        RGWHTTPManager *_http_manager,
+                        const string& _path,
+                        rgw_http_param_pair *_params)
+    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
+      path(_path), params(make_param_list(_params))
+  {}
+
+  ~RGWDeleteRESTResourceCR() {
+    request_cleanup();
+  }
+
+  int send_request() {
+    auto op = boost::intrusive_ptr<RGWRESTDeleteResource>(
+        new RGWRESTDeleteResource(conn, path, params, nullptr, http_manager));
+
+    op->set_user_info((void *)stack);
+
+    bufferlist bl;
+
+    int ret = op->aio_send(bl);
+    if (ret < 0) {
+      lsubdout(cct, rgw, 0) << "ERROR: failed to send DELETE request" << dendl;
+      op->put();
+      return ret;
+    }
+    std::swap(http_op, op); // store reference in http_op on success
+    return 0;
+  }
+
+  int request_complete() {
+    int ret;
+    bufferlist bl;
+    ret = http_op->wait_bl(&bl);
+    auto op = std::move(http_op); // release ref on return
+    if (ret < 0) {
+      error_stream << "http operation failed: " << op->to_str()
+          << " status=" << op->get_http_status() << std::endl;
+      lsubdout(cct, rgw, 5) << "failed to wait for op, ret=" << ret
+          << ": " << op->to_str() << dendl;
+      op->put();
+      return ret;
+    }
+    op->put();
+    return 0;
+  }
+
+  void request_cleanup() {
+    if (http_op) {
+      http_op->put();
+      http_op = NULL;
+    }
+  }
+};
+
 #endif
index 01426034215d0b3efe8e9788903935ce5092a803..5ca8b682c866f37cba69fe19633ed21cc3b6b87f 100644 (file)
@@ -387,5 +387,24 @@ public:
 
 };
 
+class RGWRESTDeleteResource : public RGWRESTSendResource {
+public:
+  RGWRESTDeleteResource(RGWRESTConn *_conn,
+                    const string& _resource,
+                    const rgw_http_param_pair *pp,
+                    param_vec_t *extra_headers,
+                    RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "DELETE", _resource,
+                                                                  pp, extra_headers, _mgr) {}
+
+  RGWRESTDeleteResource(RGWRESTConn *_conn,
+                    const string& _resource,
+                    param_vec_t& params,
+                    param_vec_t *extra_headers,
+                    RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "DELETE", _resource,
+                                                                  params, extra_headers, _mgr) {}
+
+};
+
+
 
 #endif