summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2015-01-07 21:56:58 +0530
committerVijay Bellur <vbellur@redhat.com>2015-02-02 12:19:07 -0800
commit52765ad94f233e4b4e57515e49f5b7c9e7c08b43 (patch)
treebadad9a91e6a45e54205d3bc7941c305bf903c5a
parent63f17d66258bca46532fe649bbb76a5e5948f22b (diff)
geo-rep: Adding Slave user field to georep status
New column introduced in Status output, "SLAVE USER", Slave user is not "root" in non root Geo-replication setup. Added additional tag in XML output <slave_user> BUG: 1180459 Change-Id: Ia48a5a8eb892ce883b9ec114be7bb2d46eff8535 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/9409 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Tested-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--cli/src/cli-rpc-ops.c32
-rw-r--r--cli/src/cli-xml-output.c13
-rw-r--r--rpc/rpc-lib/src/protocol-common.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c22
4 files changed, 47 insertions, 21 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index c26e1bbbd8d..bd133d0ba82 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -4027,18 +4027,19 @@ get_struct_variable (int mem_num, gf_gsync_status_t *sts_val)
case 0: return (sts_val->node);
case 1: return (sts_val->master);
case 2: return (sts_val->brick);
- case 3: return (sts_val->slave_node);
- case 4: return (sts_val->worker_status);
- case 5: return (sts_val->checkpoint_status);
- case 6: return (sts_val->crawl_status);
- case 7: return (sts_val->files_syncd);
- case 8: return (sts_val->files_remaining);
- case 9: return (sts_val->bytes_remaining);
- case 10: return (sts_val->purges_remaining);
- case 11: return (sts_val->total_files_skipped);
- case 12: return (sts_val->brick_host_uuid);
- case 13: return (sts_val->slavekey);
- case 14: return (sts_val->session_slave);
+ case 3: return (sts_val->slave_user);
+ case 4: return (sts_val->slave_node);
+ case 5: return (sts_val->worker_status);
+ case 6: return (sts_val->checkpoint_status);
+ case 7: return (sts_val->crawl_status);
+ case 8: return (sts_val->files_syncd);
+ case 9: return (sts_val->files_remaining);
+ case 10: return (sts_val->bytes_remaining);
+ case 11: return (sts_val->purges_remaining);
+ case 12: return (sts_val->total_files_skipped);
+ case 13: return (sts_val->brick_host_uuid);
+ case 14: return (sts_val->slavekey);
+ case 15: return (sts_val->session_slave);
default:
goto out;
}
@@ -4056,7 +4057,7 @@ gf_cli_print_status (char **title_values,
int i = 0;
int j = 0;
int ret = 0;
- int status_fields = 6; /* Indexed at 0 */
+ int status_fields = 7; /* Indexed at 0 */
int total_spacing = 0;
char **output_values = NULL;
char *tmp = NULL;
@@ -4218,12 +4219,13 @@ gf_cli_gsync_status_output (dict_t *dict, gf_boolean_t is_detail)
int i = 0;
int ret = 0;
int spacing[13] = {0};
- int num_of_fields = 12;
+ int num_of_fields = 13;
char errmsg[1024] = "";
char *master = NULL;
char *slave = NULL;
char *title_values[] = {"MASTER NODE", "MASTER VOL",
- "MASTER BRICK", "SLAVE",
+ "MASTER BRICK", "SLAVE USER",
+ "SLAVE",
"STATUS", "CHECKPOINT STATUS",
"CRAWL STATUS", "FILES SYNCD",
"FILES PENDING", "BYTES PENDING",
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index dcce53901f4..b4c72eaa84e 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -3909,8 +3909,8 @@ cli_xml_output_vol_gsync_status (dict_t *dict,
int i = 1;
int j = 0;
int count = 0;
- const int number_of_fields = 12;
- const int number_of_basic_fields = 7;
+ const int number_of_fields = 13;
+ const int number_of_basic_fields = 8;
int closed = 1;
int session_closed = 1;
gf_gsync_status_t **status_values = NULL;
@@ -3924,6 +3924,7 @@ cli_xml_output_vol_gsync_status (dict_t *dict,
char *title_values[] = {"master_node",
"master_node_uuid",
"master_brick",
+ "slave_user",
"slave",
"status",
"checkpoint_status",
@@ -4006,7 +4007,7 @@ cli_xml_output_vol_gsync_status (dict_t *dict,
session_closed = 0;
- tmp = get_struct_variable (14, status_values[i]);
+ tmp = get_struct_variable (15, status_values[i]);
if (!tmp) {
gf_log ("cli", GF_LOG_ERROR,
"struct member empty.");
@@ -4031,7 +4032,7 @@ cli_xml_output_vol_gsync_status (dict_t *dict,
// Displaying the master_node uuid as second field
if (j == 1)
- tmp = get_struct_variable (12,
+ tmp = get_struct_variable (13,
status_values[i]);
else
tmp = get_struct_variable (j, status_values[i]);
@@ -4052,8 +4053,8 @@ cli_xml_output_vol_gsync_status (dict_t *dict,
XML_RET_CHECK_AND_GOTO (ret, out);
if (i+1 < count) {
- slave = get_struct_variable (13, status_values[i]);
- slave_next = get_struct_variable (13,
+ slave = get_struct_variable (14, status_values[i]);
+ slave_next = get_struct_variable (14,
status_values[i+1]);
volume = get_struct_variable (1, status_values[i]);
volume_next = get_struct_variable (1,
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 9ff9857bc82..12118721407 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -241,6 +241,7 @@ struct gf_gsync_detailed_status_ {
char node[NAME_MAX];
char master[NAME_MAX];
char brick[NAME_MAX];
+ char slave_user[NAME_MAX];
char slave_node[NAME_MAX];
char worker_status[NAME_MAX];
char checkpoint_status[NAME_MAX];
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index f75f7261ca1..c53f027def1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -3487,6 +3487,10 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
dict_t *confd = NULL;
char *slavekey = NULL;
char *slaveentry = NULL;
+ char *slaveuser = NULL;
+ char *saveptr = NULL;
+ char *temp = NULL;
+ char *temp_inp = NULL;
char *brick_host_uuid = NULL;
int brick_host_uuid_length = 0;
int gsync_count = 0;
@@ -3718,10 +3722,27 @@ store_status:
GF_FREE (sts_val);
goto out;
}
+
+
memcpy (sts_val->session_slave, slaveentry,
strlen(slaveentry));
sts_val->session_slave[strlen(slaveentry)] = '\0';
+ temp_inp = gf_strdup(slaveentry);
+ if (!temp_inp)
+ goto out;
+
+ if (strstr(temp_inp, "@") == NULL) {
+ slaveuser = "root";
+ } else {
+ temp = strtok_r(temp_inp, "//", &saveptr);
+ temp = strtok_r(NULL, "/", &saveptr);
+ slaveuser = strtok_r(temp, "@", &saveptr);
+ }
+ memcpy (sts_val->slave_user, slaveuser,
+ strlen(slaveuser));
+ sts_val->slave_user[strlen(slaveuser)] = '\0';
+
snprintf (sts_val_name, sizeof (sts_val_name), "status_value%d", gsync_count);
ret = dict_set_bin (dict, sts_val_name, sts_val, sizeof(gf_gsync_status_t));
if (ret) {
@@ -3738,6 +3759,7 @@ store_status:
goto out;
out:
+ GF_FREE (temp_inp);
dict_unref (confd);
return 0;