Blob Blame History Raw
From 2cae6c74f4ff8a26d81d12322e4c005f0fd25c20 Mon Sep 17 00:00:00 2001
From: SonaArora <sarora@redhat.com>
Date: Fri, 6 Jan 2017 14:21:56 +0530
Subject: [PATCH 310/361] cli/geo-rep: Fix geo-rep status detail

Earlier this command works when master and slave volume args are
given. Now it works even when no volume args are given (i.e. 'gluster
volume geo-replication status detail) and also when master volume is given
(i.e.'gluster volume geo-replication <master-vol> status detail').

mainline:
> BUG: 1410071
> Reviewed-on: http://review.gluster.org/16347
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
> Tested-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit fc5f52889edb83d3f4692fe51d2c1f942851a345)

BUG: 843838
Change-Id: I1a39241a4a5d70c20b2326599b3cccd8f1f6dc78
Signed-off-by: SonaArora <sarora@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/101290
Tested-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 cli/src/cli-cmd-parser.c | 40 ++++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 4b97623..2e61c3a 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -2852,23 +2852,22 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
                 cmdi = slavei + 1;
                 if (slavei == 3)
                         masteri = 2;
-        } else if (i <= 3) {
-                if (!strcmp ((char *)words[wordcount-1], "detail")) {
-                        /* For status detail it is mandatory to provide
-                         * both master and slave */
-                        ret = -1;
-                        goto out;
+        } else if (i <= 4) {
+                if (strtail ("detail", (char *)words[wordcount-1])) {
+                        cmdi = wordcount - 2;
+                        if (i == 4)
+                                masteri = 2;
+                } else {
+                        /* no $s, can only be status cmd
+                         * (with either a single $m before it or nothing)
+                         * -- these conditions imply that i <= 3 after
+                         * the iteration and that i is the successor of
+                         * the (0 or 1 length) sequence of $m-s.
+                         */
+                        cmdi = i;
+                        if (i == 3)
+                                masteri = 2;
                 }
-
-                /* no $s, can only be status cmd
-                 * (with either a single $m before it or nothing)
-                 * -- these conditions imply that i <= 3 after
-                 * the iteration and that i is the successor of
-                 * the (0 or 1 length) sequence of $m-s.
-                 */
-                cmdi = i;
-                if (i == 3)
-                        masteri = 2;
         } else
                 goto out;
 
@@ -2933,15 +2932,12 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
         if (ret)
                 goto out;
 
-        if (!strcmp ((char *)words[wordcount-1], "detail")) {
-                if (strcmp ((char *)words[wordcount-2], "status")) {
-                        ret = -1;
-                        goto out;
-                }
-                if (!slavei || !masteri) {
+        if (strtail ("detail", (char *)words[wordcount-1])) {
+                if (!strtail ("status", (char *)words[wordcount-2])) {
                         ret = -1;
                         goto out;
                 }
+
                 ret = dict_set_uint32 (dict, "status-detail", _gf_true);
                 if (ret)
                         goto out;
-- 
1.8.3.1