From c109ffb893ab80dd7b9dac038f5778961859ceff Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 15 Sep 2010 06:49:56 +0000 Subject: cli, mgmt/glusterd: disallow probe to a cluster Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1594 (make probe oneway) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1594 --- cli/src/cli3_1-cops.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'cli') diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c index 7e0e21031..a3c0a2518 100644 --- a/cli/src/cli3_1-cops.c +++ b/cli/src/cli3_1-cops.c @@ -90,11 +90,22 @@ gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, break; } } - if (rsp.op_ret) { - cli_out ("Probe unsuccessfull"); - gf_log ("glusterd",GF_LOG_ERROR,"Probe failed with op_ret %d" - " and op_errno %d", rsp.op_ret, rsp.op_errno); - } + + if (rsp.op_ret) { + switch (rsp.op_errno) { + case GF_PROBE_ANOTHER_CLUSTER: + cli_out ("%s is already part of " + "another cluster", rsp.hostname); + break; + default: + cli_out ("Probe returned with unknown errno %d", + rsp.op_errno); + break; + } + cli_out ("Probe unsuccessful"); + gf_log ("glusterd",GF_LOG_ERROR,"Probe failed with op_ret %d" + " and op_errno %d", rsp.op_ret, rsp.op_errno); + } ret = rsp.op_ret; out: @@ -145,6 +156,8 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov, char key[256] = {0,}; int32_t state = 0; int32_t port = 0; + int32_t connected = 0; + char *connected_str = NULL; if (-1 == req->rpc_status) { goto out; @@ -208,6 +221,15 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov, if (ret) goto out; + snprintf (key, 256, "friend%d.connected", i); + ret = dict_get_int32 (dict, key, &connected); + if (ret) + goto out; + if (connected) + connected_str = "connected"; + else + connected_str = "disconnected"; + snprintf (key, 256, "friend%d.port", i); ret = dict_get_int32 (dict, key, &port); if (ret) @@ -219,11 +241,13 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov, goto out; if (!port) { - cli_out ("hostname:%s, uuid:%s, state:%d", - hostname_buf, uuid_buf, state); + cli_out ("hostname:%s, uuid:%s, state:%d (%s)", + hostname_buf, uuid_buf, state, + connected_str); } else { - cli_out ("hostname:%s, port:%d, uuid:%s, state:%d", - hostname_buf, port, uuid_buf, state); + cli_out ("hostname:%s, port:%d, uuid:%s, " + "state:%d, (%s)", hostname_buf, port, + uuid_buf, state, connected_str); } i++; } -- cgit