diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-07-19 17:28:14 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2016-07-28 03:14:18 -0700 |
commit | 7e00626b0dcd04b4f38d7cb1a3288ba6740ed9b6 (patch) | |
tree | 20cea0bd79bdd9f364ce460410008acc769b6e8f /cli | |
parent | ec6925a379c7bee071df1638bc2751b266cee346 (diff) |
eventsapi: Volume Set and Reset Events
Example of published data for Volume Set:
{
"nodeid": NODEID,
"ts": TIMESTAMP,
"event": "VOLUME_SET",
"message": {
"name": VOLUME_NAME,
"options": [[KEY1, VALUE1], [KEY2, VALUE2],..]
}
}
Example of published data for Volume Reset:
{
"nodeid": NODEID,
"ts": TIMESTAMP,
"event": "VOLUME_RESET",
"message": {
"name": VOLUME_NAME,
"option": KEY
}
}
BUG: 1358671
Change-Id: If30cc95396459b2a9993b3412ee6d05d27f6a86a
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/14973
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 6d44095d757..af815da51ef 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -665,6 +665,10 @@ cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word, call_frame_t *frame = NULL; dict_t *options = NULL; cli_local_t *local = NULL; +#if (USE_EVENTS) + int ret1 = -1; + char *tmp_opt = NULL; +#endif proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RESET_VOLUME]; @@ -692,6 +696,18 @@ out: cli_out ("Volume reset failed"); } +#if (USE_EVENTS) + if (ret == 0) { + ret1 = dict_get_str (options, "key", &tmp_opt); + if (ret1) + tmp_opt = ""; + + gf_event (EVENT_VOLUME_RESET, "name=%s;option=%s", + (char *)words[2], + tmp_opt); + } +#endif + CLI_STACK_DESTROY (frame); return ret; @@ -758,6 +774,15 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, cli_local_t *local = NULL; char *op_errstr = NULL; +#if (USE_EVENTS) + int ret1 = -1; + int i = 1; + char dict_key[50] = {0,}; + char *tmp_opt = NULL; + char *opts_str = NULL; + int num_options = 0; +#endif + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SET_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); @@ -790,6 +815,43 @@ out: cli_out ("Volume set failed"); } +#if (USE_EVENTS) + if (ret == 0) { + ret1 = dict_get_int32 (options, "count", &num_options); + if (ret1) + num_options = 0; + else + num_options = num_options/2; + + /* Initialize opts_str */ + opts_str = gf_strdup (""); + + /* Prepare String in format options=KEY1,VALUE1,KEY2,VALUE2 */ + for (i = 1; i <= num_options; i++) { + sprintf (dict_key, "key%d", i); + ret1 = dict_get_str (options, dict_key, &tmp_opt); + if (ret1) + tmp_opt = ""; + + gf_asprintf (&opts_str, "%s,%s", opts_str, tmp_opt); + + sprintf (dict_key, "value%d", i); + ret1 = dict_get_str (options, dict_key, &tmp_opt); + if (ret1) + tmp_opt = ""; + + gf_asprintf (&opts_str, "%s,%s", opts_str, tmp_opt); + } + + gf_event (EVENT_VOLUME_SET, "name=%s;options=%s", + (char *)words[2], + opts_str); + + /* Allocated by gf_strdup and gf_asprintf */ + GF_FREE (opts_str); + } +#endif + CLI_STACK_DESTROY (frame); return ret; |