diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2014-01-14 17:00:14 +0000 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2014-01-14 17:00:14 +0000 |
commit | 455791f265e6e581fa4ebddd5dc4642b2201f8ce (patch) | |
tree | ebd5cad9534291822f8c47dbbc8162525f8fe92e /cli | |
parent | 92eaa72ea4cd0d06c2161842c548008db0eee01c (diff) | |
parent | 7d89ec77763dc5076379753c736f7fce2bedd9ec (diff) |
Merge branch 'upstream' into merge
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 43 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 35 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 258 | ||||
-rw-r--r-- | cli/src/cli-xml-output.c | 13 | ||||
-rw-r--r-- | cli/src/cli.h | 14 |
5 files changed, 108 insertions, 255 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 8a37d8e78..dd9398184 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -38,13 +38,6 @@ str_getunamb (const char *tok, char **opwords) return (char *)cli_getunamb (tok, (void **)opwords, id_sel); } -static inline gf_boolean_t -cli_is_quota_cmd (char *key) -{ - return ((strcmp (key, "quota") == 0) || - (strcmp (key, "features.quota") == 0)); -} - int32_t cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index, char **bricks, int *brick_count) @@ -865,11 +858,6 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, char *value = NULL; int i = 0; char str[50] = {0,}; - char *true_keys[] = {"on", "enable", "yes", - "true", "1", NULL}; - char *false_keys[] = {"off", "disable", "no", - "false", "0", NULL}; - char *w1 = NULL, *w2 = NULL; GF_ASSERT (words); GF_ASSERT (options); @@ -922,25 +910,6 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options, if (ret == 0) *options = dict; goto out; - } else if (wordcount == 5 && cli_is_quota_cmd ((char *)words[3])) { - value = (char *)words[4]; - w1 = str_getunamb (value, true_keys); - w2 = str_getunamb (value, false_keys); - if (w1 != NULL) { - gf_asprintf (op_errstr,"'gluster volume set <VOLNAME> " - "%s %s' is deprecated. Use 'gluster " - "volume quota <VOLNAME> enable' instead.", - (char *)words[3], w1); - ret = -1; - goto out; - } else if (w2 != NULL) { - gf_asprintf (op_errstr,"'gluster volume set <VOLNAME> " - "%s %s' is deprecated. Use 'gluster " - "volume quota <VOLNAME> disable' instead.", - (char *)words[3], w2); - ret = -1; - goto out; - } } for (i = 3; i < wordcount; i+=2) { @@ -1737,13 +1706,13 @@ config_parse (const char **words, int wordcount, dict_t *dict, } append_str[append_len - 2] = '\0'; /* "checkpoint now" is special: we resolve that "now" */ - if (strcmp (words[cmdi + 1], "checkpoint") == 0 && - strcmp (append_str, "now") == 0) { + if ((strcmp (words[cmdi + 1], "checkpoint") == 0) && + (strcmp (append_str, "now") == 0)) { struct timeval tv = {0,}; ret = gettimeofday (&tv, NULL); if (ret == -1) - goto out; /* FIXME: free append_str? */ + goto out; GF_FREE (append_str); append_str = GF_CALLOC (1, 300, cli_mt_append_str); @@ -1751,10 +1720,8 @@ config_parse (const char **words, int wordcount, dict_t *dict, ret = -1; goto out; } - strcpy (append_str, "as of "); - gf_time_fmt (append_str + strlen ("as of "), - 300 - strlen ("as of "), - tv.tv_sec, gf_timefmt_FT); + snprintf (append_str, 300, "now:%ld.%06ld", + tv.tv_sec, tv.tv_usec); } ret = dict_set_dynstr (dict, "op_value", append_str); diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index f3b1828a0..a7e72dabd 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -349,6 +349,11 @@ cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word, int32_t sub_count = 0; int32_t type = GF_CLUSTER_TYPE_NONE; cli_local_t *local = NULL; + char *trans_type = NULL; + char *question = "RDMA transport is" + " recommended only for testing purposes" + " in this release. Do you want to continue?"; + gf_answer_t answer = GF_ANSWER_NO; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_CREATE_VOLUME]; @@ -395,6 +400,22 @@ cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word, } } + + ret = dict_get_str (options, "transport", &trans_type); + if (ret) { + gf_log("cli", GF_LOG_ERROR, "Unable to get transport type"); + goto out; + } + + if (strcasestr (trans_type, "rdma")) { + answer = + cli_cmd_get_confirmation (state, question); + if (GF_ANSWER_NO == answer) { + ret = 0; + goto out; + } + } + if (state->mode & GLUSTER_MODE_WIGNORE) { ret = dict_set_int32 (options, "force", _gf_true); if (ret) { @@ -1533,6 +1554,11 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state, int sent = 0; int parse_error = 0; cli_local_t *local = NULL; + int replace_op = 0; + char *q = "All replace-brick commands except " + "commit force are deprecated. " + "Do you want to continue?"; + gf_answer_t answer = GF_ANSWER_NO; #ifdef GF_SOLARIS_HOST_OS cli_out ("Command not supported on Solaris"); @@ -1552,6 +1578,15 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state, goto out; } + ret = dict_get_int32 (options, "operation", &replace_op); + if (replace_op != GF_REPLACE_OP_COMMIT_FORCE) { + answer = cli_cmd_get_confirmation (state, q); + if (GF_ANSWER_NO == answer) { + ret = 0; + goto out; + } + } + if (state->mode & GLUSTER_MODE_WIGNORE) { ret = dict_set_int32 (options, "force", _gf_true); if (ret) { diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 2cb0ba3d4..d1b39014d 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3874,85 +3874,22 @@ gf_cli_gsync_config_command (dict_t *dict) return runner_run (&runner); } -int -gf_cli_fetch_gsyncd_status_values (char *status, - gf_cli_gsync_status_t *sts_val) -{ - int32_t ret = -1; - char *tmp = NULL; - char *save_ptr = NULL; - char *key = NULL; - char *value = NULL; - - if (!status || !sts_val) { - gf_log ("", GF_LOG_ERROR, "status or sts_val is null"); - goto out; - } - - tmp = strtok_r (status, "\n", &save_ptr); - - if (tmp) - sts_val->health = gf_strdup (tmp); - - while (tmp) { - key = strtok_r (tmp, "=", &value); - - if ((key) && (!strcmp(key, "Uptime"))) - sts_val->uptime = gf_strdup (value); - - if ((key) && (!strcmp(key, "FilesSyncd"))) - sts_val->files_syncd = gf_strdup (value); - - if ((key) && (!strcmp(key, "FilesPending"))) - sts_val->files_pending = gf_strdup (value); - - if ((key) && (!strcmp(key, "BytesPending"))) { - value = gf_uint64_2human_readable(atol(value)); - sts_val->bytes_pending = gf_strdup (value); - } - - if ((key) && (!strcmp(key, "DeletesPending"))) - sts_val->deletes_pending = gf_strdup (value); - - tmp = strtok_r (NULL, ";", &save_ptr); - } - - if (sts_val->health) - ret = 0; - - if (!sts_val->uptime) - sts_val->uptime = gf_strdup ("N/A"); - - if (!sts_val->files_syncd) - sts_val->files_syncd = gf_strdup ("N/A"); - - if (!sts_val->files_pending) - sts_val->files_pending = gf_strdup ("N/A"); - - if (!sts_val->bytes_pending) - sts_val->bytes_pending = gf_strdup ("N/A"); - - if (!sts_val->deletes_pending) - sts_val->deletes_pending = gf_strdup ("N/A"); - -out: - gf_log ("", GF_LOG_DEBUG, "Returning %d.", ret); - return ret; -} - char* -get_struct_variable (int mem_num, gf_cli_gsync_status_t *sts_val) +get_struct_variable (int mem_num, gf_gsync_status_t *sts_val) { switch (mem_num) { - case 0: return (sts_val->node); - case 1: return (sts_val->master); - case 2: return (sts_val->slave); - case 3: return (sts_val->health); - case 4: return (sts_val->uptime); - case 5: return (sts_val->files_syncd); - case 6: return (sts_val->files_pending); - case 7: return (sts_val->bytes_pending); - case 8: return (sts_val->deletes_pending); + case 0: return (sts_val->node); + case 1: return (sts_val->master); + case 2: return (sts_val->brick); + case 3: return (sts_val->slave_node); + case 4: return (sts_val->worker_status); + case 5: return (sts_val->checkpoint_status); + case 6: return (sts_val->crawl_status); + case 7: return (sts_val->files_syncd); + case 8: return (sts_val->files_remaining); + case 9: return (sts_val->bytes_remaining); + case 10: return (sts_val->purges_remaining); + case 11: return (sts_val->total_files_skipped); default: goto out; } @@ -3963,28 +3900,23 @@ out: int gf_cli_print_status (char **title_values, - gf_cli_gsync_status_t **sts_vals, + gf_gsync_status_t **sts_vals, int *spacing, int gsync_count, int number_of_fields, int is_detail) { - int indents = 0; int i = 0; int j = 0; int ret = 0; + int status_fields = 6; /* Indexed at 0 */ int total_spacing = 0; char **output_values = NULL; char *tmp = NULL; char *hyphens = NULL; - char heading[PATH_MAX] = {0, }; - char indent_spaces[PATH_MAX] = {0, }; /* calculating spacing for hyphens */ for (i = 0; i < number_of_fields; i++) { - /* Suppressing master and slave output for status detail */ - if ((is_detail) && ((i == 1) || (i == 2))) { - total_spacing++; - continue; - } else if ((!is_detail) && (i > 4)) { + /* Suppressing detail output for status */ + if ((!is_detail) && (i > status_fields)) { /* Suppressing detailed output for * status */ continue; @@ -4018,64 +3950,29 @@ gf_cli_print_status (char **title_values, goto out; } - ret = snprintf(heading, sizeof(heading), "MASTER: %s SLAVE: %s", - sts_vals[0]->master, sts_vals[0]->slave); - if (ret) { - if (ret < sizeof(heading)) - heading[ret] = '\0'; - else - heading[sizeof(heading) - 1] = '\0'; - ret = 0; - } else { - ret = -1; - goto out; - } - - if (is_detail) { - cli_out (" "); - if (strlen(heading) > total_spacing) - cli_out ("%s", heading); - else { - /* Printing the heading with centre justification */ - indents = (total_spacing - strlen(heading)) / 2; - memset (indent_spaces, ' ', indents); - indent_spaces[indents] = '\0'; - ret = snprintf (hyphens, total_spacing, "%s%s", - indent_spaces, heading); - if (ret) { - hyphens[ret] = '\0'; - cli_out ("%s", hyphens); - ret = 0; - } else { - ret = -1; - goto out; - } - } - cli_out (" "); - } + cli_out (" "); /* setting the title "NODE", "MASTER", etc. from title_values[] and printing the same */ for (j = 0; j < number_of_fields; j++) { - /* Suppressing master and slave output for status detail */ - if ((is_detail) && ((j == 1) || (j == 2))) { - output_values[j][0] = '\0'; - continue; - } else if ((!is_detail) && (j > 4)) { + if ((!is_detail) && (j > status_fields)) { /* Suppressing detailed output for * status */ output_values[j][0] = '\0'; - continue; + continue; } memset (output_values[j], ' ', spacing[j]); memcpy (output_values[j], title_values[j], strlen(title_values[j])); output_values[j][spacing[j]] = '\0'; } - cli_out ("%s %s %s %s %s %s %s %s %s", output_values[0], - output_values[1], output_values[2], output_values[3], - output_values[4], output_values[5], output_values[6], - output_values[7], output_values[8]); + cli_out ("%s %s %s %s %s %s %s %s %s %s %s %s", + output_values[0], output_values[1], + output_values[2], output_values[3], + output_values[4], output_values[5], + output_values[6], output_values[7], + output_values[8], output_values[9], + output_values[10], output_values[11]); /* setting and printing the hyphens */ memset (hyphens, '-', total_spacing); @@ -4084,12 +3981,7 @@ gf_cli_print_status (char **title_values, for (i = 0; i < gsync_count; i++) { for (j = 0; j < number_of_fields; j++) { - /* Suppressing master and slave output for - * status detail */ - if ((is_detail) && ((j == 1) || (j == 2))) { - output_values[j][0] = '\0'; - continue; - } else if ((!is_detail) && (j > 4)) { + if ((!is_detail) && (j > status_fields)) { /* Suppressing detailed output for * status */ output_values[j][0] = '\0'; @@ -4107,10 +3999,13 @@ gf_cli_print_status (char **title_values, output_values[j][spacing[j]] = '\0'; } - cli_out ("%s %s %s %s %s %s %s %s %s", output_values[0], - output_values[1], output_values[2], output_values[3], - output_values[4], output_values[5], output_values[6], - output_values[7], output_values[8]); + cli_out ("%s %s %s %s %s %s %s %s %s %s %s %s", + output_values[0], output_values[1], + output_values[2], output_values[3], + output_values[4], output_values[5], + output_values[6], output_values[7], + output_values[8], output_values[9], + output_values[10], output_values[11]); } out: @@ -4130,47 +4025,23 @@ out: int gf_cli_read_status_data (dict_t *dict, - gf_cli_gsync_status_t **sts_vals, + gf_gsync_status_t **sts_vals, int *spacing, int gsync_count, int number_of_fields) { - int ret = 0; - int i = 0; - int j = 0; - char mst[PATH_MAX] = {0, }; - char slv[PATH_MAX] = {0, }; - char sts[PATH_MAX] = {0, }; - char nds[PATH_MAX] = {0, }; - char *status = NULL; - char *tmp = NULL; + char *tmp = NULL; + char sts_val_name[PATH_MAX] = ""; + int ret = 0; + int i = 0; + int j = 0; /* Storing per node status info in each object */ for (i = 0; i < gsync_count; i++) { - snprintf (nds, sizeof(nds), "node%d", i + 1); - snprintf (mst, sizeof(mst), "master%d", i + 1); - snprintf (slv, sizeof(slv), "slave%d", i + 1); - snprintf (sts, sizeof(sts), "status%d", i + 1); + snprintf (sts_val_name, sizeof(sts_val_name), "status_value%d", i); /* Fetching the values from dict, and calculating the max length for each field */ - ret = dict_get_str (dict, nds, &(sts_vals[i]->node)); - if (ret) - goto out; - - ret = dict_get_str (dict, mst, &(sts_vals[i]->master)); - if (ret) - goto out; - - ret = dict_get_str (dict, slv, &(sts_vals[i]->slave)); - if (ret) - goto out; - - ret = dict_get_str (dict, sts, &status); - if (ret) - goto out; - - /* Fetching health and uptime from sts_val */ - ret = gf_cli_fetch_gsyncd_status_values (status, sts_vals[i]); + ret = dict_get_bin (dict, sts_val_name, (void **)&(sts_vals[i])); if (ret) goto out; @@ -4192,25 +4063,23 @@ out: } int -gf_cli_gsync_status_output (dict_t *dict, int status_detail) +gf_cli_gsync_status_output (dict_t *dict, gf_boolean_t is_detail) { int gsync_count = 0; int i = 0; - int j = 0; int ret = 0; - int spacing[10] = {0}; - int num_of_fields = 9; + int spacing[13] = {0}; + int num_of_fields = 12; char errmsg[1024] = ""; char *master = NULL; char *slave = NULL; - char *tmp = NULL; - char *title_values[] = {"NODE", "MASTER", "SLAVE", - "HEALTH", "UPTIME", - "FILES SYNCD", - "FILES PENDING", - "BYTES PENDING", - "DELETES PENDING"}; - gf_cli_gsync_status_t **sts_vals = NULL; + char *title_values[] = {"MASTER NODE", "MASTER VOL", + "MASTER BRICK", "SLAVE", + "STATUS", "CHECKPOINT STATUS", + "CRAWL STATUS", "FILES SYNCD", + "FILES PENDING", "BYTES PENDING", + "DELETES PENDING", "FILES SKIPPED"}; + gf_gsync_status_t **sts_vals = NULL; /* Checks if any session is active or not */ ret = dict_get_int32 (dict, "gsync-count", &gsync_count); @@ -4244,14 +4113,14 @@ gf_cli_gsync_status_output (dict_t *dict, int status_detail) /* gsync_count = number of nodes reporting output. each sts_val object will store output of each node */ - sts_vals = GF_CALLOC (gsync_count, sizeof (gf_cli_gsync_status_t *), + sts_vals = GF_CALLOC (gsync_count, sizeof (gf_gsync_status_t *), gf_common_mt_char); if (!sts_vals) { ret = -1; goto out; } for (i = 0; i < gsync_count; i++) { - sts_vals[i] = GF_CALLOC (1, sizeof (gf_cli_gsync_status_t), + sts_vals[i] = GF_CALLOC (1, sizeof (gf_gsync_status_t), gf_common_mt_char); if (!sts_vals[i]) { ret = -1; @@ -4267,23 +4136,15 @@ gf_cli_gsync_status_output (dict_t *dict, int status_detail) } ret = gf_cli_print_status (title_values, sts_vals, spacing, gsync_count, - num_of_fields, status_detail); + num_of_fields, is_detail); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to print status output"); goto out; } out: - if (sts_vals) { - for (i = 0; i < gsync_count; i++) { - for (j = 3; j < num_of_fields; j++) { - tmp = get_struct_variable(j, sts_vals[i]); - if (tmp) - GF_FREE (tmp); - } - } + if (sts_vals) GF_FREE (sts_vals); - } return ret; } @@ -4602,7 +4463,10 @@ gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, status_detail = dict_get_str_boolean (dict, "status-detail", _gf_false); - ret = gf_cli_gsync_status_output (dict, status_detail); + if (status_detail) + ret = gf_cli_gsync_status_output (dict, status_detail); + else + ret = gf_cli_gsync_status_output (dict, status_detail); break; case GF_GSYNC_OPTION_TYPE_DELETE: diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index fe0969a30..69fed1bc9 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -251,6 +251,11 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, } *node_present = _gf_true; + /* <node> + * will be closed in the calling function cli_xml_output_vol_status()*/ + ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); + XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"hostname", "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); @@ -1662,11 +1667,6 @@ cli_xml_output_vol_status (cli_local_t *local, dict_t *dict) index_max = brick_index_max + other_count; for (i = 0; i <= index_max; i++) { - /* <node> */ - ret = xmlTextWriterStartElement (local->writer, - (xmlChar *)"node"); - XML_RET_CHECK_AND_GOTO (ret, out); - ret = cli_xml_output_vol_status_common (local->writer, dict, i, &online, &node_present); if (ret) { @@ -1732,7 +1732,8 @@ cli_xml_output_vol_status (cli_local_t *local, dict_t *dict) break; } - /* </node> */ + + /* </node> was opened in cli_xml_output_vol_status_common()*/ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); } diff --git a/cli/src/cli.h b/cli/src/cli.h index f5db29383..53537c642 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -148,18 +148,6 @@ struct cli_local { #endif }; -struct gf_cli_gsync_detailed_status_ { - char *node; - char *master; - char *slave; - char *health; - char *uptime; - char *files_syncd; - char *files_pending; - char *bytes_pending; - char *deletes_pending; -}; - struct cli_volume_status { int port; int online; @@ -178,8 +166,6 @@ struct cli_volume_status { #endif }; -typedef struct gf_cli_gsync_detailed_status_ gf_cli_gsync_status_t; - typedef struct cli_volume_status cli_volume_status_t; typedef struct cli_local cli_local_t; |