]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: implement S3RESTConn to send request to S3
authorlvshanchun <lvshanchun@gmail.com>
Tue, 21 Nov 2017 05:01:34 +0000 (13:01 +0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:39 +0000 (08:05 -0700)
add a sub-class of RGWRESTConn called S3RESTConn that do not
populate zonegroup-related params, it shall only used for send request
to S3-like interface.

Signed-off-by: lvshanchun <lvshanchun@gmail.com>
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h
src/rgw/rgw_sync_module_aws.cc

index 14586bcd452f42bdee8d4ddb57e25f29365a46ea..fc4cda6e852ea56f5ba543efb319a5fd8f297c56 100644 (file)
@@ -81,7 +81,7 @@ string RGWRESTConn::get_url()
   return endpoint;
 }
 
-static void populate_params(param_vec_t& params, const rgw_user *uid, const string& zonegroup)
+void RGWRESTConn::populate_params(param_vec_t& params, const rgw_user *uid, const string& zonegroup)
 {
   if (uid) {
     string uid_str = uid->to_str();
@@ -371,7 +371,7 @@ RGWRESTReadResource::RGWRESTReadResource(RGWRESTConn *_conn,
 
 void RGWRESTReadResource::init_common(param_vec_t *extra_headers)
 {
-  populate_params(params, nullptr, conn->get_self_zonegroup());
+  conn->populate_params(params, nullptr, conn->get_self_zonegroup());
 
   if (extra_headers) {
     headers.insert(extra_headers->begin(), extra_headers->end());
@@ -431,7 +431,7 @@ RGWRESTSendResource::RGWRESTSendResource(RGWRESTConn *_conn,
 
 void RGWRESTSendResource::init_common(param_vec_t *extra_headers)
 {
-  populate_params(params, nullptr, conn->get_self_zonegroup());
+  conn->populate_params(params, nullptr, conn->get_self_zonegroup());
 
   if (extra_headers) {
     headers.insert(extra_headers->begin(), extra_headers->end());
index e4c9d3dbb1fb4185e69d49730a3e6a82ae16d056..bc50ae9bac5089eb8378c6c2ebc5c93a84e8d1e5 100644 (file)
@@ -90,6 +90,8 @@ public:
   }
   size_t get_endpoint_count() const { return endpoints.size(); }
 
+  virtual void populate_params(param_vec_t& params, const rgw_user *uid, const string& zonegroup);
+
   /* sync request */
   int forward(const rgw_user& uid, req_info& info, obj_version *objv, size_t max_response, bufferlist *inbl, bufferlist *outbl);
 
@@ -149,6 +151,22 @@ public:
   int get_json_resource(const string& resource, const rgw_http_param_pair *pp, T& t);
 };
 
+class S3RESTConn : public RGWRESTConn {
+
+public:
+
+  S3RESTConn(CephContext *_cct, RGWRados *store, const string& _remote_id, const list<string>& endpoints) :
+    RGWRESTConn(_cct, store, _remote_id, endpoints) {}
+
+  S3RESTConn(CephContext *_cct, RGWRados *store, const string& _remote_id, const list<string>& endpoints, RGWAccessKey _cred):
+    RGWRESTConn(_cct, store, _remote_id, endpoints, _cred) {}
+
+  void populate_params(param_vec_t& params, const rgw_user *uid, const string& zonegroup) override {
+    // do not populate any params in S3 REST Connection.
+    return;
+  }
+};
+
 
 template<class T>
 int RGWRESTConn::get_json_resource(const string& resource, param_vec_t *params, bufferlist *in_data, T& t)
index 73fb938b2e6dc23b8c0b25c26ef4895e7c4ec949..162b12d7e2d7d22bc438b8eda9bfc02ef23c88b7 100644 (file)
@@ -914,7 +914,7 @@ public:
 
   void init(RGWDataSyncEnv *sync_env, uint64_t instance_id) {
     instance.id = string("s3:") + instance.conf.s3_endpoint;
-    instance.conn.reset(new RGWRESTConn(cct,
+    instance.conn.reset(new S3RESTConn(cct,
                                     sync_env->store,
                                     instance.id,
                                     { instance.conf.s3_endpoint },