21ab4e
From 2cae6c74f4ff8a26d81d12322e4c005f0fd25c20 Mon Sep 17 00:00:00 2001
21ab4e
From: SonaArora <sarora@redhat.com>
21ab4e
Date: Fri, 6 Jan 2017 14:21:56 +0530
21ab4e
Subject: [PATCH 310/361] cli/geo-rep: Fix geo-rep status detail
21ab4e
21ab4e
Earlier this command works when master and slave volume args are
21ab4e
given. Now it works even when no volume args are given (i.e. 'gluster
21ab4e
volume geo-replication status detail) and also when master volume is given
21ab4e
(i.e.'gluster volume geo-replication <master-vol> status detail').
21ab4e
21ab4e
mainline:
21ab4e
> BUG: 1410071
21ab4e
> Reviewed-on: http://review.gluster.org/16347
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
21ab4e
> Tested-by: Kotresh HR <khiremat@redhat.com>
21ab4e
(cherry picked from commit fc5f52889edb83d3f4692fe51d2c1f942851a345)
21ab4e
21ab4e
BUG: 843838
21ab4e
Change-Id: I1a39241a4a5d70c20b2326599b3cccd8f1f6dc78
21ab4e
Signed-off-by: SonaArora <sarora@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/101290
21ab4e
Tested-by: Milind Changire <mchangir@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 cli/src/cli-cmd-parser.c | 40 ++++++++++++++++++----------------------
21ab4e
 1 file changed, 18 insertions(+), 22 deletions(-)
21ab4e
21ab4e
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
21ab4e
index 4b97623..2e61c3a 100644
21ab4e
--- a/cli/src/cli-cmd-parser.c
21ab4e
+++ b/cli/src/cli-cmd-parser.c
21ab4e
@@ -2852,23 +2852,22 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
21ab4e
                 cmdi = slavei + 1;
21ab4e
                 if (slavei == 3)
21ab4e
                         masteri = 2;
21ab4e
-        } else if (i <= 3) {
21ab4e
-                if (!strcmp ((char *)words[wordcount-1], "detail")) {
21ab4e
-                        /* For status detail it is mandatory to provide
21ab4e
-                         * both master and slave */
21ab4e
-                        ret = -1;
21ab4e
-                        goto out;
21ab4e
+        } else if (i <= 4) {
21ab4e
+                if (strtail ("detail", (char *)words[wordcount-1])) {
21ab4e
+                        cmdi = wordcount - 2;
21ab4e
+                        if (i == 4)
21ab4e
+                                masteri = 2;
21ab4e
+                } else {
21ab4e
+                        /* no $s, can only be status cmd
21ab4e
+                         * (with either a single $m before it or nothing)
21ab4e
+                         * -- these conditions imply that i <= 3 after
21ab4e
+                         * the iteration and that i is the successor of
21ab4e
+                         * the (0 or 1 length) sequence of $m-s.
21ab4e
+                         */
21ab4e
+                        cmdi = i;
21ab4e
+                        if (i == 3)
21ab4e
+                                masteri = 2;
21ab4e
                 }
21ab4e
-
21ab4e
-                /* no $s, can only be status cmd
21ab4e
-                 * (with either a single $m before it or nothing)
21ab4e
-                 * -- these conditions imply that i <= 3 after
21ab4e
-                 * the iteration and that i is the successor of
21ab4e
-                 * the (0 or 1 length) sequence of $m-s.
21ab4e
-                 */
21ab4e
-                cmdi = i;
21ab4e
-                if (i == 3)
21ab4e
-                        masteri = 2;
21ab4e
         } else
21ab4e
                 goto out;
21ab4e
 
21ab4e
@@ -2933,15 +2932,12 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
21ab4e
         if (ret)
21ab4e
                 goto out;
21ab4e
 
21ab4e
-        if (!strcmp ((char *)words[wordcount-1], "detail")) {
21ab4e
-                if (strcmp ((char *)words[wordcount-2], "status")) {
21ab4e
-                        ret = -1;
21ab4e
-                        goto out;
21ab4e
-                }
21ab4e
-                if (!slavei || !masteri) {
21ab4e
+        if (strtail ("detail", (char *)words[wordcount-1])) {
21ab4e
+                if (!strtail ("status", (char *)words[wordcount-2])) {
21ab4e
                         ret = -1;
21ab4e
                         goto out;
21ab4e
                 }
21ab4e
+
21ab4e
                 ret = dict_set_uint32 (dict, "status-detail", _gf_true);
21ab4e
                 if (ret)
21ab4e
                         goto out;
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e