summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 58dfc4459..03ebb2e46 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7395,6 +7395,7 @@ out:
/*Function to list the snap "gluster snapshot list" */
static int
list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
+ int64_t snapcount_total = -1 ;
int64_t snapcount = -1 ;
char buffer[PATH_MAX] = "" ;
char *get_buffer = NULL;
@@ -7414,7 +7415,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
* if volume not present then display that volume doesnot exist
* and try to fetch next volume mentioned
*/
- ret = snprintf (buffer, sizeof(buffer), "%s.vol_name", prefix_str);
+ ret = snprintf (buffer, sizeof(buffer), "%s.volname", prefix_str);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7425,10 +7426,10 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
}
cli_out ("Vol Name : %s", get_buffer);
/* if Volume is present then get the snapcount.
- * string is "snaplist.vol{0..}.snap_count.
+ * string is "snaplist.vol{0..}.snap-count.
*/
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap_count", prefix_str);
+ "%s.snap-count", prefix_str);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7439,28 +7440,38 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
}
/* To check if the user has given "-d" option */
- ret = dict_get_int8 (dict_n, "snap_details", &detail);
+ ret = dict_get_int8 (dict_n, "snap-details", &detail);
if (ret) {
gf_log ("",GF_LOG_ERROR, "could not get snap_details status");
goto out;
}
- cli_out ("Number of Snaps Taken : %ld", snapcount);
+ ret = snprintf (buffer, sizeof (buffer),
+ "%s.snap-count-total", prefix_str);
+ if (ret < 0) {
+ goto out;
+ }
+ ret = dict_get_int64 (dict_n, buffer, &snapcount_total);
+ if (!ret)
+ cli_out ("Total Snap Count : %ld", snapcount_total);
+ else
+ gf_log ("", GF_LOG_ERROR, "Failed to get snapcount total");
+
for (i = 0 ; i < snapcount; i++) {
- /* get snapname "snaplist.vol{0..}.snap{0..}.snap_name" */
+ /* get snapname "snaplist.vol-{0..}.snap-{0..}.snapname" */
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.snap_name", prefix_str,i);
+ "%s.snap-%ld.snapname", prefix_str,i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
ret = dict_get_str (dict_n, buffer, &get_buffer);
if (!ret)
- cli_out ("\tSnap Name : %s",get_buffer);
+ cli_out ("\n\tSnap Name : %s",get_buffer);
else
- cli_out ("\tSnap Name : %s","Does not exist");
+ cli_out ("\n\tSnap Name : %s","Does not exist");
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.snap_time", prefix_str, i);
+ "%s.snap-%ld.snap-time", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7471,7 +7482,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
cli_out ("\tSnap Time : %s","Does not exist");
- ret = snprintf (buffer, sizeof(buffer), "%s.snap%ld.snap_id"
+ ret = snprintf (buffer, sizeof(buffer), "%s.snap-%ld.snap-id"
, prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
@@ -7489,7 +7500,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
continue;
}
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.cg_name", prefix_str, i);
+ "%s.snap-%ld.cgname", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7500,7 +7511,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
cli_out("\tCG Name : %s","Does not exist");
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.cg_id", prefix_str, i);
+ "%s.snap-%ld.cg-id", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7511,7 +7522,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
cli_out("\tCG ID : %s","Does not exist");
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.snap_desc", prefix_str, i);
+ "%s.snap-%ld.snap-desc", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7523,7 +7534,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
"Description not present");
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap%ld.snap_status", prefix_str, i);
+ "%s.snap-%ld.snap-status", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7556,13 +7567,13 @@ list_snap_of_cg (dict_t *dict) {
* or else we can keep that string in some variable
* and use the same variable every where
*/
- ret = dict_get_int8 (dict, "snap_details", &detail);
+ ret = dict_get_int8 (dict, "snap-details", &detail);
if (ret) {
gf_log ("", GF_LOG_ERROR, "could not get snap_details status");
goto out;
}
- ret = dict_get_str (dict, "snaplist.cg0.cg_name", &get_buffer);
+ ret = dict_get_str (dict, "snaplist.cg-0.cgname", &get_buffer);
if (ret) {
/* if cg_name is not present then exit, it is not necessary
* to check other details if cg_name is not present
@@ -7573,14 +7584,15 @@ list_snap_of_cg (dict_t *dict) {
}
cli_out ("CG Name : %s", get_buffer);
- ret = dict_get_str (dict, "snaplist.cg0.cg_id", &get_buffer);
+ ret = dict_get_str (dict, "snaplist.cg-0.cg-id", &get_buffer);
if (!ret)
cli_out ("CG ID : %s",get_buffer);
else
cli_out ("CG ID : %s","Does not exist");
if (detail == 1) {
- ret = dict_get_str (dict, "snaplist.cg0.cg_desc", &get_buffer);
+ ret = dict_get_str (dict,
+ "snaplist.cg-0.cg-desc", &get_buffer);
if (!ret)
cli_out ("CG Description : %s",
get_buffer);
@@ -7588,7 +7600,7 @@ list_snap_of_cg (dict_t *dict) {
cli_out ("CG Description : %s",
"Does not exist");
- ret = dict_get_str (dict, "snaplist.cg0.cg_status",
+ ret = dict_get_str (dict, "snaplist.cg-0.cg-status",
&get_buffer);
if (!ret)
cli_out ("CG Status : %s", get_buffer);
@@ -7598,7 +7610,7 @@ list_snap_of_cg (dict_t *dict) {
}
- ret = dict_get_int64 (dict, "snaplist.cg0.vol_count", &cg_volcount);
+ ret = dict_get_int64 (dict, "snaplist.cg-0.vol-count", &cg_volcount);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Could not fetch cg_volcount");
goto out;
@@ -7606,7 +7618,7 @@ list_snap_of_cg (dict_t *dict) {
/* list the snaps of each volume present in a CG*/
for (i = 0 ; i < cg_volcount ; i++){
ret = snprintf (cg_name_list, sizeof(cg_name_list),
- "snaplist.cg0.vol%ld",i);
+ "snaplist.cg-0.vol%ld",i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7625,20 +7637,20 @@ static int
call_list_snap_of_volume(dict_t *dict){
int ret = -1;
int64_t volcount = -1;
- int i = -1;
+ int64_t i = -1;
char vol_name_prefix[PATH_MAX] = "";
- ret = dict_get_int64 (dict, "snaplist.vol_count", &volcount);
+ ret = dict_get_int64 (dict, "snaplist.vol-count", &volcount);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Could not fetch volcount");
goto out;
}
for (i = 0 ; i < volcount ; i++) {
/* list the snap of each volume
- * vol_name_prefix = "snaplist.vol{0..}"
+ * vol_name_prefix = "snaplist.vol-{0..}"
*/
ret = snprintf (vol_name_prefix, sizeof(vol_name_prefix),
- "snaplist.vol%d", i);
+ "snaplist.vol%ld", i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7748,7 +7760,7 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov,
/* get the vol_count
* if vol_count = 0, then there must be presence of CG
*/
- ret = dict_get_int64 (dict, "snaplist.vol_count", &volcount);
+ ret = dict_get_int64 (dict, "snaplist.vol-count", &volcount);
if (ret){
gf_log("", GF_LOG_ERROR, "Could not fetch volcount");
ret = -1;