diff options
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 340752aa8..b441e1083 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7985,6 +7985,41 @@ cli_get_snaps_in_volume (dict_t *dict) { out : return ret; } + +int +cli_snapshot_list (dict_t *dict) { + int snapcount = 0; + char key[PATH_MAX] = ""; + int ret = -1; + int i = 0; + char *get_buffer = NULL; + + GF_ASSERT (dict); + + ret = dict_get_int32 (dict, "snap-count", &snapcount); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not fetch snap count"); + goto out; + } + + for (i = 1 ; i <= snapcount ; i++) { + ret = snprintf (key, sizeof (key), "snapname%d",i); + if (ret < 0) { + goto out; + } + + ret = dict_get_str (dict, key, &get_buffer); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not get %s ", key); + goto out; + } else { + cli_out ("%s", get_buffer); + } + } +out : + return ret; +} + int gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -8125,9 +8160,7 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, goto out; } } - break; - - + break; case GF_SNAP_OPTION_TYPE_CONFIG: ret = cli_snapshot_config_display (dict, &rsp); @@ -8138,6 +8171,15 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, } break; + case GF_SNAP_OPTION_TYPE_LIST: + ret = cli_snapshot_list (dict); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to display snapshot" + " list"); + goto out; + } + break; + case GF_SNAP_OPTION_TYPE_DELETE: ret = cli_snapshot_remove_reply (&rsp, dict, frame); break; |