|
|
3604df |
From 73effb9f22fad8ee6084521c62566b5b4a46792c Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Aravinda VK <avishwan@redhat.com>
|
|
|
3604df |
Date: Wed, 3 Aug 2016 12:16:43 +0530
|
|
|
3604df |
Subject: [PATCH 33/86] eventsapi: Geo-replication User driven events
|
|
|
3604df |
|
|
|
3604df |
Following Geo-replication Events are added
|
|
|
3604df |
|
|
|
3604df |
GEOREP_CREATE/GEOREP_START/GEOREP_STOP/GEOREP_DELETE/GEOREP_PAUSE/GEOREP_RESUME
|
|
|
3604df |
{
|
|
|
3604df |
"nodeid": NODEID,
|
|
|
3604df |
"ts": TIMESTAMP,
|
|
|
3604df |
"event": EVENT_TYPE,
|
|
|
3604df |
"message": {
|
|
|
3604df |
"master": MASTER_VOLUME_NAME,
|
|
|
3604df |
"slave": SLAVE_DETAILS
|
|
|
3604df |
}
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
GEOREP_CONFIG_SET
|
|
|
3604df |
{
|
|
|
3604df |
"nodeid": NODEID,
|
|
|
3604df |
"ts": TIMESTAMP,
|
|
|
3604df |
"event": GEOREP_CONFIG_SET,
|
|
|
3604df |
"message": {
|
|
|
3604df |
"master": MASTER_VOLUME_NAME,
|
|
|
3604df |
"slave": SLAVE_DETAILS,
|
|
|
3604df |
"option": OPTION_NAME,
|
|
|
3604df |
"value": OPTION_VALUE
|
|
|
3604df |
}
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
GEOREP_CONFIG_RESET
|
|
|
3604df |
{
|
|
|
3604df |
"nodeid": NODEID,
|
|
|
3604df |
"ts": TIMESTAMP,
|
|
|
3604df |
"event": GEOREP_CONFIG_RESET,
|
|
|
3604df |
"message": {
|
|
|
3604df |
"master": MASTER_VOLUME_NAME,
|
|
|
3604df |
"slave": SLAVE_DETAILS,
|
|
|
3604df |
"option": OPTION_NAME
|
|
|
3604df |
}
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
> Reviewed-on: http://review.gluster.org/15077
|
|
|
3604df |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
|
|
|
3604df |
|
|
|
3604df |
BUG: 1361118
|
|
|
3604df |
Change-Id: I78c81aabd022ebb042b3eae3c6b5a284a6c2801f
|
|
|
3604df |
Signed-off-by: Aravinda VK <avishwan@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/84739
|
|
|
3604df |
Reviewed-by: Milind Changire <mchangir@redhat.com>
|
|
|
3604df |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
cli/src/cli-cmd-volume.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
3604df |
events/eventskeygen.py | 9 +++
|
|
|
3604df |
2 files changed, 134 insertions(+), 0 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
|
|
|
3604df |
index 4202622..7e53514 100644
|
|
|
3604df |
--- a/cli/src/cli-cmd-volume.c
|
|
|
3604df |
+++ b/cli/src/cli-cmd-volume.c
|
|
|
3604df |
@@ -1958,6 +1958,14 @@ cli_cmd_volume_gsync_set_cbk (struct cli_state *state, struct cli_cmd_word *word
|
|
|
3604df |
rpc_clnt_procedure_t *proc = NULL;
|
|
|
3604df |
call_frame_t *frame = NULL;
|
|
|
3604df |
cli_local_t *local = NULL;
|
|
|
3604df |
+#if (USE_EVENTS)
|
|
|
3604df |
+ int ret1 = -1;
|
|
|
3604df |
+ int cmd_type = -1;
|
|
|
3604df |
+ int tmpi = 0;
|
|
|
3604df |
+ char *tmp = NULL;
|
|
|
3604df |
+ char *events_str = NULL;
|
|
|
3604df |
+ int event_type = -1;
|
|
|
3604df |
+#endif
|
|
|
3604df |
|
|
|
3604df |
proc = &cli_rpc_prog->proctable [GLUSTER_CLI_GSYNC_SET];
|
|
|
3604df |
|
|
|
3604df |
@@ -1983,6 +1991,123 @@ out:
|
|
|
3604df |
if (ret && parse_err == 0)
|
|
|
3604df |
cli_out (GEOREP" command failed");
|
|
|
3604df |
|
|
|
3604df |
+#if (USE_EVENTS)
|
|
|
3604df |
+ if (ret == 0) {
|
|
|
3604df |
+ events_str = gf_strdup ("");
|
|
|
3604df |
+
|
|
|
3604df |
+ /* Type of Geo-rep Action - Create, Start etc */
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "type", &cmd_type);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ cmd_type = -1;
|
|
|
3604df |
+
|
|
|
3604df |
+ /* Only capture Events for modification commands */
|
|
|
3604df |
+ switch (cmd_type) {
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_CREATE:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_CREATE;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_START:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_START;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_STOP:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_STOP;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_PAUSE:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_PAUSE;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_RESUME:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_RESUME;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_DELETE:
|
|
|
3604df |
+ event_type = EVENT_GEOREP_DELETE;
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ case GF_GSYNC_OPTION_TYPE_CONFIG:
|
|
|
3604df |
+ ret1 = dict_get_str (options, "subop", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+
|
|
|
3604df |
+ /* For Config Set additionally capture key and value */
|
|
|
3604df |
+ /* For Config Reset capture key */
|
|
|
3604df |
+ if (strcmp (tmp, "set") == 0) {
|
|
|
3604df |
+ event_type = EVENT_GEOREP_CONFIG_SET;
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_str (options, "op_name", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_asprintf (&events_str, "%soption=%s;",
|
|
|
3604df |
+ events_str, tmp);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_str (options, "op_value", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_asprintf (&events_str, "%svalue=%s;",
|
|
|
3604df |
+ events_str, tmp);
|
|
|
3604df |
+ } else if (strcmp (tmp, "del") == 0) {
|
|
|
3604df |
+ event_type = EVENT_GEOREP_CONFIG_RESET;
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_str (options, "op_name", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_asprintf (&events_str, "%soption=%s;",
|
|
|
3604df |
+ events_str, tmp);
|
|
|
3604df |
+ }
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ default:
|
|
|
3604df |
+ break;
|
|
|
3604df |
+ }
|
|
|
3604df |
+
|
|
|
3604df |
+ if (event_type > -1) {
|
|
|
3604df |
+ /* Capture all optional arguments used */
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "force", &tmpi);
|
|
|
3604df |
+ if (ret1 == 0)
|
|
|
3604df |
+ gf_asprintf (&events_str, "%sforce=%d;",
|
|
|
3604df |
+ events_str, tmpi);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "push_pem", &tmpi);
|
|
|
3604df |
+ if (ret1 == 0)
|
|
|
3604df |
+ gf_asprintf (&events_str, "%spush_pem=%d;",
|
|
|
3604df |
+ events_str, tmpi);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "no_verify", &tmpi);
|
|
|
3604df |
+ if (ret1 == 0)
|
|
|
3604df |
+ gf_asprintf (&events_str, "%sno_verify=%d;",
|
|
|
3604df |
+ events_str, tmpi);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "ssh_port", &tmpi);
|
|
|
3604df |
+ if (ret1 == 0)
|
|
|
3604df |
+ gf_asprintf (&events_str, "%sssh_port=%d;",
|
|
|
3604df |
+ events_str, tmpi);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_int32 (options, "reset-sync-time",
|
|
|
3604df |
+ &tmpi);
|
|
|
3604df |
+ if (ret1 == 0)
|
|
|
3604df |
+ gf_asprintf (&events_str,
|
|
|
3604df |
+ "%sreset_sync_time=%d;",
|
|
|
3604df |
+ events_str, tmpi);
|
|
|
3604df |
+
|
|
|
3604df |
+ /* Capture Master and Slave Info */
|
|
|
3604df |
+ ret1 = dict_get_str (options, "master", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+ gf_asprintf (&events_str, "%smaster=%s;",
|
|
|
3604df |
+ events_str, tmp);
|
|
|
3604df |
+
|
|
|
3604df |
+ ret1 = dict_get_str (options, "slave", &tmp);
|
|
|
3604df |
+ if (ret1)
|
|
|
3604df |
+ tmp = "";
|
|
|
3604df |
+ gf_asprintf (&events_str, "%sslave=%s",
|
|
|
3604df |
+ events_str, tmp);
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_event (event_type, "%s", events_str);
|
|
|
3604df |
+ }
|
|
|
3604df |
+
|
|
|
3604df |
+ /* Allocated by gf_strdup and gf_asprintf */
|
|
|
3604df |
+ GF_FREE (events_str);
|
|
|
3604df |
+ }
|
|
|
3604df |
+#endif
|
|
|
3604df |
+
|
|
|
3604df |
CLI_STACK_DESTROY (frame);
|
|
|
3604df |
|
|
|
3604df |
return ret;
|
|
|
3604df |
diff --git a/events/eventskeygen.py b/events/eventskeygen.py
|
|
|
3604df |
index 5bb0319..bccb91a 100644
|
|
|
3604df |
--- a/events/eventskeygen.py
|
|
|
3604df |
+++ b/events/eventskeygen.py
|
|
|
3604df |
@@ -30,6 +30,15 @@ keys = (
|
|
|
3604df |
"EVENT_VOLUME_DELETE",
|
|
|
3604df |
"EVENT_VOLUME_SET",
|
|
|
3604df |
"EVENT_VOLUME_RESET",
|
|
|
3604df |
+
|
|
|
3604df |
+ "EVENT_GEOREP_CREATE",
|
|
|
3604df |
+ "EVENT_GEOREP_START",
|
|
|
3604df |
+ "EVENT_GEOREP_STOP",
|
|
|
3604df |
+ "EVENT_GEOREP_PAUSE",
|
|
|
3604df |
+ "EVENT_GEOREP_RESUME",
|
|
|
3604df |
+ "EVENT_GEOREP_DELETE",
|
|
|
3604df |
+ "EVENT_GEOREP_CONFIG_SET",
|
|
|
3604df |
+ "EVENT_GEOREP_CONFIG_RESET",
|
|
|
3604df |
)
|
|
|
3604df |
|
|
|
3604df |
LAST_EVENT = "EVENT_LAST"
|
|
|
3604df |
--
|
|
|
3604df |
1.7.1
|
|
|
3604df |
|