From 0628c77f9069e93c49993722ac577becfcf902db Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Fri, 21 Aug 2015 06:45:46 -0400 Subject: cluster/tier: add gluster v tier This is a backport of 11984. > Currently the tier feature piggy backs off the rebalance command > syntax to obtain status and this is clumsy. Introduce a new > tier command that can do tier specific operations, starting > with volume status to display counters. > Old commands: > gluster volume attach-tier [replica count] {bricklist..} > gluster volume detach-tier {start|stop|commit} > New commands: > gluster volume tier attach [replica count] {bricklist} | > detach {start|stop|commit} | > status > Change-Id: Ic07b3c6260588162de7d34380f8cbd3d8a7f35d3 > BUG: 1255693 > Signed-off-by: Dan Lambright > Reviewed-on: http://review.gluster.org/11984 > Reviewed-by: Gaurav Kumar Garg > Tested-by: Gluster Build System Signed-off-by: Dan Lambright Change-Id: Id45bd0fa6b8606dd47863de83a694908da393229 BUG: 1261664 Signed-off-by: Dan Lambright Reviewed-on: http://review.gluster.org/12143 Tested-by: Gluster Build System Reviewed-by: Gaurav Kumar Garg --- cli/src/cli-cmd-parser.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 5b27ed9c6a7..cd63782e0f3 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -63,6 +63,9 @@ enum cli_snap_config_set_types { }; typedef enum cli_snap_config_set_types cli_snap_config_set_types; +int +cli_cmd_validate_volume (char *volname); + static const char * id_sel (void *wcon) { @@ -1692,6 +1695,71 @@ out: return ret; } +int32_t +cli_cmd_volume_tier_parse (const char **words, int wordcount, + dict_t **options) +{ + dict_t *dict = NULL; + char *volname = NULL; + char *word = NULL; + int ret = -1; + int32_t command = GF_OP_CMD_NONE; + + GF_ASSERT (words); + GF_ASSERT (options); + + dict = dict_new (); + + if (!dict) + goto out; + + if (wordcount != 4) { + gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); + ret = -1; + goto out; + } + + volname = (char *)words[2]; + + GF_ASSERT (volname); + + ret = cli_cmd_validate_volume (volname); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to validate volume name"); + goto out; + } + + ret = dict_set_str (dict, "volname", volname); + + if (ret) + goto out; + + volname = (char *)words[2]; + + word = (char *)words[3]; + if (!strcmp(word, "status")) + command = GF_DEFRAG_CMD_STATUS_TIER; + else { + ret = -1; + goto out; + } + + ret = dict_set_int32 (dict, "rebalance-command", command); + if (ret) + goto out; + + *options = dict; +out: + + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Unable to parse tier CLI"); + if (dict) + dict_destroy (dict); + } + + return ret; +} + int32_t cli_cmd_volume_detach_tier_parse (const char **words, int wordcount, dict_t **options) -- cgit