diff options
author | shishir gowda <sgowda@redhat.com> | 2013-10-24 15:47:14 +0530 |
---|---|---|
committer | shishir gowda <sgowda@redhat.com> | 2013-11-15 14:39:42 +0530 |
commit | 096b23f187d0b3ccbed25d8bd02723a61cc4da2d (patch) | |
tree | b4fbbd9de6396d9a2f8c7d1317da01b13e42a3b4 /cli/src/cli-cmd-parser.c | |
parent | 30e6c5364a0484fddc655d43cd3a0224f21343e4 (diff) |
mgmt/glusterd: snapshot config changes
Also refactored code in glusterd for create command
Additionally, removed brick-op func from mgmt_iniate_all_phases
Change-Id: Iddcc332009c5716adee7f2b04c93b352fb983446
Signed-off-by: shishir gowda <sgowda@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 104 |
1 files changed, 90 insertions, 14 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index cf790918c..b7078ff28 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3163,6 +3163,82 @@ out: return ret; } +int32_t +cli_snap_config_parse (const char **words, int wordcount, dict_t *options) +{ + dict_t *dict = NULL; + char *volname = NULL; + int ret = -1; + char *key = NULL; + char *value = NULL; + uint64_t limit = 0; + gf1_cli_snapshot type = GF_SNAP_OPTION_TYPE_NONE; + + GF_ASSERT (words); + GF_ASSERT (options); + + if ((wordcount != 3) && (wordcount != 5)) + goto out; + + volname = (char *)words[2]; + + GF_ASSERT (volname); + + type = GF_SNAP_OPTION_TYPE_CONFIG; + ret = dict_set_int32 (options, "type", type); + if (ret) { + gf_log ("", GF_LOG_ERROR, + "Failed to set type."); + goto out; + } + + ret = dict_set_str (options, "volname", volname); + if (ret) { + gf_log ("", GF_LOG_ERROR, + "Failed to set volname."); + goto out; + } + + /* snapshot config <volname | all> [snap_max_limit <count>] */ + + if (wordcount == 3) { + ret = dict_set_int32 (options, "config-command", + GF_SNAP_CONFIG_DISPLAY); + goto out; + } + + key = (char *) words[3]; + value = (char *) words[4]; + if ( !key || !value) { + ret = -1; + goto out; + } + if (strncmp (key, "snap-max-limit", 14)) { + gf_log ("", GF_LOG_ERROR, "Invalid key"); + goto out; + } + if (!strncmp (volname, "all", 3)) { + ret = dict_set_int32 (options, "config-command", + GF_SNAP_CONFIG_SYS_MAX); + } else { + ret = dict_set_int32 (options, "config-command", + GF_SNAP_CONFIG_VOL_MAX); + } + + limit = (uint64_t) atoll (value); + ret = dict_set_uint64 (options, "limit", limit); + if (ret) { + gf_log ("", GF_LOG_ERROR, + "Failed to set limit."); + goto out; + } + if (ret) + goto out; + +out: + return ret; +} + int32_t cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options) @@ -3171,7 +3247,7 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options) dict_t *dict = NULL; gf1_cli_snapshot type = GF_SNAP_OPTION_TYPE_NONE; int32_t cmdi = 0; - char *opwords[] = {"create", "list", NULL}; + char *opwords[] = {"create", "list", "config", NULL}; char *w = NULL; int i = 0; @@ -3211,12 +3287,6 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options) goto out; type = GF_SNAP_OPTION_TYPE_CREATE; cmdi = 1; - ret = dict_set_int32 (dict, "type", type); - if (ret) { - gf_log ("", GF_LOG_ERROR, - "Failed to set type."); - goto out; - } ret = cli_snap_create_parse (dict, words, wordcount, cmdi); @@ -3239,14 +3309,8 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options) goto out; } } - type = GF_SNAP_OPTION_TYPE_LIST; - ret = dict_set_int32 (dict, "type" , type); - if (ret) { - gf_log ("" , GF_LOG_ERROR, - "Failed to set type."); - goto out; - } + type = GF_SNAP_OPTION_TYPE_LIST; ret = cli_snap_list_parse (dict, words, wordcount, cmdi); @@ -3256,11 +3320,23 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options) "list command parsing failed."); goto out; } + } else if (strcmp (w, "config") == 0){ + /* snapshot config <volname | all> [snap_max_limit <count>] */ + + type = GF_SNAP_OPTION_TYPE_CONFIG; + + ret = cli_snap_config_parse (words, wordcount, dict); } else { gf_log ("", GF_LOG_ERROR, "Opword Mismatch"); goto out; } + ret = dict_set_int32 (dict, "type", type); + if (ret) { + gf_log ("", GF_LOG_ERROR, + "Failed to set type."); + goto out; + } /* If you got so far, input is valid */ ret = 0; out: |