From 9fe1f24e42fa54b58616cd846fce76ab60d7e4e8 Mon Sep 17 00:00:00 2001 From: Sachin Pandit Date: Fri, 7 Mar 2014 05:16:02 +0530 Subject: glusterd/snapshot : Introduced a macro for snapshot info command. Also populated the error message in case of snapshot create, list, info and delete failure. When snapshot list, info or delete is issued, if the entered snapname/volname does not exist then populate error string along with logging. Change-Id: I632d25110bc63ff0e4ac98b27e2f410f7ccbb990 Signed-off-by: Sachin Pandit Reviewed-on: http://review.gluster.org/7203 Reviewed-by: Vijaikumar Mallikarjuna Reviewed-by: Rajesh Joseph Tested-by: Rajesh Joseph --- cli/src/cli-cmd-parser.c | 12 +++++++++++- cli/src/cli-rpc-ops.c | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'cli/src') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index adfb85e9e..2ad5d430c 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2780,7 +2780,7 @@ cli_snap_create_desc_parse (dict_t *dict, const char **words, desc[desc_len] = '\0'; /* Calculating the size of the description as given by the user */ - ret = dict_set_dynstr (dict, "snap-description", desc); + ret = dict_set_dynstr (dict, "description", desc); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to save snap " "description"); @@ -3008,6 +3008,7 @@ cli_snap_info_parse (dict_t *dict, const char **words, int wordcount, unsigned int cmdi) { int ret = -1; + int32_t cmd = GF_SNAP_INFO_TYPE_ALL; GF_ASSERT (words); GF_ASSERT (dict); @@ -3044,6 +3045,7 @@ cli_snap_info_parse (dict_t *dict, const char **words, int wordcount, goto out; } + cmd = GF_SNAP_INFO_TYPE_SNAP; ret = 0; goto out; /* No need to continue the parsing once we @@ -3067,7 +3069,15 @@ cli_snap_info_parse (dict_t *dict, const char **words, int wordcount, "volume name %s", words[wordcount - 1]); goto out; } + cmd = GF_SNAP_INFO_TYPE_VOL; out : + if (ret == 0) { + ret = dict_set_int32 (dict, "cmd", cmd); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save " + "type of snapshot info"); + } + } return ret; } diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 0447e5baf..60abfc1bf 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -8147,6 +8147,14 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, break; case GF_SNAP_OPTION_TYPE_LIST: + if (rsp.op_ret) { + cli_err ("Snapshot list : failed: %s", + rsp.op_errstr ? rsp.op_errstr : + "Please check log file for details"); + ret = rsp.op_ret; + goto out; + } + ret = cli_snapshot_list (dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to display " -- cgit