From 2b86da69df423a90b76932bd32b7a17bd5ac2add Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Mon, 22 Apr 2019 19:50:19 +0530 Subject: tier/cli: remove tier code to increase code coverage in cli Change-Id: I56cc09243dab23b3be86a7faac45001dda77181f updates: bz#1693692 Signed-off-by: Sanju Rakonde --- cli/src/cli-cmd-misc.c | 15 +- cli/src/cli-cmd-parser.c | 212 ---------- cli/src/cli-cmd-volume.c | 414 +------------------ cli/src/cli-rpc-ops.c | 1018 ++++------------------------------------------ cli/src/cli-xml-output.c | 383 ++--------------- cli/src/cli.c | 2 - cli/src/cli.h | 18 +- 7 files changed, 111 insertions(+), 1951 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c index 04dd2efc22..120d4ab69b 100644 --- a/cli/src/cli-cmd-misc.c +++ b/cli/src/cli-cmd-misc.c @@ -25,7 +25,6 @@ extern rpc_clnt_prog_t *cli_rpc_prog; extern struct cli_cmd volume_cmds[]; extern struct cli_cmd bitrot_cmds[]; extern struct cli_cmd quota_cmds[]; -extern struct cli_cmd tier_cmds[]; extern struct cli_cmd cli_probe_cmds[]; extern struct cli_cmd cli_log_cmds[]; extern struct cli_cmd cli_system_cmds[]; @@ -59,18 +58,8 @@ cli_cmd_display_help(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount) { struct cli_cmd *cmd[] = { - cli_misc_cmds, - cli_probe_cmds, - volume_cmds, - bitrot_cmds, - quota_cmds, -#if !defined(__NetBSD__) - tier_cmds, -#endif - snapshot_cmds, - global_cmds, - NULL - }; + cli_misc_cmds, cli_probe_cmds, volume_cmds, bitrot_cmds, + quota_cmds, snapshot_cmds, global_cmds, NULL}; struct cli_cmd *cmd_ind = NULL; int i = 0; gf_boolean_t list_all = _gf_false; diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index d9913f678a..ccae1ada98 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -392,11 +392,6 @@ cli_validate_disperse_volume(char *word, gf1_cluster_type type, ret = 2; } break; - case GF_CLUSTER_TYPE_TIER: - cli_err( - "tier-dispersed volume is not " - "supported"); - goto out; case GF_CLUSTER_TYPE_REPLICATE: cli_err( "replicated-dispersed volume is not " @@ -542,12 +537,6 @@ cli_cmd_volume_create_parse(struct cli_state *state, const char **words, case GF_CLUSTER_TYPE_STRIPE: cli_err("stripe option not supported"); goto out; - case GF_CLUSTER_TYPE_TIER: - cli_err( - "replicated-tiered volume is not " - "supported"); - goto out; - break; case GF_CLUSTER_TYPE_DISPERSE: cli_err( "replicated-dispersed volume is not " @@ -1865,146 +1854,6 @@ 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; - int ret = -1; - int32_t command = GF_DEFRAG_CMD_NONE; - int32_t is_force = 0; - - GF_ASSERT(words); - GF_ASSERT(options); - - dict = dict_new(); - - if (!dict) - goto out; - - if (!(wordcount == 4 || wordcount == 5)) { - 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]; - if (wordcount == 4) { - if (!strcmp(words[3], "status")) - command = GF_DEFRAG_CMD_STATUS_TIER; - else if (!strcmp(words[3], "start")) - command = GF_DEFRAG_CMD_START_TIER; - else if (!strcmp(words[3], "stop")) - command = GF_DEFRAG_CMD_STOP_TIER; - else { - ret = -1; - goto out; - } - } else if (wordcount == 5) { - if ((!strcmp(words[3], "start")) && (!strcmp(words[4], "force"))) { - command = GF_DEFRAG_CMD_START_TIER; - is_force = 1; - ret = dict_set_int32(dict, "force", is_force); - if (ret) - goto out; - } 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_unref(dict); - } - - return ret; -} - -int32_t -cli_cmd_volume_detach_tier_parse(const char **words, int wordcount, - dict_t **options, int *question) -{ - int ret = -1; - char *word = NULL; - dict_t *dict = NULL; - int32_t command = GF_DEFRAG_CMD_NONE; - - dict = dict_new(); - if (!dict) - goto out; - - ret = dict_set_str(dict, "volname", (char *)words[2]); - if (ret) - goto out; - - if (wordcount == 3 && !strcmp((char *)words[2], "help")) { - return -1; - } - - if (wordcount != 4) { - ret = -1; - goto out; - } - - word = (char *)words[3]; - - ret = -1; - - if (!strcmp(word, "start")) { - command = GF_DEFRAG_CMD_DETACH_START; - } else if (!strcmp(word, "commit")) { - *question = 1; - command = GF_DEFRAG_CMD_DETACH_COMMIT; - } else if (!strcmp(word, "force")) { - *question = 1; - command = GF_DEFRAG_CMD_DETACH_COMMIT_FORCE; - } else if (!strcmp(word, "stop")) - command = GF_DEFRAG_CMD_DETACH_STOP; - else if (!strcmp(word, "status")) - command = GF_DEFRAG_CMD_DETACH_STATUS; - else - goto out; - - ret = dict_set_int32(dict, "command", command); - if (ret) - goto out; - - *options = dict; - ret = 0; -out: - if (ret) { - gf_log("cli", GF_LOG_ERROR, "Unable to parse detach tier CLI"); - if (dict) - dict_unref(dict); - } - - return ret; -} - int32_t cli_cmd_volume_remove_brick_parse(struct cli_state *state, const char **words, int wordcount, dict_t **options, @@ -3455,8 +3304,6 @@ cli_cmd_volume_status_parse(const char **words, int wordcount, dict_t **options) cmd |= GF_CLI_STATUS_QUOTAD; } else if (!strcmp(words[3], "snapd")) { cmd |= GF_CLI_STATUS_SNAPD; - } else if (!strcmp(words[3], "tierd")) { - cmd |= GF_CLI_STATUS_TIERD; } else if (!strcmp(words[3], "bitd")) { cmd |= GF_CLI_STATUS_BITD; } else if (!strcmp(words[3], "scrub")) { @@ -3532,16 +3379,6 @@ cli_cmd_volume_status_parse(const char **words, int wordcount, dict_t **options) goto out; } cmd |= GF_CLI_STATUS_SNAPD; - } else if (!strcmp(words[3], "tierd")) { - if (cmd == GF_CLI_STATUS_FD || cmd == GF_CLI_STATUS_CLIENTS || - cmd == GF_CLI_STATUS_DETAIL || cmd == GF_CLI_STATUS_INODE) { - cli_err( - "Detail/FD/Clients/Inode status not " - "available for tier daemon"); - ret = -1; - goto out; - } - cmd |= GF_CLI_STATUS_TIERD; } else { if (cmd == GF_CLI_STATUS_TASKS) { cli_err( @@ -4066,55 +3903,6 @@ out: return ret; } -int -cli_cmd_volume_old_tier_parse(const char **words, int wordcount, - dict_t **options) -{ - dict_t *dict = NULL; - int ret = -1; - char *volname = NULL; - gf_cli_defrag_type cmd = 0; - - GF_ASSERT(words); - GF_ASSERT(options); - - dict = dict_new(); - if (!dict) - goto out; - - if (wordcount != 4) - goto out; - - if ((strcmp(words[1], "tier") == 0) && (strcmp(words[3], "start") == 0)) { - cmd = GF_DEFRAG_CMD_START_TIER; - } else - goto out; - - volname = (char *)words[2]; - - ret = dict_set_str(dict, "volname", volname); - - if (ret) { - gf_log(THIS->name, GF_LOG_ERROR, "failed to set dict"); - goto out; - } - - ret = dict_set_int32(dict, "rebalance-command", (int32_t)cmd); - - if (ret) { - gf_log(THIS->name, GF_LOG_ERROR, "failed to set dict"); - goto out; - } - - *options = dict; - -out: - if (ret && dict) - dict_unref(dict); - - return ret; -} - int cli_cmd_volume_defrag_parse(const char **words, int wordcount, dict_t **options) { diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 975536f9f6..e711608ed8 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -49,10 +49,6 @@ int cli_cmd_quota_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); -int -cli_cmd_tier_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, - const char **words, int wordcount); - int cli_cmd_volume_info_cbk(struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -1118,335 +1114,6 @@ out: return ret; } -int -cli_tier_validate_replica_type(dict_t *dict, int type) -{ - int brick_count = -1; - int replica_count = 1; - int ret = -1; - - ret = dict_get_int32(dict, "count", &brick_count); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "Failed to get brick count"); - goto out; - } - - ret = dict_get_int32(dict, "replica-count", &replica_count); - if (ret) { - gf_log("cli", GF_LOG_DEBUG, - "Failed to get replica count. " - "Defaulting to one"); - replica_count = 1; - } - - /* - * Change the calculation of sub_count once attach-tier support - * disperse volume. - * sub_count = disperse_count for disperse volume - * */ - - if (brick_count % replica_count) { - if (type == GF_CLUSTER_TYPE_REPLICATE) - cli_err( - "number of bricks is not a multiple of " - "replica count"); - else if (type == GF_CLUSTER_TYPE_DISPERSE) - cli_err( - "number of bricks is not a multiple of " - "disperse count"); - else - cli_err( - "number of bricks given doesn't match " - "required count"); - - ret = -1; - goto out; - } - ret = 0; -out: - return ret; -} - -int -do_cli_cmd_volume_attach_tier(struct cli_state *state, - struct cli_cmd_word *word, const char **words, - int wordcount) -{ - int ret = -1; - rpc_clnt_procedure_t *proc = NULL; - call_frame_t *frame = NULL; - dict_t *options = NULL; - int sent = 0; - int parse_error = 0; - cli_local_t *local = NULL; - int type = 0; - - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - - ret = cli_cmd_volume_add_brick_parse(state, words, wordcount, &options, - &type); - if (ret) { - cli_usage_out(word->pattern); - parse_error = 1; - goto out; - } - - /* - * Merge this check when attach-tier has it's own cli parse function. - */ - ret = cli_tier_validate_replica_type(options, type); - if (ret) { - cli_usage_out(word->pattern); - parse_error = 1; - goto out; - } - - if (state->mode & GLUSTER_MODE_WIGNORE) { - ret = dict_set_int32(options, "force", _gf_true); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "Failed to set force " - "option"); - goto out; - } - } - - ret = dict_set_int32(options, "attach-tier", 1); - if (ret) - goto out; - - ret = dict_set_int32(options, "hot-type", type); - if (ret) - goto out; - - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ADD_TIER_BRICK]; - - CLI_LOCAL_INIT(local, words, frame, options); - - if (proc->fn) { - ret = proc->fn(frame, THIS, options); - } - -out: - if (ret) { - cli_cmd_sent_status_get(&sent); - if ((sent == 0) && (parse_error == 0)) - cli_out("attach-tier failed"); - } - - CLI_STACK_DESTROY(frame); - - return ret; -} - -int -do_cli_cmd_volume_detach_tier(struct cli_state *state, - struct cli_cmd_word *word, const char **words, - int wordcount, gf_boolean_t *aborted) -{ - int ret = -1; - rpc_clnt_procedure_t *proc = NULL; - call_frame_t *frame = NULL; - dict_t *options = NULL; - int sent = 0; - int parse_error = 0; - gf_answer_t answer = GF_ANSWER_NO; - cli_local_t *local = NULL; - int need_question = 0; - - const char *question = - "Removing tier can result in data loss. " - "Do you want to Continue?"; - - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - - ret = cli_cmd_volume_detach_tier_parse(words, wordcount, &options, - &need_question); - if (ret) { - cli_usage_out(word->pattern); - parse_error = 1; - goto out; - } - - ret = dict_set_int32(options, "force", 1); - if (ret) - goto out; - - ret = dict_set_int32(options, "count", 0); - if (ret) - goto out; - - *aborted = _gf_false; - - if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { - /* we need to ask question only in case of 'commit or force' */ - answer = cli_cmd_get_confirmation(state, question); - if (GF_ANSWER_NO == answer) { - ret = 0; - *aborted = _gf_true; - goto out; - } - } - - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_REMOVE_TIER_BRICK]; - - CLI_LOCAL_INIT(local, words, frame, options); - - if (proc->fn) { - ret = proc->fn(frame, THIS, options); - } - -out: - if (ret) { - cli_cmd_sent_status_get(&sent); - if ((sent == 0) && (parse_error == 0)) - cli_out("Volume detach tier failed"); - } - - CLI_STACK_DESTROY(frame); - - return ret; -} - -int -cli_cmd_volume_tier_cbk(struct cli_state *state, struct cli_cmd_word *word, - const char **words, int wordcount) -{ - int ret = -1; - call_frame_t *frame = NULL; - dict_t *options = NULL; - rpc_clnt_procedure_t *proc = NULL; - cli_local_t *local = NULL; - int i = 0; - eventtypes_t event = EVENT_LAST; - gf_boolean_t aborted = _gf_false; - gf_answer_t answer = GF_ANSWER_NO; - - const char *detach_question = - "gluster volume detach-tier " - " is " - "deprecated. Use the new command \'" - "gluster volume tier detach \'\n" - "Do you want to Continue?"; - - const char *attach_question = - "gluster volume attach-tier " - "[] ... is " - "deprecated. Use the new command \'" - "gluster volume tier attach [] ... [force]\'\n" - "Do you want to Continue?"; - - if (wordcount < 4) { - if (wordcount == 3 && !strcmp(words[2], "help")) { - cli_cmd_tier_help_cbk(state, word, words, wordcount); - ret = 0; - } else { - cli_usage_out(word->pattern); - } - goto out; - } - - if (!strcmp(words[1], "detach-tier")) { - /* we need to ask question when older command is used */ - answer = cli_cmd_get_confirmation(state, detach_question); - if (GF_ANSWER_NO == answer) { - ret = 0; - goto out; - } - ret = do_cli_cmd_volume_detach_tier(state, word, words, wordcount, - &aborted); - goto out; - } else if (!strcmp(words[3], "detach")) { - for (i = 3; i < wordcount; i++) - words[i] = words[i + 1]; - - ret = do_cli_cmd_volume_detach_tier(state, word, words, wordcount - 1, - &aborted); - if (!aborted) { - if (!strcmp(words[wordcount - 2], "commit")) { - event = EVENT_TIER_DETACH_COMMIT; - } else if (!strcmp(words[wordcount - 2], "start")) { - event = EVENT_TIER_DETACH_START; - } else if (!strcmp(words[wordcount - 2], "stop")) { - event = EVENT_TIER_DETACH_STOP; - } else if (!strcmp(words[wordcount - 2], "force")) { - event = EVENT_TIER_DETACH_FORCE; - } - } - goto out; - - } else if (!strcmp(words[1], "attach-tier")) { - /* we need to ask question when the older command is used */ - answer = cli_cmd_get_confirmation(state, attach_question); - if (GF_ANSWER_NO == answer) { - ret = 0; - goto out; - } - ret = do_cli_cmd_volume_attach_tier(state, word, words, wordcount); - goto out; - } else if (!strcmp(words[3], "attach")) { - for (i = 3; i < wordcount; i++) - words[i] = words[i + 1]; - - ret = do_cli_cmd_volume_attach_tier(state, word, words, wordcount - 1); - if (!strcmp(words[wordcount - 2], "force")) { - event = EVENT_TIER_ATTACH_FORCE; - } else { - event = EVENT_TIER_ATTACH; - } - goto out; - } - - ret = cli_cmd_volume_tier_parse(words, wordcount, &options); - if (ret) { - cli_usage_out(word->pattern); - goto out; - } - - if (!strcmp(words[wordcount - 1], "start")) { - event = EVENT_TIER_START; - } else { - if (!strcmp(words[wordcount - 2], "start") && - !strcmp(words[wordcount - 1], "force")) { - event = EVENT_TIER_START_FORCE; - } - } - - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TIER]; - - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) { - gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame"); - ret = -1; - goto out; - } - - CLI_LOCAL_INIT(local, words, frame, options); - - if (proc->fn) { - ret = proc->fn(frame, THIS, options); - } - -out: - if (ret) { - cli_out("Tier command failed"); - } else { - if (event != EVENT_LAST) { - gf_event(event, "vol=%s", words[2]); - } - } - if (options) - dict_unref(options); - - return ret; -} - int cli_get_soft_limit(dict_t *options, const char **words, dict_t *xdata) { @@ -3317,50 +2984,6 @@ struct cli_cmd quota_cmds[] = { {NULL, NULL, NULL}}; -struct cli_cmd tier_cmds[] = { - - {"volume tier help", cli_cmd_tier_help_cbk, - "display help for volume tier commands"}, - - {"volume tier status", cli_cmd_volume_tier_cbk, - "Display tier status for "}, - - {"volume tier start [force]", cli_cmd_volume_tier_cbk, - "Start the tier service for "}, - - {"volume tier stop [force]", cli_cmd_volume_tier_cbk, - "Stop the tier service for "}, - - {"volume tier attach [] ... [force]", - cli_cmd_volume_tier_cbk, "Attach a hot tier to "}, - - {"volume tier detach ", - cli_cmd_volume_tier_cbk, "Detach the hot tier from "}, - - {"volume attach-tier [] ...", - cli_cmd_volume_tier_cbk, - "NOTE: this is old syntax, will be deprecated in next release. " - "Please use gluster volume tier attach " - "[] ..."}, - - {"volume detach-tier " - "", - cli_cmd_volume_tier_cbk, - "NOTE: this is old syntax, will be deprecated in next release. " - "Please use gluster volume tier detach " - "{start|stop|commit} [force]"}, - - {"volume tier status\n" - "volume tier start [force]\n" - "volume tier stop\n" - "volume tier attach [] ... [force]\n" - "volume tier detach \n", - cli_cmd_volume_tier_cbk, NULL}, - - {NULL, NULL, NULL} - -}; - struct cli_cmd volume_cmds[] = { {"volume help", cli_cmd_volume_help_cbk, "display help for volume commands"}, @@ -3452,7 +3075,7 @@ struct cli_cmd volume_cmds[] = { "[brick ] [list-cnt ]", cli_cmd_volume_top_cbk, "volume top operations"}, - {"volume status [all | [nfs|shd||quotad|tierd]]" + {"volume status [all | [nfs|shd||quotad]]" " [detail|clients|mem|inode|fd|callpool|tasks|client-list]", cli_cmd_volume_status_cbk, "display status of all or specified volume(s)/brick"}, @@ -3540,32 +3163,6 @@ cli_cmd_bitrot_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, return 0; } -int -cli_cmd_tier_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, - const char **words, int wordcount) -{ - struct cli_cmd *cmd = NULL; - struct cli_cmd *tier_cmd = NULL; - int count = 0; - - cmd = GF_MALLOC(sizeof(tier_cmds), cli_mt_cli_cmd); - memcpy(cmd, tier_cmds, sizeof(tier_cmds)); - count = (sizeof(tier_cmds) / sizeof(struct cli_cmd)); - cli_cmd_sort(cmd, count); - - cli_out("\ngluster tier commands"); - cli_out("======================\n"); - - for (tier_cmd = cmd; tier_cmd->pattern; tier_cmd++) { - if ((_gf_false == tier_cmd->disable) && tier_cmd->desc) { - cli_out("%s - %s", tier_cmd->pattern, tier_cmd->desc); - } - } - cli_out("\n"); - GF_FREE(cmd); - return 0; -} - int cli_cmd_volume_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount) @@ -3615,15 +3212,6 @@ cli_cmd_volume_register(struct cli_state *state) goto out; } -#if !defined(__NetBSD__) - for (cmd = tier_cmds; cmd->pattern; cmd++) { - ret = cli_cmd_register(&state->tree, cmd); - if (ret) - goto out; - } - -#endif - out: return ret; } diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 910729c5cd..16d5f73983 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -685,7 +685,7 @@ gf_cli_print_number_of_bricks(int type, int brick_count, int dist_count, int disperse_count, int redundancy_count, int arbiter_count) { - if (type == GF_CLUSTER_TYPE_NONE || type == GF_CLUSTER_TYPE_TIER) { + if (type == GF_CLUSTER_TYPE_NONE) { cli_out("Number of Bricks: %d", brick_count); } else if (type == GF_CLUSTER_TYPE_DISPERSE) { cli_out("Number of Bricks: %d x (%d + %d) = %d", @@ -705,107 +705,6 @@ gf_cli_print_number_of_bricks(int type, int brick_count, int dist_count, } } -int -gf_cli_print_tier_info(dict_t *dict, int i, int brick_count) -{ - int hot_brick_count = -1; - int cold_type = 0; - int cold_brick_count = 0; - int cold_replica_count = 0; - int cold_arbiter_count = 0; - int cold_disperse_count = 0; - int cold_redundancy_count = 0; - int cold_dist_count = 0; - int hot_type = 0; - int hot_replica_count = 0; - int hot_dist_count = 0; - int ret = -1; - int vol_type = -1; - char key[256] = { - 0, - }; - - GF_ASSERT(dict); - - snprintf(key, sizeof(key), "volume%d.cold_brick_count", i); - ret = dict_get_int32(dict, key, &cold_brick_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_type", i); - ret = dict_get_int32(dict, key, &cold_type); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_dist_count", i); - ret = dict_get_int32(dict, key, &cold_dist_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_replica_count", i); - ret = dict_get_int32(dict, key, &cold_replica_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_arbiter_count", i); - ret = dict_get_int32(dict, key, &cold_arbiter_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_disperse_count", i); - ret = dict_get_int32(dict, key, &cold_disperse_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.cold_redundancy_count", i); - ret = dict_get_int32(dict, key, &cold_redundancy_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.hot_brick_count", i); - ret = dict_get_int32(dict, key, &hot_brick_count); - if (ret) - goto out; - - snprintf(key, sizeof(key), "volume%d.hot_type", i); - ret = dict_get_int32(dict, key, &hot_type); - if (ret) - goto out; - snprintf(key, sizeof(key), "volume%d.hot_replica_count", i); - ret = dict_get_int32(dict, key, &hot_replica_count); - if (ret) - goto out; - - cli_out("Hot Tier :"); - hot_dist_count = (hot_replica_count ? hot_replica_count : 1); - - vol_type = get_vol_type(hot_type, hot_dist_count, hot_brick_count); - cli_out("Hot Tier Type : %s", vol_type_str[vol_type]); - - gf_cli_print_number_of_bricks(hot_type, hot_brick_count, hot_dist_count, 0, - hot_replica_count, 0, 0, 0); - - ret = print_brick_details(dict, i, 1, hot_brick_count, hot_replica_count); - if (ret) - goto out; - - cli_out("Cold Tier:"); - - vol_type = get_vol_type(cold_type, cold_dist_count, cold_brick_count); - cli_out("Cold Tier Type : %s", vol_type_str[vol_type]); - - gf_cli_print_number_of_bricks(cold_type, cold_brick_count, cold_dist_count, - 0, cold_replica_count, cold_disperse_count, - cold_redundancy_count, cold_arbiter_count); - - ret = print_brick_details(dict, i, hot_brick_count + 1, brick_count, - cold_replica_count); - if (ret) - goto out; -out: - return ret; -} - int gf_cli_get_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -1025,17 +924,10 @@ xml_output: GF_FREE(local->get_vol.volname); local->get_vol.volname = gf_strdup(volname); - if (type == GF_CLUSTER_TYPE_TIER) { - ret = gf_cli_print_tier_info(dict, i, brick_count); - if (ret) - goto out; - - } else { - cli_out("Bricks:"); - ret = print_brick_details(dict, i, j, brick_count, replica_count); - if (ret) - goto out; - } + cli_out("Bricks:"); + ret = print_brick_details(dict, i, j, brick_count, replica_count); + if (ret) + goto out; snprintf(key, 256, "volume%d.opt_count", i); ret = dict_get_int32(dict, key, &opt_count); @@ -1527,8 +1419,7 @@ out: } int -gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type, - gf_boolean_t is_tier) +gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type) { int ret = -1; int count = 0; @@ -1549,7 +1440,6 @@ gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type, int32_t hrs = 0; uint32_t min = 0; uint32_t sec = 0; - gf_boolean_t down = _gf_false; gf_boolean_t fix_layout = _gf_false; uint64_t max_time = 0; uint64_t max_elapsed = 0; @@ -1616,7 +1506,6 @@ gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type, gf_log("cli", GF_LOG_ERROR, "node down and has failed" " to set dict"); - down = _gf_true; continue; /* skip this node if value not available*/ } else if (ret) { @@ -1717,12 +1606,6 @@ gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type, } GF_FREE(size_str); } - if (is_tier && down) - cli_out( - "WARNING: glusterd might be down on one or more nodes." - " Please check the nodes that are down using \'gluster" - " peer status\' and start the glusterd on those nodes," - " else tier detach commit might fail!"); /* Max time will be non-zero if rebalance is still running */ if (max_time) { @@ -1763,112 +1646,6 @@ out: return ret; } -int -gf_cli_print_tier_status(dict_t *dict, enum gf_task_types task_type) -{ - int ret = -1; - int count = 0; - int i = 1; - uint64_t promoted = 0; - uint64_t demoted = 0; - char key[256] = { - 0, - }; - char *node_name = NULL; - gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; - char *status_str = NULL; - gf_boolean_t down = _gf_false; - double elapsed = 0; - int hrs = 0; - int min = 0; - int sec = 0; - - ret = dict_get_int32(dict, "count", &count); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "count not set"); - goto out; - } - - cli_out("%-20s %-20s %-20s %-20s %-20s", "Node", "Promoted files", - "Demoted files", "Status", "run time in h:m:s"); - cli_out("%-20s %-20s %-20s %-20s %-20s", "---------", "---------", - "---------", "---------", "---------"); - - for (i = 1; i <= count; i++) { - /* Reset the variables to prevent carryover of values */ - node_name = NULL; - promoted = 0; - demoted = 0; - - /* Check if status is NOT_STARTED, and continue early */ - snprintf(key, sizeof(key), "status-%d", i); - - ret = dict_get_int32(dict, key, (int32_t *)&status_rcd); - if (ret == -ENOENT) { - gf_log("cli", GF_LOG_TRACE, - "count: %d, %d," - "failed to get status", - count, i); - gf_log("cli", GF_LOG_ERROR, - "node down and has failed" - " to set dict"); - down = _gf_true; - continue; - /*skipping this node as value unavailable*/ - } else if (ret) { - gf_log("cli", GF_LOG_TRACE, - "count: %d, %d," - "failed to get status", - count, i); - continue; - } - - if (GF_DEFRAG_STATUS_NOT_STARTED == status_rcd) - continue; - - snprintf(key, sizeof(key), "node-name-%d", i); - ret = dict_get_str(dict, key, &node_name); - if (ret) - gf_log("cli", GF_LOG_TRACE, "failed to get node-name"); - - snprintf(key, sizeof(key), "promoted-%d", i); - ret = dict_get_uint64(dict, key, &promoted); - if (ret) - gf_log("cli", GF_LOG_TRACE, "failed to get promoted count"); - - snprintf(key, sizeof(key), "demoted-%d", i); - ret = dict_get_uint64(dict, key, &demoted); - if (ret) - gf_log("cli", GF_LOG_TRACE, "failed to get demoted count"); - - snprintf(key, sizeof(key), "run-time-%d", i); - ret = dict_get_double(dict, key, &elapsed); - if (ret) - gf_log("cli", GF_LOG_TRACE, "failed to get run-time"); - - /* Check for array bound */ - if (status_rcd >= GF_DEFRAG_STATUS_MAX) - status_rcd = GF_DEFRAG_STATUS_MAX; - - hrs = elapsed / 3600; - min = ((int)elapsed % 3600) / 60; - sec = ((int)elapsed % 3600) % 60; - - status_str = cli_vol_task_status_str[status_rcd]; - cli_out("%-20s %-20" PRIu64 " %-20" PRIu64 - " %-20s" - " %d:%d:%d", - node_name, promoted, demoted, status_str, hrs, min, sec); - } - if (down) - cli_out( - "WARNING: glusterd might be down on one or more nodes." - " Please check the nodes that are down using \'gluster" - " peer status\' and start the glusterd on those nodes."); -out: - return ret; -} - int gf_cli_defrag_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -1931,8 +1708,7 @@ gf_cli_defrag_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, } } - if (!((cmd == GF_DEFRAG_CMD_STOP) || (cmd == GF_DEFRAG_CMD_STATUS) || - (cmd == GF_DEFRAG_CMD_STATUS_TIER)) && + if (!((cmd == GF_DEFRAG_CMD_STOP) || (cmd == GF_DEFRAG_CMD_STATUS)) && !(global_state->mode & GLUSTER_MODE_XML)) { ret = dict_get_str(dict, GF_REBALANCE_TID_KEY, &task_id_str); if (ret) { @@ -1947,26 +1723,13 @@ gf_cli_defrag_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, * case since unlock failures can be highlighted * event though rebalance command was successful */ - if (cmd == GF_DEFRAG_CMD_START_TIER) { - snprintf(msg, sizeof(msg), - "Tier " - "start is successful on %s.", - volname); - } else if (cmd == GF_DEFRAG_CMD_STOP_TIER) { - snprintf(msg, sizeof(msg), - "Tier " - "daemon stopped " - "on %s.", - volname); - } else { - snprintf(msg, sizeof(msg), - "Rebalance on %s has been " - "started successfully. Use " - "rebalance status command to" - " check status of the " - "rebalance process.\nID: %s", - volname, task_id_str); - } + snprintf(msg, sizeof(msg), + "Rebalance on %s has been " + "started successfully. Use " + "rebalance status command to" + " check status of the " + "rebalance process.\nID: %s", + volname, task_id_str); } else { snprintf(msg, sizeof(msg), "Starting rebalance on volume %s has " @@ -1999,7 +1762,7 @@ gf_cli_defrag_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, rsp.op_errstr); } } - if (cmd == GF_DEFRAG_CMD_STATUS || cmd == GF_DEFRAG_CMD_STATUS_TIER) { + if (cmd == GF_DEFRAG_CMD_STATUS) { if (rsp.op_ret == -1) { if (strcmp(rsp.op_errstr, "")) snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); @@ -2019,15 +1782,7 @@ gf_cli_defrag_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, goto out; } - if (cmd == GF_DEFRAG_CMD_STATUS_TIER) - ret = gf_cli_print_tier_status(dict, GF_TASK_TYPE_REBALANCE); - else if (cmd == GF_DEFRAG_CMD_DETACH_STATUS) - ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REBALANCE, - _gf_true); - else - ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REBALANCE, - _gf_false); - + ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REBALANCE); if (ret) gf_log("cli", GF_LOG_ERROR, "Failed to print rebalance status"); @@ -2037,23 +1792,9 @@ done: rsp.op_errstr); else { if (rsp.op_ret) - - if (cmd == GF_DEFRAG_CMD_START_TIER || - cmd == GF_DEFRAG_CMD_STATUS_TIER) { - cli_err( - "Tiering Migration Functionality: %s:" - " failed%s%s", - volname, strlen(msg) ? ": " : "", msg); - } else - cli_err("volume rebalance: %s: failed%s%s", volname, - strlen(msg) ? ": " : "", msg); - else if (cmd == GF_DEFRAG_CMD_START_TIER || - cmd == GF_DEFRAG_CMD_STATUS_TIER) { - cli_out( - "Tiering Migration Functionality: %s:" - " success%s%s", - volname, strlen(msg) ? ": " : "", msg); - } else + cli_err("volume rebalance: %s: failed%s%s", volname, + strlen(msg) ? ": " : "", msg); + else cli_out("volume rebalance: %s: success%s%s", volname, strlen(msg) ? ": " : "", msg); } @@ -2242,477 +1983,75 @@ gf_cli_set_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); if (ret < 0) { - gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, - "Failed to decode xdr response"); - goto out; - } - - gf_log("cli", GF_LOG_INFO, "Received resp to set"); - - dict = dict_new(); - - if (!dict) { - ret = -1; - goto out; - } - - ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &dict); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "failed to unserialize volume set respone dict"); - goto out; - } - - /* For brick processes graph change does not happen on the fly. - * The process has to be restarted. So this is a check from the - * volume set option such that if debug xlators such as trace/errorgen - * are provided in the set command, warn the user. - */ - debug_xlator = is_server_debug_xlator(myframe); - - if (dict_get_str(dict, "help-str", &help_str) && !msg[0]) - snprintf(msg, sizeof(msg), "Set volume %s", - (rsp.op_ret) ? "unsuccessful" : "successful"); - if (rsp.op_ret == 0 && debug_xlator) { - snprintf(tmp_str, sizeof(tmp_str), - "\n%s translator has been " - "added to the server volume file. Please restart the" - " volume for enabling the translator", - debug_xlator); - } - - if ((global_state->mode & GLUSTER_MODE_XML) && (help_str == NULL)) { - ret = cli_xml_output_str("volSet", msg, rsp.op_ret, rsp.op_errno, - rsp.op_errstr); - if (ret) - gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); - goto out; - } - - if (rsp.op_ret) { - if (strcmp(rsp.op_errstr, "")) - cli_err("volume set: failed: %s", rsp.op_errstr); - else - cli_err("volume set: failed"); - } else { - if (help_str == NULL) { - if (debug_xlator == NULL) - cli_out("volume set: success"); - else - cli_out("volume set: success%s", tmp_str); - } else { - cli_out("%s", help_str); - } - } - - ret = rsp.op_ret; - -out: - if (dict) - dict_unref(dict); - GF_FREE(debug_xlator); - cli_cmd_broadcast_response(ret); - gf_free_xdr_cli_rsp(rsp); - return ret; -} - -int -gf_cli_add_tier_brick_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gf_cli_rsp rsp = { - 0, - }; - int ret = -1; - char msg[1024] = { - 0, - }; - - GF_VALIDATE_OR_GOTO("cli", myframe, out); - - if (-1 == req->rpc_status) { - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); - if (ret < 0) { - gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, - "Failed to decode xdr response"); - goto out; - } - - gf_log("cli", GF_LOG_INFO, "Received resp to attach tier"); - - if (rsp.op_ret && strcmp(rsp.op_errstr, "")) - snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); - else - snprintf(msg, sizeof(msg), "Attach tier %s", - (rsp.op_ret) ? "unsuccessful" : "successful"); - - if (global_state->mode & GLUSTER_MODE_XML) { - ret = cli_xml_output_str("volAttachTier", msg, rsp.op_ret, rsp.op_errno, - rsp.op_errstr); - if (ret) - gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); - goto out; - } - - if (rsp.op_ret) - cli_err("volume attach-tier: failed: %s", msg); - else - cli_out("volume attach-tier: success"); - ret = rsp.op_ret; - -out: - cli_cmd_broadcast_response(ret); - gf_free_xdr_cli_rsp(rsp); - return ret; -} - -int -gf_cli_attach_tier_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gf_cli_rsp rsp = { - 0, - }; - int ret = -1; - char msg[1024] = { - 0, - }; - - GF_VALIDATE_OR_GOTO("cli", myframe, out); - - if (-1 == req->rpc_status) { - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); - if (ret < 0) { - gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, - "Failed to decode xdr response"); - goto out; - } - - gf_log("cli", GF_LOG_INFO, "Received resp to attach tier"); - - if (rsp.op_ret && strcmp(rsp.op_errstr, "")) - snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); - else - snprintf(msg, sizeof(msg), "Attach tier %s", - (rsp.op_ret) ? "unsuccessful" : "successful"); - - if (global_state->mode & GLUSTER_MODE_XML) { - ret = cli_xml_output_str("volAttachTier", msg, rsp.op_ret, rsp.op_errno, - rsp.op_errstr); - if (ret) - gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); - goto out; - } - - if (rsp.op_ret) - cli_err("volume attach-tier: failed: %s", msg); - else - cli_out("volume attach-tier: success"); - ret = rsp.op_ret; - -out: - cli_cmd_broadcast_response(ret); - gf_free_xdr_cli_rsp(rsp); - return ret; -} - -int -gf_cli_remove_tier_brick_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gf_cli_rsp rsp = { - 0, - }; - int ret = -1; - char msg[1024] = { - 0, - }; - char *cmd_str = "unknown"; - cli_local_t *local = NULL; - call_frame_t *frame = NULL; - char *task_id_str = NULL; - dict_t *rsp_dict = NULL; - int32_t command = 0; - - GF_ASSERT(myframe); - - if (-1 == req->rpc_status) { - goto out; - } - - frame = myframe; - - GF_ASSERT(frame->local); - - local = frame->local; - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); - if (ret < 0) { - gf_log(frame->this->name, GF_LOG_ERROR, - "Failed to decode xdr response"); - goto out; - } - - ret = dict_get_int32(local->dict, "command", &command); - if (ret) { - gf_log("", GF_LOG_ERROR, "failed to get command"); - goto out; - } - - if (rsp.dict.dict_len) { - rsp_dict = dict_new(); - if (!rsp_dict) { - ret = -1; - goto out; - } - - ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &rsp_dict); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "Failed to unserialize rsp_dict"); - goto out; - } - } - - switch (command) { - case GF_DEFRAG_CMD_DETACH_START: - cmd_str = "start"; - - ret = dict_get_str(rsp_dict, GF_REMOVE_BRICK_TID_KEY, &task_id_str); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "remove-brick-id is not present in dict"); - } - break; - case GF_DEFRAG_CMD_DETACH_COMMIT: - cmd_str = "commit"; - break; - case GF_DEFRAG_CMD_DETACH_COMMIT_FORCE: - cmd_str = "commit force"; - break; - case GF_DEFRAG_CMD_DETACH_STOP: - cmd_str = "stop"; - break; - case GF_DEFRAG_CMD_DETACH_STATUS: - cmd_str = "status"; - break; - - default: - cmd_str = "unknown"; - break; - } - - gf_log("cli", GF_LOG_INFO, "Received resp to detach tier"); - - if (rsp.op_ret && strcmp(rsp.op_errstr, "")) - snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); - else - snprintf(msg, sizeof(msg), "Detach tier %s %s", cmd_str, - (rsp.op_ret) ? "unsuccessful" : "successful"); - - ret = rsp.op_ret; - if (global_state->mode & GLUSTER_MODE_XML) { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_true, rsp_dict, rsp.op_ret, rsp.op_errno, msg, "volDetachTier"); - - if (ret) - gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); - goto out; - } else { - if (rsp.op_ret) { - if (strcmp(rsp.op_errstr, "")) - snprintf(msg, sizeof(msg), - "volume tier " - "detach %s: failed: %s", - cmd_str, rsp.op_errstr); - else - snprintf(msg, sizeof(msg), - "volume tier " - "detach %s: failed", - cmd_str); - - cli_err("%s", msg); - goto out; - - } else { - cli_out("volume detach tier %s: success", cmd_str); - if (GF_DEFRAG_CMD_DETACH_START == command && task_id_str != NULL) - cli_out("ID: %s", task_id_str); - if (GF_DEFRAG_CMD_DETACH_COMMIT == command) - cli_out( - "Check the detached bricks to ensure " - "all files are migrated.\nIf files " - "with data are found on the brick " - "path, copy them via a gluster mount " - "point before re-purposing the " - "removed brick. "); - } - } - if (command == GF_DEFRAG_CMD_DETACH_STOP || - command == GF_DEFRAG_CMD_DETACH_STATUS) - ret = gf_cli_print_rebalance_status(rsp_dict, GF_TASK_TYPE_REMOVE_BRICK, - _gf_true); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "Failed to print remove-brick " - "rebalance status"); - goto out; - } - - if ((command == GF_DEFRAG_CMD_DETACH_STOP) && (rsp.op_ret == 0)) { - cli_out( - "'detach tier' process may be in the middle of a " - "file migration.\nThe process will be fully stopped " - "once the migration of the file is complete.\nPlease " - "check detach tier process for completion before " - "doing any further brick related tasks on the " - "volume."); - } - ret = rsp.op_ret; - -out: - cli_cmd_broadcast_response(ret); - gf_free_xdr_cli_rsp(rsp); - - if (rsp_dict) - dict_unref(rsp_dict); - return ret; -} - -int -gf_cli_detach_tier_status_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gf_cli_rsp rsp = { - 0, - }; - int ret = -1; - dict_t *dict = NULL; - char msg[1024] = { - 0, - }; - int32_t command = 0; - gf1_op_commands cmd = GF_OP_CMD_NONE; - cli_local_t *local = NULL; - call_frame_t *frame = NULL; - char *cmd_str = "unknown"; - - GF_ASSERT(myframe); - - if (-1 == req->rpc_status) { - goto out; - } - - frame = myframe; - - GF_ASSERT(frame->local); - - local = frame->local; - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); - if (ret < 0) { - gf_log(frame->this->name, GF_LOG_ERROR, + gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, "Failed to decode xdr response"); goto out; } - ret = dict_get_int32(local->dict, "command", &command); - if (ret) - goto out; + gf_log("cli", GF_LOG_INFO, "Received resp to set"); - cmd = command; + dict = dict_new(); - switch (cmd) { - case GF_OP_CMD_STOP_DETACH_TIER: - cmd_str = "stop"; - break; - case GF_OP_CMD_STATUS: - cmd_str = "status"; - break; - default: - break; + if (!dict) { + ret = -1; + goto out; } - ret = rsp.op_ret; - if (rsp.op_ret == -1) { - if (strcmp(rsp.op_errstr, "")) - snprintf(msg, sizeof(msg), - "volume tier detach %s: " - "failed: %s", - cmd_str, rsp.op_errstr); - else - snprintf(msg, sizeof(msg), - "volume tier detach %s: " - "failed", - cmd_str); - - if (global_state->mode & GLUSTER_MODE_XML) - goto xml_output; - - cli_err("%s", msg); + ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &dict); + if (ret) { + gf_log("cli", GF_LOG_ERROR, + "failed to unserialize volume set respone dict"); goto out; } - if (rsp.dict.dict_len) { - /* Unserialize the dictionary */ - dict = dict_new(); - - ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &dict); - if (ret < 0) { - strncpy(msg, - "failed to unserialize req-buffer to " - "dictionary", - sizeof(msg)); - - if (global_state->mode & GLUSTER_MODE_XML) { - rsp.op_ret = -1; - goto xml_output; - } + /* For brick processes graph change does not happen on the fly. + * The process has to be restarted. So this is a check from the + * volume set option such that if debug xlators such as trace/errorgen + * are provided in the set command, warn the user. + */ + debug_xlator = is_server_debug_xlator(myframe); - gf_log("cli", GF_LOG_ERROR, "%s", msg); - goto out; - } - } -xml_output: - if (global_state->mode & GLUSTER_MODE_XML) { - if (strcmp(rsp.op_errstr, "")) { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_true, dict, rsp.op_ret, rsp.op_errno, rsp.op_errstr, - "volDetachTier"); - } else { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_true, dict, rsp.op_ret, rsp.op_errno, msg, "volDetachTier"); - } - goto out; + if (dict_get_str(dict, "help-str", &help_str) && !msg[0]) + snprintf(msg, sizeof(msg), "Set volume %s", + (rsp.op_ret) ? "unsuccessful" : "successful"); + if (rsp.op_ret == 0 && debug_xlator) { + snprintf(tmp_str, sizeof(tmp_str), + "\n%s translator has been " + "added to the server volume file. Please restart the" + " volume for enabling the translator", + debug_xlator); } - ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REMOVE_BRICK, - _gf_true); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "Failed to print remove-brick " - "rebalance status"); + if ((global_state->mode & GLUSTER_MODE_XML) && (help_str == NULL)) { + ret = cli_xml_output_str("volSet", msg, rsp.op_ret, rsp.op_errno, + rsp.op_errstr); + if (ret) + gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); goto out; } - if ((cmd == GF_OP_CMD_STOP_DETACH_TIER) && (rsp.op_ret == 0)) { - cli_out( - "'detach tier' process may be in the middle of a " - "file migration.\nThe process will be fully stopped " - "once the migration of the file is complete.\nPlease " - "check detach tier process for completion before " - "doing any further brick related tasks on the " - "volume."); + if (rsp.op_ret) { + if (strcmp(rsp.op_errstr, "")) + cli_err("volume set: failed: %s", rsp.op_errstr); + else + cli_err("volume set: failed"); + } else { + if (help_str == NULL) { + if (debug_xlator == NULL) + cli_out("volume set: success"); + else + cli_out("volume set: success%s", tmp_str); + } else { + cli_out("%s", help_str); + } } + ret = rsp.op_ret; + out: if (dict) dict_unref(dict); + GF_FREE(debug_xlator); cli_cmd_broadcast_response(ret); gf_free_xdr_cli_rsp(rsp); return ret; @@ -2869,19 +2208,18 @@ gf_cli3_remove_brick_status_cbk(struct rpc_req *req, struct iovec *iov, xml_output: if (global_state->mode & GLUSTER_MODE_XML) { if (strcmp(rsp.op_errstr, "")) { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_true, dict, rsp.op_ret, rsp.op_errno, rsp.op_errstr, - "volRemoveBrick"); + ret = cli_xml_output_vol_remove_brick(_gf_true, dict, rsp.op_ret, + rsp.op_errno, rsp.op_errstr, + "volRemoveBrick"); } else { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_true, dict, rsp.op_ret, rsp.op_errno, msg, - "volRemoveBrick"); + ret = cli_xml_output_vol_remove_brick(_gf_true, dict, rsp.op_ret, + rsp.op_errno, msg, + "volRemoveBrick"); } goto out; } - ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REMOVE_BRICK, - _gf_false); + ret = gf_cli_print_rebalance_status(dict, GF_TASK_TYPE_REMOVE_BRICK); if (ret) { gf_log("cli", GF_LOG_ERROR, "Failed to print remove-brick " @@ -2995,9 +2333,9 @@ gf_cli_remove_brick_cbk(struct rpc_req *req, struct iovec *iov, int count, (rsp.op_ret) ? "unsuccessful" : "successful"); if (global_state->mode & GLUSTER_MODE_XML) { - ret = cli_xml_output_vol_remove_brick_detach_tier( - _gf_false, rsp_dict, rsp.op_ret, rsp.op_errno, msg, - "volRemoveBrick"); + ret = cli_xml_output_vol_remove_brick(_gf_false, rsp_dict, rsp.op_ret, + rsp.op_errno, msg, + "volRemoveBrick"); if (ret) gf_log("cli", GF_LOG_ERROR, "Error outputting to xml"); goto out; @@ -4909,182 +4247,6 @@ out: return ret; } -int32_t -gf_cli_tier(call_frame_t *frame, xlator_t *this, void *data) -{ - int ret = 0; - int32_t command = 0; - gf_cli_req req = {{ - 0, - }}; - dict_t *dict = NULL; - - if (!frame || !this || !data) { - ret = -1; - goto out; - } - dict = data; - - ret = dict_get_int32(dict, "rebalance-command", &command); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "Failed to get rebalance-command"); - goto out; - } - - ret = cli_to_glusterd(&req, frame, gf_cli_defrag_volume_cbk, - (xdrproc_t)xdr_gf_cli_req, dict, GLUSTER_CLI_TIER, - this, cli_rpc_prog, NULL); - -out: - gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); - - GF_FREE(req.dict.dict_val); - - return ret; -} - -int32_t -gf_cli_add_tier_brick(call_frame_t *frame, xlator_t *this, void *data) -{ - gf_cli_req req = {{ - 0, - }}; - int ret = 0; - dict_t *dict = NULL; - - if (!frame || !this || !data) { - ret = -1; - goto out; - } - - dict = data; - - ret = cli_to_glusterd(&req, frame, gf_cli_add_tier_brick_cbk, - (xdrproc_t)xdr_gf_cli_req, dict, - GLUSTER_CLI_ADD_TIER_BRICK, this, cli_rpc_prog, NULL); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "Failed to send request to " - "glusterd"); - goto out; - } - -out: - gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); - - GF_FREE(req.dict.dict_val); - return ret; -} - -int32_t -gf_cli_attach_tier(call_frame_t *frame, xlator_t *this, void *data) -{ - gf_cli_req req = {{ - 0, - }}; - int ret = 0; - dict_t *dict = NULL; - dict_t *newdict = NULL; - char *tierwords[] = {"volume", "tier", "", "start", NULL}; - const char **words = (const char **)tierwords; - char *volname = NULL; - cli_local_t *local = NULL; - cli_local_t *oldlocal = NULL; - - if (!frame || !this || !data) { - ret = -1; - goto out; - } - - dict = data; - - ret = cli_to_glusterd(&req, frame, gf_cli_attach_tier_cbk, - (xdrproc_t)xdr_gf_cli_req, dict, - GLUSTER_CLI_ATTACH_TIER, this, cli_rpc_prog, NULL); - if (ret) - goto out; - ret = dict_get_str(dict, "volname", &volname); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "Failed to get volume name"); - goto notify_cli; - } - - words[2] = volname; - ret = cli_cmd_volume_old_tier_parse((const char **)words, 4, &newdict); - if (ret) { - gf_log("cli", GF_LOG_ERROR, - "Failed to parse tier start " - "command"); - goto notify_cli; - } - - gf_log("cli", GF_LOG_DEBUG, "Sending tier start"); - - oldlocal = frame->local; - CLI_LOCAL_INIT(local, words, frame, newdict); - ret = gf_cli_tier(frame, this, newdict); - frame->local = oldlocal; - cli_local_wipe(local); - -notify_cli: - if (ret) { - cli_out( - "Failed to run tier start. Please execute tier start " - "command explicitly"); - cli_out("Usage : gluster volume tier start"); - } - -out: - gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); - - GF_FREE(req.dict.dict_val); - return ret; -} - -int32_t -gf_cli_remove_tier_brick(call_frame_t *frame, xlator_t *this, void *data) -{ - gf_cli_req status_req = {{ - 0, - }}; - int ret = 0; - dict_t *dict = NULL; - int32_t command = 0; - char *volname = NULL; - - if (!frame || !this || !data) { - ret = -1; - goto out; - } - - dict = data; - - ret = dict_get_str(dict, "volname", &volname); - if (ret) - goto out; - - ret = dict_get_int32(dict, "command", &command); - if (ret) - goto out; - - ret = dict_set_int32(dict, "rebalance-command", (int32_t)command); - if (ret) { - gf_log(this->name, GF_LOG_ERROR, "Failed to set dict"); - goto out; - } - - ret = cli_to_glusterd(&status_req, frame, gf_cli_remove_tier_brick_cbk, - (xdrproc_t)xdr_gf_cli_req, dict, GLUSTER_CLI_TIER, - this, cli_rpc_prog, NULL); - -out: - gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); - - GF_FREE(status_req.dict.dict_val); - - return ret; -} - int32_t gf_cli_remove_brick(call_frame_t *frame, xlator_t *this, void *data) { @@ -7279,7 +6441,6 @@ cli_print_volume_status_client_list(dict_t *dict, gf_boolean_t notbrick) char *name = NULL; gf_boolean_t is_fuse_done = _gf_false; gf_boolean_t is_gfapi_done = _gf_false; - gf_boolean_t is_tierd_done = _gf_false; gf_boolean_t is_rebalance_done = _gf_false; gf_boolean_t is_glustershd_done = _gf_false; gf_boolean_t is_quotad_done = _gf_false; @@ -7323,16 +6484,6 @@ cli_print_volume_status_client_list(dict_t *dict, gf_boolean_t notbrick) goto print; } continue; - } else if (!strcmp(name, "tierd")) { - if (!is_tierd_done) { - is_tierd_done = _gf_true; - ret = dict_get_int32(dict, "tierd-count", ¤t_count); - if (ret) - goto out; - total = total + current_count; - goto print; - } - continue; } else if (!strcmp(name, "rebalance")) { if (!is_rebalance_done) { is_rebalance_done = _gf_true; @@ -8291,8 +7442,7 @@ gf_cli_status_cbk(struct rpc_req *req, struct iovec *iov, int count, if ((cmd & GF_CLI_STATUS_NFS) || (cmd & GF_CLI_STATUS_SHD) || (cmd & GF_CLI_STATUS_QUOTAD) || (cmd & GF_CLI_STATUS_SNAPD) || - (cmd & GF_CLI_STATUS_BITD) || (cmd & GF_CLI_STATUS_SCRUB) || - (cmd & GF_CLI_STATUS_TIERD)) + (cmd & GF_CLI_STATUS_BITD) || (cmd & GF_CLI_STATUS_SCRUB)) notbrick = _gf_true; if (global_state->mode & GLUSTER_MODE_XML) { @@ -8398,13 +7548,7 @@ gf_cli_status_cbk(struct rpc_req *req, struct iovec *iov, int count, "Gluster process", "TCP Port", "RDMA Port", "Online", "Pid"); cli_print_line(CLI_BRICK_STATUS_LINE_LEN); } - if (type == GF_CLUSTER_TYPE_TIER) { - cli_out("Hot Bricks:"); - } for (i = 0; i <= index_max; i++) { - if (type == GF_CLUSTER_TYPE_TIER && i == hot_brick_count) { - cli_out("Cold Bricks:"); - } status.rdma_port = 0; snprintf(key, sizeof(key), "brick%d.hostname", i); @@ -8426,8 +7570,7 @@ gf_cli_status_cbk(struct rpc_req *req, struct iovec *iov, int count, !strcmp(hostname, "Quota Daemon") || !strcmp(hostname, "Snapshot Daemon") || !strcmp(hostname, "Scrubber Daemon") || - !strcmp(hostname, "Bitrot Daemon") || - !strcmp(hostname, "Tier Daemon")) + !strcmp(hostname, "Bitrot Daemon")) snprintf(status.brick, PATH_MAX + 255, "%s on %s", hostname, path); else { snprintf(key, sizeof(key), "brick%d.rdma_port", i); @@ -12182,12 +11325,9 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = { [GLUSTER_CLI_BARRIER_VOLUME] = {"BARRIER VOLUME", gf_cli_barrier_volume}, [GLUSTER_CLI_GET_VOL_OPT] = {"GET_VOL_OPT", gf_cli_get_vol_opt}, [GLUSTER_CLI_BITROT] = {"BITROT", gf_cli_bitrot}, - [GLUSTER_CLI_ATTACH_TIER] = {"ATTACH_TIER", gf_cli_attach_tier}, - [GLUSTER_CLI_TIER] = {"TIER", gf_cli_tier}, [GLUSTER_CLI_GET_STATE] = {"GET_STATE", gf_cli_get_state}, [GLUSTER_CLI_RESET_BRICK] = {"RESET_BRICK", gf_cli_reset_brick}, - [GLUSTER_CLI_REMOVE_TIER_BRICK] = {"DETACH_TIER", gf_cli_remove_tier_brick}, - [GLUSTER_CLI_ADD_TIER_BRICK] = {"ADD_TIER_BRICK", gf_cli_add_tier_brick}}; +}; struct rpc_clnt_program cli_prog = { .progname = "Gluster CLI", diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 54458987d9..ce5c9cd6cc 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -1526,7 +1526,6 @@ cli_xml_output_vol_status(cli_local_t *local, dict_t *dict) gf_boolean_t node_present = _gf_true; int i; int type = -1; - int hot_brick_count = -1; /* */ ret = xmlTextWriterStartElement(local->writer, (xmlChar *)"volume"); @@ -1564,23 +1563,7 @@ cli_xml_output_vol_status(cli_local_t *local, dict_t *dict) if (ret) goto out; - if (type == GF_CLUSTER_TYPE_TIER) { - ret = dict_get_int32(dict, "hot_brick_count", &hot_brick_count); - if (ret) - goto out; - - ret = xmlTextWriterStartElement(local->writer, (xmlChar *)"hotBricks"); - XML_RET_CHECK_AND_GOTO(ret, out); - } for (i = 0; i <= index_max; i++) { - if (type == GF_CLUSTER_TYPE_TIER && i == hot_brick_count) { - /* */ - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"coldBricks"); - XML_RET_CHECK_AND_GOTO(ret, out); - } ret = cli_xml_output_vol_status_common(local->writer, dict, i, &online, &node_present); if (ret) { @@ -1646,12 +1629,6 @@ cli_xml_output_vol_status(cli_local_t *local, dict_t *dict) /* was opened in cli_xml_output_vol_status_common()*/ ret = xmlTextWriterEndElement(local->writer); XML_RET_CHECK_AND_GOTO(ret, out); - - /* */ - if (type == GF_CLUSTER_TYPE_TIER && i == brick_index_max) { - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - } } /* Tasks are only present when a normal volume status call is done on a @@ -2471,24 +2448,6 @@ cli_xml_output_vol_info(cli_local_t *local, dict_t *dict) int j = 1; char *caps __attribute__((unused)) = NULL; int k __attribute__((unused)) = 0; - int index = 1; - int tier_vol_type = 0; - /* hot dist count is always zero so need for it to be - * included in the array.*/ - int hot_dist_count = 0; - values c = 0; - char *keys[MAX] = { - [COLD_BRICK_COUNT] = "volume%d.cold_brick_count", - [COLD_TYPE] = "volume%d.cold_type", - [COLD_DIST_COUNT] = "volume%d.cold_dist_count", - [COLD_REPLICA_COUNT] = "volume%d.cold_replica_count", - [COLD_ARBITER_COUNT] = "volume%d.cold_arbiter_count", - [COLD_DISPERSE_COUNT] = "volume%d.cold_disperse_count", - [COLD_REDUNDANCY_COUNT] = "volume%d.cold_redundancy_count", - [HOT_BRICK_COUNT] = "volume%d.hot_brick_count", - [HOT_TYPE] = "volume%d.hot_type", - [HOT_REPLICA_COUNT] = "volume%d.hot_replica_count"}; - int value[MAX] = {}; ret = dict_get_int32(dict, "count", &count); if (ret) @@ -2624,246 +2583,47 @@ cli_xml_output_vol_info(cli_local_t *local, dict_t *dict) ret = xmlTextWriterStartElement(local->writer, (xmlChar *)"bricks"); XML_RET_CHECK_AND_GOTO(ret, out); - if (type == GF_CLUSTER_TYPE_TIER) { - /*the values for hot stripe, disperse and redundancy - * should not be looped in here as they are zero - * always */ - for (c = COLD_BRICK_COUNT; c < MAX; c++) { - snprintf(key, 256, keys[c], i); - ret = dict_get_int32(dict, key, &value[c]); - if (ret) - goto out; - } - - hot_dist_count = (value[HOT_REPLICA_COUNT] - ? value[HOT_REPLICA_COUNT] - : 1); - - tier_vol_type = get_vol_type(value[HOT_TYPE], hot_dist_count, - value[HOT_BRICK_COUNT]); - - if ((value[HOT_TYPE] != GF_CLUSTER_TYPE_TIER) && - (value[HOT_TYPE] > 0) && - (hot_dist_count < value[HOT_BRICK_COUNT])) - tier_vol_type = value[HOT_TYPE] + GF_CLUSTER_TYPE_MAX - 1; - - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"hotBricks"); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"hotBrickType", "%s", - vol_type_str[tier_vol_type]); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"hotreplicaCount", "%d", - value[HOT_REPLICA_COUNT]); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement(local->writer, - (xmlChar *)"hotbrickCount", - "%d", value[HOT_BRICK_COUNT]); - XML_RET_CHECK_AND_GOTO(ret, out); - - if (value[HOT_TYPE] == GF_CLUSTER_TYPE_NONE || - value[HOT_TYPE] == GF_CLUSTER_TYPE_TIER) { - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"numberOfBricks", "%d", - value[HOT_BRICK_COUNT]); - } else { - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"numberOfBricks", "%d x %d = %d", - (value[HOT_BRICK_COUNT] / hot_dist_count), hot_dist_count, - value[HOT_BRICK_COUNT]); - } + while (j <= brick_count) { + ret = xmlTextWriterStartElement(local->writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO(ret, out); - while (index <= value[HOT_BRICK_COUNT]) { - snprintf(key, 1024, "volume%d.brick%d", i, index); - ret = dict_get_str(dict, key, &brick); - if (ret) - goto out; - - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"brick"); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d.uuid", i, index); - ret = dict_get_str(dict, key, &uuid); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatAttribute( - local->writer, (xmlChar *)"uuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatString(local->writer, "%s", - brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"name", "%s", brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"hostUuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - - index++; - } - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - - tier_vol_type = get_vol_type(value[COLD_TYPE], - value[COLD_DIST_COUNT], - value[COLD_BRICK_COUNT]); - - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"coldBricks"); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"coldBrickType", "%s", - vol_type_str[tier_vol_type]); + snprintf(key, sizeof(key), "volume%d.brick%d.uuid", i, j); + ret = dict_get_str(dict, key, &uuid); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatAttribute( + local->writer, (xmlChar *)"uuid", "%s", uuid); XML_RET_CHECK_AND_GOTO(ret, out); - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"coldreplicaCount", "%d", - value[COLD_REPLICA_COUNT]); + snprintf(key, sizeof(key), "volume%d.brick%d", i, j); + ret = dict_get_str(dict, key, &brick); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatString(local->writer, "%s", brick); XML_RET_CHECK_AND_GOTO(ret, out); ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"coldarbiterCount", "%d", - value[COLD_ARBITER_COUNT]); + local->writer, (xmlChar *)"name", "%s", brick); XML_RET_CHECK_AND_GOTO(ret, out); ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"coldbrickCount", "%d", - value[COLD_BRICK_COUNT]); + local->writer, (xmlChar *)"hostUuid", "%s", uuid); XML_RET_CHECK_AND_GOTO(ret, out); + snprintf(key, sizeof(key), "volume%d.brick%d.isArbiter", i, j); + if (dict_get(dict, key)) + isArbiter = 1; + else + isArbiter = 0; ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"colddisperseCount", "%d", - value[COLD_DISPERSE_COUNT]); + local->writer, (xmlChar *)"isArbiter", "%d", isArbiter); XML_RET_CHECK_AND_GOTO(ret, out); - if (value[COLD_TYPE] == GF_CLUSTER_TYPE_NONE || - value[COLD_TYPE] == GF_CLUSTER_TYPE_TIER) { - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"numberOfBricks", "%d", - value[COLD_BRICK_COUNT]); - } else if (value[COLD_TYPE] == GF_CLUSTER_TYPE_DISPERSE) { - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"numberOfBricks", - " %d x (%d + %d) = %d", - (value[COLD_BRICK_COUNT] / value[COLD_DIST_COUNT]), - value[COLD_DISPERSE_COUNT] - value[COLD_REDUNDANCY_COUNT], - value[COLD_REDUNDANCY_COUNT], value[COLD_BRICK_COUNT]); - } else { - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"numberOfBricks", "%d x %d = %d", - (value[COLD_BRICK_COUNT] / value[COLD_DIST_COUNT]), - value[COLD_DIST_COUNT], value[COLD_BRICK_COUNT]); - } - XML_RET_CHECK_AND_GOTO(ret, out); - index = value[HOT_BRICK_COUNT] + 1; - - while (index <= brick_count) { - snprintf(key, 1024, "volume%d.brick%d", i, index); - ret = dict_get_str(dict, key, &brick); - if (ret) - goto out; - - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"brick"); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d.uuid", i, index); - ret = dict_get_str(dict, key, &uuid); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatAttribute( - local->writer, (xmlChar *)"uuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatString(local->writer, "%s", - brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"name", "%s", brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"hostUuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d.isArbiter", i, - index); - if (dict_get(dict, key)) - isArbiter = 1; - else - isArbiter = 0; - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"isArbiter", "%d", isArbiter); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - - index++; - } + /* */ ret = xmlTextWriterEndElement(local->writer); XML_RET_CHECK_AND_GOTO(ret, out); - } else { - while (j <= brick_count) { - ret = xmlTextWriterStartElement(local->writer, - (xmlChar *)"brick"); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d.uuid", i, j); - ret = dict_get_str(dict, key, &uuid); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatAttribute( - local->writer, (xmlChar *)"uuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d", i, j); - ret = dict_get_str(dict, key, &brick); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatString(local->writer, "%s", - brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"name", "%s", brick); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"hostUuid", "%s", uuid); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "volume%d.brick%d.isArbiter", i, j); - if (dict_get(dict, key)) - isArbiter = 1; - else - isArbiter = 0; - ret = xmlTextWriterWriteFormatElement( - local->writer, (xmlChar *)"isArbiter", "%d", isArbiter); - XML_RET_CHECK_AND_GOTO(ret, out); - - /* */ - ret = xmlTextWriterEndElement(local->writer); - XML_RET_CHECK_AND_GOTO(ret, out); - - j++; - } + j++; } /* */ ret = xmlTextWriterEndElement(local->writer); @@ -3385,90 +3145,6 @@ cli_xml_output_vol_rebalance_status(xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterEndElement(writer); XML_RET_CHECK_AND_GOTO(ret, out); -out: - gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); - return ret; -} - -int -cli_xml_output_vol_tier_status(xmlTextWriterPtr writer, dict_t *dict, - enum gf_task_types task_type) -{ - int ret = -1; - int count = 0; - char *node_name = NULL; - char *status_str = NULL; - uint64_t promoted = 0; - uint64_t demoted = 0; - int i = 1; - char key[1024] = { - 0, - }; - gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; - - GF_VALIDATE_OR_GOTO("cli", dict, out); - - ret = dict_get_int32(dict, "count", &count); - if (ret) { - gf_log("cli", GF_LOG_ERROR, "count not set"); - goto out; - } - - ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"nodeCount", "%d", - count); - XML_RET_CHECK_AND_GOTO(ret, out); - - while (i <= count) { - promoted = 0; - node_name = NULL; - demoted = 0; - - ret = xmlTextWriterStartElement(writer, (xmlChar *)"node"); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "node-name-%d", i); - ret = dict_get_str(dict, key, &node_name); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"nodeName", - "%s", node_name); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "promoted-%d", i); - ret = dict_get_uint64(dict, key, &promoted); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatElement (writer, - (xmlChar *)"promoted" - "Files", "%"PRIu64, - promoted); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "demoted-%d", i); - ret = dict_get_uint64(dict, key, &demoted); - if (ret) - goto out; - ret = xmlTextWriterWriteFormatElement (writer, - (xmlChar *)"demoted" - "Files", "%"PRIu64, - demoted); - XML_RET_CHECK_AND_GOTO(ret, out); - - snprintf(key, sizeof(key), "status-%d", i); - ret = dict_get_int32(dict, key, (int32_t *)&status_rcd); - - status_str = cli_vol_task_status_str[status_rcd]; - - ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"statusStr", - "%s", status_str); - XML_RET_CHECK_AND_GOTO(ret, out); - - ret = xmlTextWriterEndElement(writer); - XML_RET_CHECK_AND_GOTO(ret, out); - - i++; - } - out: gf_log("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -3507,12 +3183,6 @@ cli_xml_output_vol_rebalance(gf_cli_defrag_type op, dict_t *dict, int op_ret, ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"op", "%d", op); XML_RET_CHECK_AND_GOTO(ret, out); - if (GF_DEFRAG_CMD_STATUS_TIER == op) { - ret = cli_xml_output_vol_tier_status(writer, dict, - GF_TASK_TYPE_REBALANCE); - if (ret) - goto out; - } if ((GF_DEFRAG_CMD_STOP == op) || (GF_DEFRAG_CMD_STATUS == op)) { ret = cli_xml_output_vol_rebalance_status(writer, dict, GF_TASK_TYPE_REBALANCE); @@ -3535,10 +3205,9 @@ out: } int -cli_xml_output_vol_remove_brick_detach_tier(gf_boolean_t status_op, - dict_t *dict, int op_ret, - int op_errno, char *op_errstr, - const char *op) +cli_xml_output_vol_remove_brick(gf_boolean_t status_op, dict_t *dict, + int op_ret, int op_errno, char *op_errstr, + const char *op) { #if (HAVE_LIB_XML) int ret = -1; diff --git a/cli/src/cli.c b/cli/src/cli.c index ba5daba9be..4ac7d9e3fb 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -377,8 +377,6 @@ cli_opt_parse(char *opt, struct cli_state *state) " bitrot commands\n" " volume quota help - display help for volume" " quota commands\n" - " volume tier help - display help for volume" - " tier commands\n" " snapshot help - display help for snapshot commands\n" " global help - list global commands\n"); exit(0); diff --git a/cli/src/cli.h b/cli/src/cli.h index b79a0a235f..542aedd66f 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -289,17 +289,6 @@ int32_t cli_cmd_volume_add_brick_parse(struct cli_state *state, const char **words, int wordcount, dict_t **options, int *type); -int32_t -cli_cmd_volume_detach_tier_parse(const char **words, int wordcount, - dict_t **options, int *question); - -int32_t -cli_cmd_volume_tier_parse(const char **words, int wordcount, dict_t **options); - -int32_t -cli_cmd_volume_old_tier_parse(const char **words, int wordcount, - dict_t **options); - int32_t cli_cmd_volume_remove_brick_parse(struct cli_state *state, const char **words, int wordcount, dict_t **options, @@ -445,10 +434,9 @@ cli_xml_output_vol_rebalance(gf_cli_defrag_type op, dict_t *dict, int op_ret, int op_errno, char *op_errstr); int -cli_xml_output_vol_remove_brick_detach_tier(gf_boolean_t status_op, - dict_t *dict, int op_ret, - int op_errno, char *op_errstr, - const char *op); +cli_xml_output_vol_remove_brick(gf_boolean_t status_op, dict_t *dict, + int op_ret, int op_errno, char *op_errstr, + const char *op); int cli_xml_output_vol_replace_brick(dict_t *dict, int op_ret, int op_errno, -- cgit