summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-08-03 12:16:43 +0530
committerAravinda VK <avishwan@redhat.com>2016-08-04 02:00:49 -0700
commit3b4c9e525e931a703cc526b3fbe27ee86f2fd70a (patch)
tree76fa0fadf6ba4730a5e4861b9efa4afb01e55f71 /cli
parent67ebde53ea26065d41cacf054fa4337c22de5903 (diff)
eventsapi: Geo-replication User driven events
Following Geo-replication Events are added GEOREP_CREATE/GEOREP_START/GEOREP_STOP/GEOREP_DELETE/GEOREP_PAUSE/GEOREP_RESUME { "nodeid": NODEID, "ts": TIMESTAMP, "event": EVENT_TYPE, "message": { "master": MASTER_VOLUME_NAME, "slave": SLAVE_DETAILS } } GEOREP_CONFIG_SET { "nodeid": NODEID, "ts": TIMESTAMP, "event": GEOREP_CONFIG_SET, "message": { "master": MASTER_VOLUME_NAME, "slave": SLAVE_DETAILS, "option": OPTION_NAME, "value": OPTION_VALUE } } GEOREP_CONFIG_RESET { "nodeid": NODEID, "ts": TIMESTAMP, "event": GEOREP_CONFIG_RESET, "message": { "master": MASTER_VOLUME_NAME, "slave": SLAVE_DETAILS, "option": OPTION_NAME } } BUG: 1363591 Change-Id: I78c81aabd022ebb042b3eae3c6b5a284a6c2801f Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15077 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 77635b76530..b7f95f3ae7b 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1950,6 +1950,14 @@ cli_cmd_volume_gsync_set_cbk (struct cli_state *state, struct cli_cmd_word *word
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
cli_local_t *local = NULL;
+#if (USE_EVENTS)
+ int ret1 = -1;
+ int cmd_type = -1;
+ int tmpi = 0;
+ char *tmp = NULL;
+ char *events_str = NULL;
+ int event_type = -1;
+#endif
proc = &cli_rpc_prog->proctable [GLUSTER_CLI_GSYNC_SET];
@@ -1975,6 +1983,123 @@ out:
if (ret && parse_err == 0)
cli_out (GEOREP" command failed");
+#if (USE_EVENTS)
+ if (ret == 0) {
+ events_str = gf_strdup ("");
+
+ /* Type of Geo-rep Action - Create, Start etc */
+ ret1 = dict_get_int32 (options, "type", &cmd_type);
+ if (ret1)
+ cmd_type = -1;
+
+ /* Only capture Events for modification commands */
+ switch (cmd_type) {
+ case GF_GSYNC_OPTION_TYPE_CREATE:
+ event_type = EVENT_GEOREP_CREATE;
+ break;
+ case GF_GSYNC_OPTION_TYPE_START:
+ event_type = EVENT_GEOREP_START;
+ break;
+ case GF_GSYNC_OPTION_TYPE_STOP:
+ event_type = EVENT_GEOREP_STOP;
+ break;
+ case GF_GSYNC_OPTION_TYPE_PAUSE:
+ event_type = EVENT_GEOREP_PAUSE;
+ break;
+ case GF_GSYNC_OPTION_TYPE_RESUME:
+ event_type = EVENT_GEOREP_RESUME;
+ break;
+ case GF_GSYNC_OPTION_TYPE_DELETE:
+ event_type = EVENT_GEOREP_DELETE;
+ break;
+ case GF_GSYNC_OPTION_TYPE_CONFIG:
+ ret1 = dict_get_str (options, "subop", &tmp);
+ if (ret1)
+ tmp = "";
+
+ /* For Config Set additionally capture key and value */
+ /* For Config Reset capture key */
+ if (strcmp (tmp, "set") == 0) {
+ event_type = EVENT_GEOREP_CONFIG_SET;
+
+ ret1 = dict_get_str (options, "op_name", &tmp);
+ if (ret1)
+ tmp = "";
+
+ gf_asprintf (&events_str, "%soption=%s;",
+ events_str, tmp);
+
+ ret1 = dict_get_str (options, "op_value", &tmp);
+ if (ret1)
+ tmp = "";
+
+ gf_asprintf (&events_str, "%svalue=%s;",
+ events_str, tmp);
+ } else if (strcmp (tmp, "del") == 0) {
+ event_type = EVENT_GEOREP_CONFIG_RESET;
+
+ ret1 = dict_get_str (options, "op_name", &tmp);
+ if (ret1)
+ tmp = "";
+
+ gf_asprintf (&events_str, "%soption=%s;",
+ events_str, tmp);
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (event_type > -1) {
+ /* Capture all optional arguments used */
+ ret1 = dict_get_int32 (options, "force", &tmpi);
+ if (ret1 == 0)
+ gf_asprintf (&events_str, "%sforce=%d;",
+ events_str, tmpi);
+
+ ret1 = dict_get_int32 (options, "push_pem", &tmpi);
+ if (ret1 == 0)
+ gf_asprintf (&events_str, "%spush_pem=%d;",
+ events_str, tmpi);
+
+ ret1 = dict_get_int32 (options, "no_verify", &tmpi);
+ if (ret1 == 0)
+ gf_asprintf (&events_str, "%sno_verify=%d;",
+ events_str, tmpi);
+
+ ret1 = dict_get_int32 (options, "ssh_port", &tmpi);
+ if (ret1 == 0)
+ gf_asprintf (&events_str, "%sssh_port=%d;",
+ events_str, tmpi);
+
+ ret1 = dict_get_int32 (options, "reset-sync-time",
+ &tmpi);
+ if (ret1 == 0)
+ gf_asprintf (&events_str,
+ "%sreset_sync_time=%d;",
+ events_str, tmpi);
+
+ /* Capture Master and Slave Info */
+ ret1 = dict_get_str (options, "master", &tmp);
+ if (ret1)
+ tmp = "";
+ gf_asprintf (&events_str, "%smaster=%s;",
+ events_str, tmp);
+
+ ret1 = dict_get_str (options, "slave", &tmp);
+ if (ret1)
+ tmp = "";
+ gf_asprintf (&events_str, "%sslave=%s",
+ events_str, tmp);
+
+ gf_event (event_type, "%s", events_str);
+ }
+
+ /* Allocated by gf_strdup and gf_asprintf */
+ GF_FREE (events_str);
+ }
+#endif
+
CLI_STACK_DESTROY (frame);
return ret;