diff options
author | Avra Sengupta <asengupt@redhat.com> | 2014-02-19 16:30:11 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-04-11 16:29:17 -0700 |
commit | 29bccc2ed18eedc40e83d2f0d35327037a322384 (patch) | |
tree | 207829c5a0535af28cbad6de90497d2f48093d1a /cli/src/cli-cmd-snapshot.c | |
parent | 2045c9ea1c7c3aac9d377070df6f0ee99619f421 (diff) |
gluster: GlusterFS Volume Snapshot Feature
This is the initial patch for the Snapshot feature. Current patch
includes following features:
* Snapshot create
* Snapshot delete
* Snapshot restore
* Snapshot list
* Snapshot info
* Snapshot status
* Snapshot config
Change-Id: I2f46920c0d61c515f6a60e0f8b46fff886d9f6a9
BUG: 1061685
Signed-off-by: shishir gowda <sgowda@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Signed-off-by: Vijaikumar M <vmallika@redhat.com>
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/7128
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-snapshot.c')
-rw-r--r-- | cli/src/cli-cmd-snapshot.c | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c new file mode 100644 index 00000000000..941dcbdd2a3 --- /dev/null +++ b/cli/src/cli-cmd-snapshot.c @@ -0,0 +1,145 @@ +/* + Copyright (c) 2013-2014 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdint.h> +#include <pthread.h> + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "cli.h" +#include "cli-cmd.h" + +extern rpc_clnt_prog_t *cli_rpc_prog; + +int +cli_cmd_snapshot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, + const char **words, int wordcount); + +int +cli_cmd_snapshot_cbk (struct cli_state *state, struct cli_cmd_word *word, + const char **words, int wordcount) +{ + int ret = 0; + int parse_err = 0; + dict_t *options = NULL; + rpc_clnt_procedure_t *proc = NULL; + call_frame_t *frame = NULL; + cli_local_t *local = NULL; + + proc = &cli_rpc_prog->proctable [GLUSTER_CLI_SNAP]; + if (proc == NULL) { + ret = -1; + goto out; + } + + frame = create_frame (THIS, THIS->ctx->pool); + if (frame == NULL) { + ret = -1; + goto out; + } + + /* Parses the command entered by the user */ + ret = cli_cmd_snapshot_parse (words, wordcount, &options, state); + if (ret) { + if (ret < 0) { + cli_usage_out (word->pattern); + parse_err = 1; + } else { + /* User might have cancelled the snapshot operation */ + ret = 0; + } + goto out; + } + + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) + ret = proc->fn (frame, THIS, options); + +out: + if (ret && parse_err == 0) + cli_out ("Snapshot command failed"); + + CLI_STACK_DESTROY (frame); + + return ret; +} + +struct cli_cmd snapshot_cmds[] = { + { "snapshot help", + cli_cmd_snapshot_help_cbk, + "display help for snapshot commands" + }, + { "snapshot create <snapname> <volname(s)> [description <description>] [force]", + cli_cmd_snapshot_cbk, + "Snapshot Create." + }, + { "snapshot restore <snapname>", + cli_cmd_snapshot_cbk, + "Snapshot Restore." + }, + { "snapshot status [(snapname | volume <volname>)]", + cli_cmd_snapshot_cbk, + "Snapshot Status." + }, + { "snapshot info [(snapname | volume <volname>)]", + cli_cmd_snapshot_cbk, + "Snapshot Info." + }, + { "snapshot list [volname]", + cli_cmd_snapshot_cbk, + "Snapshot List." + }, + {"snapshot config [volname] [snap-max-hard-limit <count>] [snap-max-soft-limit <percent>]", + cli_cmd_snapshot_cbk, + "Snapshot Config." + }, + {"snapshot delete <snapname>", + cli_cmd_snapshot_cbk, + "Snapshot Delete." + }, + { NULL, NULL, NULL } +}; + +int +cli_cmd_snapshot_help_cbk (struct cli_state *state, + struct cli_cmd_word *in_word, + const char **words, + int wordcount) +{ + struct cli_cmd *cmd = NULL; + + for (cmd = snapshot_cmds; cmd->pattern; cmd++) + if (_gf_false == cmd->disable) + cli_out ("%s - %s", cmd->pattern, cmd->desc); + + return 0; +} + +int +cli_cmd_snapshot_register (struct cli_state *state) +{ + int ret = 0; + struct cli_cmd *cmd = NULL; + + for (cmd = snapshot_cmds; cmd->pattern; cmd++) { + + ret = cli_cmd_register (&state->tree, cmd); + if (ret) + goto out; + } +out: + return ret; +} |