From: Abhishek Lekshmanan Date: Wed, 22 Feb 2017 12:35:28 +0000 (+0100) Subject: rgw: make RGWSyncModule classes for AWS X-Git-Tag: v13.1.0~270^2~124 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5ad873af6a1cc667d001a47a436f2a35cb1803d7;p=ceph.git rgw: make RGWSyncModule classes for AWS Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_sync_module_aws.cc b/src/rgw/rgw_sync_module_aws.cc index 33dc0f548f28..c40b9fa19dbb 100644 --- a/src/rgw/rgw_sync_module_aws.cc +++ b/src/rgw/rgw_sync_module_aws.cc @@ -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& 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)); + +}