diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/cloudsync/src/cloudsync.c | 54 | ||||
-rw-r--r-- | xlators/features/cloudsync/src/cloudsync.h | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 |
3 files changed, 59 insertions, 6 deletions
diff --git a/xlators/features/cloudsync/src/cloudsync.c b/xlators/features/cloudsync/src/cloudsync.c index 48e27c372b6..e14fc544957 100644 --- a/xlators/features/cloudsync/src/cloudsync.c +++ b/xlators/features/cloudsync/src/cloudsync.c @@ -34,15 +34,27 @@ cs_cleanup_private (cs_private_t *priv) return; } +struct cs_plugin plugins[] = { + { + .name = "amazons3", + .library = "libamazons3.so", + .description = "amazon s3 store." + }, + + {.name = NULL}, +}; + int cs_init (xlator_t *this) { cs_private_t *priv = NULL; gf_boolean_t per_vol = _gf_false; int ret = 0; - char *libpath = ("libaws.so"); + char *libpath = NULL; store_methods_t *store_methods = NULL; void *handle = NULL; + char *temp_str = NULL; + int index = 0; priv = GF_CALLOC (1, sizeof (*priv), gf_cs_mt_cs_private_t); if (!priv) { @@ -66,7 +78,25 @@ cs_init (xlator_t *this) per_vol = _gf_true; if (per_vol) { - /*TODO:Need to make it configurable. This is a temp workaround*/ + if (dict_get_str (this->options, "cloudsync-storetype", + &temp_str) == 0) { + for (index = 0; plugins[index].name; index++) { + if (!strcmp (temp_str, plugins[index].name)) { + libpath = plugins[index].library; + break; + } + } + } else { + ret = 0; + } + + if (!libpath) { + gf_msg (this->name, GF_LOG_WARNING, 0, 0, + "no plugin enabled"); + ret = 0; + goto out; + } + handle = dlopen (libpath, RTLD_NOW); if (!handle) { gf_msg (this->name, GF_LOG_ERROR, 0, 0, "could not load" @@ -848,15 +878,23 @@ cs_download_task (void *arg) priv = this->private; - local = frame->local; - retval = GF_CALLOC (1, sizeof(int), gf_common_mt_int); if (!retval) { - gf_log (this->name, GF_LOG_ERROR, "insufficient memory"); + gf_msg (this->name, GF_LOG_ERROR, 0, 0, "insufficient memory"); + ret = -1; + goto out; + } + + if (!priv->stores) { + gf_msg (this->name, GF_LOG_ERROR, 0, 0, "No remote store " + "plugins found"); ret = -1; goto out; } + local = frame->local; + + if (local->fd) fd = fd_anonymous (local->fd->inode); else @@ -1656,7 +1694,11 @@ struct xlator_dumpops cs_dumpops = { }; struct volume_options cs_options[] = { - { .key = {NULL} }, + { .key = {"cloudsync-storetype"}, + .type = GF_OPTION_TYPE_STR, + .description = "Defines which remote store is enabled" + }, + { .key = {NULL} }, }; xlator_api_t xlator_api = { diff --git a/xlators/features/cloudsync/src/cloudsync.h b/xlators/features/cloudsync/src/cloudsync.h index bd54d760864..18840a6523d 100644 --- a/xlators/features/cloudsync/src/cloudsync.h +++ b/xlators/features/cloudsync/src/cloudsync.h @@ -34,6 +34,12 @@ typedef struct cs_inode_ctx { gf_cs_obj_state state; } cs_inode_ctx_t; +struct cs_plugin { + char *name; /* store name */ + char *library; /* library to load for the given store */ + char *description; /* description about the store */ +}; + cs_local_t * cs_local_init (xlator_t *this, call_frame_t *frame, loc_t *loc, fd_t *fd, glusterfs_fop_t fop); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 0f4df92f07d..4fbc45d7cb3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -3821,6 +3821,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { .description = "enable/disable utime translator on the volume.", .flags = VOLOPT_FLAG_CLIENT_OPT | VOLOPT_FLAG_XLATOR_OPT }, + { .key = "feature.cloudsync-storetype", + .voltype = "features/cloudsync", + .op_version = GD_OP_VERSION_4_1_0, + .flags = VOLOPT_FLAG_CLIENT_OPT + }, { .key = NULL } }; |