diff options
author | Sachin Pandit <spandit@redhat.com> | 2014-02-20 13:46:58 +0530 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2014-03-05 02:03:20 -0800 |
commit | ae62c3aec7b92dc5325a04add9ab0ac63ff05fa5 (patch) | |
tree | 811c34afa69f3910abc9f72f568dd3f60e00d927 /cli/src/cli-cmd-parser.c | |
parent | cffe1de37453f81992047408e4c4ce5e35e21434 (diff) |
cli/snapshot : snapshot list CLI
syntax:
gluster snapshot list [volname]
This will list all the snapshots (or) snapshots of a particular volume.
Change-Id: If879e06fe13caf2236f48df345857f833ae83c5b
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/7143
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 2505bbc7f..6b8f2929f 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2956,6 +2956,44 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, out : return ret; } + +/* snapshot list [volname] + * @arg-0, dict : Request Dictionary to be sent to server side. + * @arg-1, words : Contains individual words of CLI command. + * @arg-2, wordcount: Contains number of words present in the CLI command. + * @arg-3, cmdi : command index, here cmdi is "2" (gluster snapshot list) + * + * return value : -1 on failure + * 0 on success + */ +int +cli_snap_list_parse (dict_t *dict, const char **words, int wordcount, + unsigned int cmdi) { + int ret = -1; + + GF_ASSERT (words); + GF_ASSERT (dict); + + if (wordcount < cmdi || wordcount > 3) { + gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); + goto out; + } + + if (wordcount == 2) { + ret = 0; + goto out; + } + + ret = dict_set_str (dict, "volname", (char *)words[cmdi]); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, + "Failed to save volname in dictionary"); + goto out; + } +out : + return ret; +} + /* snapshot info [(snapname | volume <volname>)] * @arg-0, dict : Request Dictionary to be sent to server side. * @arg-1, words : Contains individual words of CLI command. @@ -3458,6 +3496,22 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options, cmdi); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to parse " + "snapshot info command"); + goto out; + } + break; + } + + case GF_SNAP_OPTION_TYPE_LIST: + { + /* Syntax : + * gluster snaphsot list [volname] + */ + + ret = cli_snap_list_parse (dict, words, wordcount, + cmdi); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to parse " "snapshot list command"); goto out; } |