]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make RGWSyncModule classes for AWS
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 22 Feb 2017 12:35:28 +0000 (13:35 +0100)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:03:10 +0000 (08:03 -0700)
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_sync_module_aws.cc

index 33dc0f548f2892457a92cf452e526800429e48ca..c40b9fa19dbbe4cb5a81d31d0b66d6b9cce675cf 100644 (file)
@@ -68,3 +68,79 @@ public:
     }
   }
 };
+
+class RGWAWSHandleRemoteObjCR : public RGWCallStatRemoteObjCR {
+  const AWSConfig& conf;
+public:
+  RGWAWSHandleRemoteObjCR(RGWDataSyncEnv *_sync_env,
+                              RGWBucketInfo& _bucket_info, rgw_obj_key& _key,
+                              const AWSConfig& _conf) : RGWCallStatRemoteObjCR(_sync_env, _bucket_info, _key),
+                                                            conf(_conf) {
+  }
+
+  ~RGWAWSHandleRemoteObjCR() {}
+
+  RGWStatRemoteObjCBCR *allocate_callback() override {
+    return new RGWAWSHandleRemoteObjCBCR(sync_env, bucket_info, key, conf);
+  }
+};
+
+
+class RGWAWSDataSyncModule: public RGWDataSyncModule {
+  AWSConfig conf;
+public:
+  RGWAWSDataSyncModule(CephContext *cct, const string& s3_endpoint, const string& access_key, const string& secret){
+    conf.id = string("s3:") + s3_endpoint;
+    // TODO: modify restconn class to accept user spec. keys
+    conf.conn = new RGWRESTConn(cct,
+                                nullptr, // we don't need a rados store handle for this client
+                                conf.id,
+                                { s3_endpoint });
+  }
+
+  ~RGWAWSDataSyncModule() {
+    delete conf.conn;
+  }
+    RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, uint64_t versioned_epoch) override {
+    ldout(sync_env->cct, 0) << conf.id << ": sync_object: b=" << bucket_info.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch << dendl;
+    return new RGWAWSHandleRemoteObjCR(sync_env, bucket_info, key, conf);
+  }
+  RGWCoroutine *remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime, bool versioned, uint64_t versioned_epoch) override {
+    ldout(sync_env->cct, 0) <<"AWS Not implemented: rm_object: b=" << bucket_info.bucket << " k=" << key << " mtime=" << mtime << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl;
+    return NULL;
+  }
+  RGWCoroutine *create_delete_marker(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime,
+                                     rgw_bucket_entry_owner& owner, bool versioned, uint64_t versioned_epoch) override {
+    ldout(sync_env->cct, 0) <<"AWS Not implemented: create_delete_marker: b=" << bucket_info.bucket << " k=" << key << " mtime=" << mtime
+                            << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl;
+    return NULL;
+  }
+};
+
+class RGWAWSSyncModuleInstance : public RGWSyncModuleInstance {
+  RGWAWSDataSyncModule data_handler;
+public:
+  RGWAWSSyncModuleInstance(CephContext *cct, const string& s3_endpoint, const string& access_key, const string& secret) : data_handler(cct, s3_endpoint, access_key, secret) {}
+  RGWDataSyncModule *get_data_handler() override {
+    return &data_handler;
+  }
+};
+
+int RGWAWSSyncModule::create_instance(CephContext *cct, map<string, string>& config,  RGWSyncModuleInstanceRef *instance){
+  string s3_endpoint, access_key, secret;
+  auto i = config.find("s3_endpoint");
+  if (i != config.end())
+    s3_endpoint = i->second;
+
+  i = config.find("access_key");
+  if (i != config.end())
+    access_key = i->second;
+
+  i = config.find("secret");
+  if (i != config.end())
+    secret = i->second;
+
+    // maybe we should just pass dictionaries around?
+  instance->reset(new RGWAWSSyncModuleInstance(cct, s3_endpoint, access_key, secret));
+
+}