summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-04-26 14:28:05 +0530
committerAnand Avati <avati@redhat.com>2012-04-26 22:50:38 -0700
commitecb818902e4ee7491aaeae21226b62a0ab806370 (patch)
treeb3051f7464c7e04ed369a7bffabb9c9d65845e71
parent81df001b3efb2313e68745abd84f02e24fba6e67 (diff)
cli: Make use of cli_err()
Use cli_err() in case of errors instead of cli_out(). Change-Id: Ib0766e59516a1ccd56a2133f33fac3877c4384d6 BUG: 815194 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/3229 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c98
-rw-r--r--cli/src/cli-rpc-ops.c115
2 files changed, 126 insertions, 87 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index aef13a77df9..f590a4a5acc 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -74,7 +74,7 @@ cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
brick_list_len++;
while (brick_index < wordcount) {
if (validate_brick_name ((char *)words[brick_index])) {
- cli_out ("Wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("Wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", words[brick_index]);
ret = -1;
goto out;
@@ -86,9 +86,8 @@ cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
}
if ((brick_list_len + strlen (words[brick_index]) + 1) > sizeof (brick_list)) {
- gf_log ("cli", GF_LOG_ERROR,
- "total brick list is larger than a request "
- "can take (brick_count %d)", *brick_count);
+ cli_err ("Total brick list is larger than a request. "
+ "Can take (brick_count %d)", *brick_count);
ret = -1;
goto out;
}
@@ -109,14 +108,14 @@ cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
if (!(strcmp (host_name, "localhost") &&
strcmp (host_name, "127.0.0.1"))) {
- cli_out ("Please provide a valid hostname/ip other "
+ cli_err ("Please provide a valid hostname/ip other "
"than localhost or 127.0.0.1");
ret = -1;
GF_FREE (tmp_host);
goto out;
}
if (!valid_internet_address (host_name, _gf_false)) {
- cli_out ("internet address '%s' does not conform to "
+ cli_err ("internet address '%s' does not conform to "
"standards", host_name);
}
GF_FREE (tmp_host);
@@ -131,7 +130,7 @@ cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
strtok_r (tmp_list, " ", &tmpptr);
if (!(strcmp (tmp_list, words[brick_index]))) {
ret = -1;
- cli_out ("Found duplicate"
+ cli_err ("Found duplicate"
" exports %s",words[brick_index]);
goto out;
}
@@ -196,7 +195,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
goto out;
if (!strcmp (volname, "all")) {
- cli_out ("\"all\" cannot be the name of a volume.");
+ cli_err ("\"all\" cannot be the name of a volume.");
goto out;
}
@@ -228,7 +227,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
switch (type) {
case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
case GF_CLUSTER_TYPE_REPLICATE:
- cli_out ("replica option given twice");
+ cli_err ("replica option given twice");
goto out;
case GF_CLUSTER_TYPE_NONE:
type = GF_CLUSTER_TYPE_REPLICATE;
@@ -244,7 +243,8 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
}
replica_count = strtol (words[index+1], NULL, 0);
if (replica_count < 2) {
- cli_out ("replica count should be greater than 1");
+ cli_err ("replica count should be greater"
+ " than 1");
ret = -1;
goto out;
}
@@ -258,7 +258,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
switch (type) {
case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
case GF_CLUSTER_TYPE_STRIPE:
- cli_out ("stripe option given twice");
+ cli_err ("stripe option given twice");
goto out;
case GF_CLUSTER_TYPE_NONE:
type = GF_CLUSTER_TYPE_STRIPE;
@@ -273,7 +273,8 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
}
stripe_count = strtol (words[index+1], NULL, 0);
if (stripe_count < 2) {
- cli_out ("stripe count should be greater than 1");
+ cli_err ("stripe count should be greater"
+ " than 1");
ret = -1;
goto out;
}
@@ -285,7 +286,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
} else if ((strcmp (w, "transport")) == 0) {
if (trans_type) {
- cli_out ("'transport' option given more"
+ cli_err ("'transport' option given more"
" than one time");
goto out;
}
@@ -334,20 +335,20 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
/* If brick-count is not valid when replica or stripe is
given, exit here */
if (!brick_count) {
- cli_out ("No bricks specified");
+ cli_err ("No bricks specified");
ret = -1;
goto out;
}
if (brick_count % sub_count) {
if (type == GF_CLUSTER_TYPE_STRIPE)
- cli_out ("number of bricks is not a multiple of "
+ cli_err ("number of bricks is not a multiple of "
"stripe count");
else if (type == GF_CLUSTER_TYPE_REPLICATE)
- cli_out ("number of bricks is not a multiple of "
+ cli_err ("number of bricks is not a multiple of "
"replica count");
else
- cli_out ("number of bricks given doesn't match "
+ cli_err ("number of bricks given doesn't match "
"required count");
ret = -1;
@@ -497,7 +498,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
goto out;
if (!strcmp (volname, "all")) {
- cli_out ("\"all\" cannot be the name of a volume.");
+ cli_err ("\"all\" cannot be the name of a volume.");
goto out;
}
@@ -543,7 +544,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
type = GF_QUOTA_OPTION_TYPE_LIMIT_USAGE;
if (words[4][0] != '/') {
- cli_out ("Please enter absolute path");
+ cli_err ("Please enter absolute path");
return -2;
}
@@ -552,14 +553,14 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
goto out;
if (!words[5]) {
- cli_out ("Please enter the limit value to be set");
+ cli_err ("Please enter the limit value to be set");
return -2;
}
ret = gf_string2bytesize (words[5], &value);
if (ret != 0) {
- cli_out ("Please enter a correct value");
+ cli_err ("Please enter a correct value");
return -1;
}
@@ -578,7 +579,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
type = GF_QUOTA_OPTION_TYPE_REMOVE;
if (words[4][0] != '/') {
- cli_out ("Please enter absolute path");
+ cli_err ("Please enter absolute path");
return -2;
}
@@ -778,7 +779,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
}
count = strtol (words[4], NULL, 0);
if (!count || (count < 2)) {
- cli_out ("replica count should be greater than 1");
+ cli_err ("replica count should be greater than 1");
ret = -1;
goto out;
}
@@ -794,7 +795,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
}
count = strtol (words[4], NULL, 0);
if (!count || (count < 2)) {
- cli_out ("stripe count should be greater than 1");
+ cli_err ("stripe count should be greater than 1");
ret = -1;
goto out;
}
@@ -886,7 +887,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
}
count = strtol (words[4], NULL, 0);
if (count < 1) {
- cli_out ("replica count should be greater than 0 in "
+ cli_err ("replica count should be greater than 0 in "
"case of remove-brick");
ret = -1;
goto out;
@@ -962,7 +963,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
while (brick_index < wordcount) {
if (validate_brick_name ((char *)words[brick_index])) {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", words[brick_index]);
ret = -1;
goto out;
@@ -980,7 +981,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
if (!(strcmp (tmp_brick, tmp_brick1))) {
gf_log("",GF_LOG_ERROR, "Duplicate bricks"
" found %s", words[brick_index]);
- cli_out("Duplicate bricks found %s",
+ cli_err("Duplicate bricks found %s",
words[brick_index]);
ret = -1;
goto out;
@@ -1056,7 +1057,7 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
}
if (validate_brick_name ((char *)words[3])) {
- cli_out ("wrong brick type: %s, use "
+ cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[3]);
ret = -1;
goto out;
@@ -1077,7 +1078,7 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
}
if (validate_brick_name ((char *)words[4])) {
- cli_out ("wrong brick type: %s, use "
+ cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[4]);
ret = -1;
goto out;
@@ -1186,7 +1187,7 @@ cli_cmd_log_filename_parse (const char **words, int wordcount, dict_t **options)
delimiter = strchr (words[4], ':');
if (!delimiter || delimiter == words[4]
|| *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", words[4]);
ret = -1;
goto out;
@@ -1241,8 +1242,8 @@ cli_cmd_log_level_parse (const char **words, int worcount, dict_t **options)
ret = glusterd_check_log_level(words[5]);
if (ret == -1) {
- cli_out("Invalid log level [%s] specified", words[5]);
- cli_out("Valid values for loglevel: (DEBUG|WARNING|ERROR"
+ cli_err("Invalid log level [%s] specified", words[5]);
+ cli_err("Valid values for loglevel: (DEBUG|WARNING|ERROR"
"|CRITICAL|NONE|TRACE)");
goto out;
}
@@ -1302,7 +1303,7 @@ cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options)
delimiter = strchr (words[4], ':');
if (!delimiter || delimiter == words[4]
|| *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", words[4]);
ret = -1;
goto out;
@@ -1353,7 +1354,7 @@ cli_cmd_log_rotate_parse (const char **words, int wordcount, dict_t **options)
delimiter = strchr (words[4], ':');
if (!delimiter || delimiter == words[4]
|| *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", words[4]);
ret = -1;
goto out;
@@ -1735,7 +1736,7 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
delimiter = strchr (value, ':');
if (!delimiter || delimiter == value
|| *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ cli_err ("wrong brick type: %s, use <HOSTNAME>:"
"<export-dir-abs-path>", value);
ret = -1;
goto out;
@@ -1751,7 +1752,7 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
if (!ret)
list_cnt = atoi (value);
if (ret || (list_cnt < 0) || (list_cnt > 100)) {
- cli_out ("list-cnt should be between 0 to 100");
+ cli_err ("list-cnt should be between 0 to 100");
ret = -1;
goto out;
}
@@ -1761,10 +1762,11 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
blk_size = atoi (value);
if (ret || (blk_size <= 0)) {
if (blk_size < 0)
- cli_out ("block size is an invalid number");
+ cli_err ("block size is an invalid"
+ " number");
else
- cli_out ("block size should be an integer "
- "greater than zero");
+ cli_err ("block size should be an "
+ "integer greater than zero");
ret = -1;
goto out;
}
@@ -1775,9 +1777,9 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
count = atoi(value);
if (ret || (count <= 0)) {
if (count < 0)
- cli_out ("count is an invalid number");
+ cli_err ("count is an invalid number");
else
- cli_out ("count should be an integer "
+ cli_err ("count should be an integer "
"greater than zero");
ret = -1;
@@ -1803,11 +1805,11 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
}
if ((blk_size > 0) ^ (count > 0)) {
- cli_out ("Need to give both 'bs' and 'count'");
+ cli_err ("Need to give both 'bs' and 'count'");
ret = -1;
goto out;
} else if (((uint64_t)blk_size * count) > (10 * GF_UNIT_GB)) {
- cli_out ("'bs * count' value %"PRIu64" is greater than "
+ cli_err ("'bs * count' value %"PRIu64" is greater than "
"maximum allowed value of 10GB",
((uint64_t)blk_size * count));
ret = -1;
@@ -1898,7 +1900,7 @@ cli_cmd_volume_status_parse (const char **words, int wordcount,
if (!strcmp (words[2], "all")) {
if (cmd == GF_CLI_STATUS_NONE) {
- cli_out ("%s is not a valid status option",
+ cli_err ("%s is not a valid status option",
words[3]);
ret = -1;
goto out;
@@ -1933,14 +1935,14 @@ cli_cmd_volume_status_parse (const char **words, int wordcount,
case 5:
if (!strcmp (words[2], "all")) {
- cli_out ("Cannot specify brick/nfs for \"all\"");
+ cli_err ("Cannot specify brick/nfs for \"all\"");
ret = -1;
goto out;
}
cmd = cli_cmd_get_statusop (words[4]);
if (cmd == GF_CLI_STATUS_NONE) {
- cli_out ("%s is not a valid status option",
+ cli_err ("%s is not a valid status option",
words[4]);
ret = -1;
goto out;
@@ -1954,7 +1956,7 @@ cli_cmd_volume_status_parse (const char **words, int wordcount,
if (!strcmp (words[3], "nfs")) {
if (cmd == GF_CLI_STATUS_FD ||
cmd == GF_CLI_STATUS_DETAIL) {
- cli_out ("Detail/FD status not available"
+ cli_err ("Detail/FD status not available"
" for NFS Servers");
ret = -1;
goto out;
@@ -1964,7 +1966,7 @@ cli_cmd_volume_status_parse (const char **words, int wordcount,
if (cmd == GF_CLI_STATUS_FD ||
cmd == GF_CLI_STATUS_CLIENTS ||
cmd == GF_CLI_STATUS_DETAIL) {
- cli_out ("Detail/FD/Clients status not "
+ cli_err ("Detail/FD/Clients status not "
"available for Self-heal Daemons");
ret = -1;
goto out;
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 9487badb6f1..b270c9c1d5b 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -402,7 +402,7 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
if (ret)
- cli_out ("Peer status unsuccessful");
+ cli_err ("Peer status unsuccessful");
if (dict)
dict_destroy (dict);
@@ -718,7 +718,7 @@ xml_output:
out:
cli_cmd_broadcast_response (ret);
if (ret)
- cli_out ("%s", err_str);
+ cli_err ("%s", err_str);
if (dict)
dict_destroy (dict);
@@ -774,7 +774,7 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
cli_out ("Creation of volume %s has been %s", volname,
(rsp.op_ret) ? "unsuccessful":
@@ -843,7 +843,7 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
cli_out ("Deleting volume %s has been %s", volname,
(rsp.op_ret) ? "unsuccessful": "successful");
@@ -912,7 +912,7 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
cli_out ("Starting volume %s has been %s", volname,
(rsp.op_ret) ? "unsuccessful": "successful");
@@ -984,7 +984,7 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
cli_out ("Stopping volume %s has been %s", volname,
(rsp.op_ret) ? "unsuccessful": "successful");
@@ -1205,7 +1205,10 @@ done:
goto out;
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1257,7 +1260,10 @@ gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1302,7 +1308,10 @@ gf_cli3_1_reset_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1360,9 +1369,12 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
- cli_out ("%s", ((help_str == NULL) ? msg : help_str));
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", ((help_str == NULL) ? msg : help_str));
ret = rsp.op_ret;
@@ -1409,7 +1421,10 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1432,7 +1447,7 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
uint64_t size = 0;
uint64_t lookup = 0;
dict_t *dict = NULL;
- char msg[1024] = {0,};
+ //char msg[1024] = {0,};
char key[256] = {0,};
int32_t i = 1;
int32_t counter = 0;
@@ -1455,9 +1470,9 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
ret = rsp.op_ret;
if (rsp.op_ret == -1) {
if (strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
- cli_out ("failed to get the status of "
+ cli_err ("failed to get the status of "
"remove-brick process");
goto out;
}
@@ -1553,6 +1568,8 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
i++;
} while (i <= counter);
+ //TODO: Do proper xml output
+ /*
#if (HAVE_LIB_XML)
if (global_state->mode & GLUSTER_MODE_XML) {
ret = cli_xml_output_str ("volRemoveBrick", msg, rsp.op_ret,
@@ -1565,6 +1582,7 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
#endif
cli_out ("%s", msg);
+ */
out:
if (rsp.dict.dict_val)
free (rsp.dict.dict_val); //malloced by xdr
@@ -1643,7 +1661,10 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1803,7 +1824,10 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1862,7 +1886,10 @@ gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1910,7 +1937,10 @@ gf_cli3_1_sync_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -1942,7 +1972,7 @@ gf_cli3_1_print_limit_list (char *volname, char *limit_list,
len = strlen (limit_list);
if (len == 0) {
- cli_out ("%s", op_errstr?op_errstr:"quota limit not set ");
+ cli_err ("%s", op_errstr?op_errstr:"quota limit not set ");
goto out;
}
@@ -2140,8 +2170,12 @@ xml_output:
}
#endif
- if (strlen (msg) > 0)
- cli_out ("%s", msg);
+ if (strlen (msg) > 0) {
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
+ }
ret = rsp.op_ret;
out:
@@ -3278,8 +3312,8 @@ gf_cli3_1_fsm_log_cbk (struct rpc_req *req, struct iovec *iov,
if (rsp.op_ret) {
if (strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
- cli_out ("fsm log unsuccessful");
+ cli_err ("%s", rsp.op_errstr);
+ cli_err ("fsm log unsuccessful");
ret = rsp.op_ret;
goto out;
}
@@ -3295,7 +3329,7 @@ gf_cli3_1_fsm_log_cbk (struct rpc_req *req, struct iovec *iov,
&dict);
if (ret) {
- cli_out ("bad response");
+ cli_err ("bad response");
goto out;
}
@@ -3510,7 +3544,7 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
#endif
if (rsp.op_ret) {
- cli_out ("%s", rsp.op_errstr ? rsp.op_errstr :
+ cli_err ("%s", rsp.op_errstr ? rsp.op_errstr :
GEOREP" command unsuccessful");
ret = rsp.op_ret;
goto out;
@@ -3853,7 +3887,7 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
if (rsp.op_ret && strcmp (rsp.op_errstr, "")) {
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
} else {
switch (op) {
case GF_CLI_STATS_START:
@@ -4017,8 +4051,8 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
if (rsp.op_ret) {
if (strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
- cli_out ("volume top unsuccessful");
+ cli_err ("%s", rsp.op_errstr);
+ cli_err ("volume top unsuccessful");
ret = rsp.op_ret;
goto out;
}
@@ -5314,7 +5348,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
#endif
- cli_out ("%s", msg);
+ cli_err ("%s", msg);
if (local && local->all) {
ret = 0;
cli_out (" ");
@@ -5561,7 +5595,7 @@ gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data)
ret = dict_get_int32 (vol_dict, "vol_count", &vol_count);
if (ret) {
- cli_out ("Failed to get names of volumes");
+ cli_err ("Failed to get names of volumes");
goto out;
}
@@ -5636,7 +5670,7 @@ gf_cli3_1_mount_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("%s", rsp.path);
} else {
/* weird sounding but easy to parse... */
- cli_out ("%d : failed with this errno (%s)",
+ cli_err ("%d : failed with this errno (%s)",
rsp.op_errno, strerror (rsp.op_errno));
ret = 1;
}
@@ -5701,7 +5735,7 @@ gf_cli3_1_umount_cbk (struct rpc_req *req, struct iovec *iov,
if (rsp.op_ret == 0)
ret = 0;
else {
- cli_out ("umount failed");
+ cli_err ("umount failed");
ret = 1;
}
@@ -5816,7 +5850,7 @@ gf_cli3_1_heal_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_get_int32 (input_dict, "heal-op",
(int32_t*)&heal_op);
}
-
+//TODO: Proper XML output
//#if (HAVE_LIB_XML)
// if (global_state->mode & GLUSTER_MODE_XML) {
// ret = cli_xml_output_dict ("volHeal", dict, rsp.op_ret,
@@ -5837,7 +5871,7 @@ gf_cli3_1_heal_volume_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_INFO, "Received resp to heal volume");
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else
cli_out ("Heal operation on volume %s has been %s", volname,
(rsp.op_ret) ? "unsuccessful": "successful");
@@ -5967,7 +6001,10 @@ gf_cli3_1_statedump_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
- cli_out ("%s", msg);
+ if (rsp.op_ret)
+ cli_err ("%s", msg);
+ else
+ cli_out ("%s", msg);
ret = rsp.op_ret;
out:
@@ -6057,7 +6094,7 @@ gf_cli3_1_list_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
#endif
if (rsp.op_ret)
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("%s", rsp.op_errstr);
else {
ret = dict_get_int32 (dict, "count", &vol_count);
if (ret)
@@ -6125,8 +6162,8 @@ gf_cli3_1_clearlocks_volume_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_DEBUG, "Received response to clear-locks");
if (rsp.op_ret) {
- cli_out ("Volume clear-locks unsuccessful");
- cli_out ("%s", rsp.op_errstr);
+ cli_err ("Volume clear-locks unsuccessful");
+ cli_err ("%s", rsp.op_errstr);
} else {
if (!rsp.dict.dict_len) {