summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-03-12 07:46:21 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-13 04:45:39 -0700
commit69827bac7215f269a2d29b4b9f9bd86092517d55 (patch)
tree27169411f7beb8f073b087d0d035f490831ea385
parent736fd5d9073d00bd80595afd158b4f1ab2d4c253 (diff)
snapshot : Fix for snapshot info ambiguous output.
Change-Id: I27e50921a2e030ae50b1fd28ee7ab0be65b313fd BUG: 1075454 Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/7228 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
-rw-r--r--cli/src/cli-rpc-ops.c88
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c12
2 files changed, 70 insertions, 30 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 95f8b61..a958286 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -22,6 +22,8 @@
#define VOL_TOP_PERF_SPEED_WIDTH 4
#define VOL_TOP_PERF_TIME_WIDTH 26
+#define INDENT_MAIN_HEAD "%-25s %s "
+
#include "cli.h"
#include "compat-errno.h"
#include "cli-cmd.h"
@@ -7731,6 +7733,7 @@ cli_get_each_volinfo_in_snap (dict_t *dict, char *keyprefix,
int value = 0;
int ret = -1;
char indent[5] = "\t";
+ char *volname = NULL;
GF_ASSERT (dict);
GF_ASSERT (keyprefix);
@@ -7746,7 +7749,8 @@ cli_get_each_volinfo_in_snap (dict_t *dict, char *keyprefix,
gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key);
goto out;
}
- cli_out ("%s%-12s %s", indent, "Volume Name:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent,
+ "Snap Volume Name", ":", get_buffer);
ret = snprintf (key, sizeof (key),
"%s.origin-volname", keyprefix);
@@ -7754,15 +7758,17 @@ cli_get_each_volinfo_in_snap (dict_t *dict, char *keyprefix,
goto out;
}
- ret = dict_get_str (dict, key, &get_buffer);
+ ret = dict_get_str (dict, key, &volname);
if (ret) {
gf_log ("cli", GF_LOG_WARNING, "Failed to get %s", key);
cli_out ("%-12s", "Origin:");
}
- cli_out ("%s%-12s %s", indent, "Origin:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent,
+ "Origin Volume name", ":", volname);
- ret = snprintf (key, sizeof (key),
- "%s.snaps-available", keyprefix);
+
+ ret = snprintf (key, sizeof (key), "%s.snapcount",
+ keyprefix);
if (ret < 0) {
goto out;
}
@@ -7772,20 +7778,24 @@ cli_get_each_volinfo_in_snap (dict_t *dict, char *keyprefix,
gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key);
goto out;
}
- cli_out ("%s%-12s %d", indent, "Available:", value);
- }
+ cli_out ("%s%s %s %s %d", indent, "Snaps taken for",
+ volname, ":", value);
- ret = snprintf (key, sizeof (key), "%s.vol-id", keyprefix);
- if (ret < 0) {
- goto out;
- }
+ ret = snprintf (key, sizeof (key), "%s.snaps-available",
+ keyprefix);
+ if (ret < 0) {
+ goto out;
+ }
- ret = dict_get_str (dict, key, &get_buffer);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key);
- goto out;
+ ret = dict_get_int32 (dict, key, &value);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key);
+ goto out;
+ }
+ cli_out ("%s%s %s %s %d", indent, "Snaps available for",
+ volname, ":", value);
}
- cli_out ("%s%-12s %s", indent, "UUID:", get_buffer);
+
ret = snprintf (key, sizeof (key), "%s.vol-status", keyprefix);
if (ret < 0) {
@@ -7797,7 +7807,8 @@ cli_get_each_volinfo_in_snap (dict_t *dict, char *keyprefix,
gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key);
goto out;
}
- cli_out ("%s%-12s %s", indent, "Status:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent, "Status",
+ ":", get_buffer);
out :
return ret;
}
@@ -7868,7 +7879,23 @@ cli_get_each_snap_info (dict_t *dict, char *prefix_str,
key_buffer);
goto out;
}
- cli_out ("%s%-12s %s", indent, "Snapshot:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent, "Snapshot",
+ ":", get_buffer);
+
+ ret = snprintf (key_buffer, sizeof (key_buffer), "%s.snap-id",
+ prefix_str);
+ if (ret < 0 ) {
+ goto out;
+ }
+
+ ret = dict_get_str (dict, key_buffer, &get_buffer);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Unable to fetch snap-id %s ",
+ key_buffer);
+ goto out;
+ }
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent, "Snap UUID",
+ ":", get_buffer);
ret = snprintf (key_buffer, sizeof (key_buffer), "%s.snap-desc",
prefix_str);
@@ -7879,7 +7906,8 @@ cli_get_each_snap_info (dict_t *dict, char *prefix_str,
ret = dict_get_str (dict, key_buffer, &get_buffer);
if (!ret) {
/* Ignore error for description */
- cli_out ("%s%-12s %s", indent, "Desc:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent,
+ "Description", ":", get_buffer);
}
ret = snprintf (key_buffer, sizeof (key_buffer), "%s.snap-time",
@@ -7894,10 +7922,11 @@ cli_get_each_snap_info (dict_t *dict, char *prefix_str,
prefix_str);
goto out;
}
- cli_out ("%s%-12s %s", indent, "Created:", get_buffer);
+ cli_out ("%s" INDENT_MAIN_HEAD "%s", indent, "Created",
+ ":", get_buffer);
if (snap_driven) {
- cli_out ("%-12s", "Volumes:");
+ cli_out ("%-12s", "Snap Volumes:\n");
ret = cli_get_volinfo_in_snap (dict, prefix_str);
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Unable to list details "
@@ -7948,6 +7977,7 @@ cli_get_snaps_in_volume (dict_t *dict) {
int ret = -1;
int i = 0;
int count = 0;
+ int avail = 0;
char key[PATH_MAX] = "";
char *get_buffer = NULL;
@@ -7958,21 +7988,23 @@ cli_get_snaps_in_volume (dict_t *dict) {
gf_log ("cli", GF_LOG_ERROR, "Could not fetch origin-volname");
goto out;
}
- cli_out ("%-12s %s", "Volume Name:", get_buffer);
+ cli_out (INDENT_MAIN_HEAD "%s", "Volume Name", ":", get_buffer);
- ret = dict_get_int32 (dict, "snaps-available", &count);
+ ret = dict_get_int32 (dict, "snap-count", &avail);
if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Could not fetch snaps-available");
+ gf_log ("cli", GF_LOG_ERROR, "Could not fetch snap-count");
goto out;
}
- cli_out ("%-12s %d", "Available:", count);
+ cli_out (INDENT_MAIN_HEAD "%d", "Snaps Taken", ":", avail);
- ret = dict_get_int32 (dict, "snap-count", &count);
+ ret = dict_get_int32 (dict, "snaps-available", &count);
if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Could not fetch snap-count");
+ gf_log ("cli", GF_LOG_ERROR, "Could not fetch snaps-available");
goto out;
}
- for (i = 1 ; i <= count ; i++) {
+ cli_out (INDENT_MAIN_HEAD "%d", "Snaps Available", ":", count);
+
+ for (i = 1 ; i <= avail ; i++) {
snprintf (key, sizeof (key), "snap%d", i);
ret = cli_get_each_snap_info (dict, key, _gf_false);
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index c9c23bf..17c31d8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -1386,8 +1386,6 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
goto out;
}
- if (!detail)
- goto out;
ret = glusterd_volinfo_find (snap_vol->parent_volname, &origin_vol);
if (ret) {
@@ -1422,6 +1420,16 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
goto out;
}
+ snprintf (key, sizeof (key), "%s.snapcount", keyprefix);
+ ret = dict_set_int32 (dict, key, origin_vol->snap_count);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Could not save snapcount");
+ goto out;
+ }
+
+ if (!detail)
+ goto out;
+
/* Parent volume name */
value = gf_strdup (snap_vol->parent_volname);
if (!value)