summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-09-15 08:11:20 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-16 23:07:52 -0700
commitafa6e19f6a9e1dde0f00d72c21c760a5dca341b0 (patch)
treec71fc5945a3ae8774dae9fae63ca738567710629 /cli/src
parente690af8375f55bf8d8e56a0334cc9bd88867326e (diff)
cli: added system:: portmap brick2port
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-system.c48
-rw-r--r--cli/src/cli3_1-cops.c67
2 files changed, 115 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c
index 86e2c167b57..08fc44a37c2 100644
--- a/cli/src/cli-cmd-system.c
+++ b/cli/src/cli-cmd-system.c
@@ -34,6 +34,7 @@
#include "protocol-common.h"
#define GETSPEC_SYNTAX "system:: getspec <VOLID>"
+#define BRICKTOPORT_SYNTAX "system:: portmap brick2port <BRICK>"
extern struct rpc_clnt *global_rpc;
@@ -85,11 +86,58 @@ out:
return ret;
}
+int
+cli_cmd_pmap_b2p_cbk (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 *dict = NULL;
+
+ frame = create_frame (THIS, THIS->ctx->pool);
+ if (!frame)
+ goto out;
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ if (wordcount != 4) {
+ cli_out ("Usage: " BRICKTOPORT_SYNTAX);
+ goto out;
+ }
+
+ ret = dict_set_str (dict, "brick", (char *)words[3]);
+ if (ret)
+ goto out;
+
+ proc = &cli_rpc_prog->proctable[GF1_CLI_PMAP_PORTBYBRICK];
+ if (proc->fn) {
+ ret = proc->fn (frame, THIS, dict);
+ }
+
+out:
+ if (!proc && ret) {
+ if (dict)
+ dict_destroy (dict);
+ if (wordcount > 1)
+ cli_out ("Fetching spec for volume %s failed",
+ (char *)words[3]);
+ }
+
+ return ret;
+}
+
struct cli_cmd cli_system_cmds[] = {
{ GETSPEC_SYNTAX,
cli_cmd_getspec_cbk,
"fetch spec for volume <VOLID>"},
+ { BRICKTOPORT_SYNTAX,
+ cli_cmd_pmap_b2p_cbk,
+ "query which port <BRICK> listens on"},
+
{ "system:: help",
cli_cmd_system_help_cbk,
"display help for system commands"},
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index a63c2e17a3a..026231b1f9a 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -35,6 +35,7 @@
#include "compat.h"
#include "glusterfs3.h"
+#include "portmap.h"
extern rpc_clnt_prog_t *cli_rpc_prog;
extern int cli_op_ret;
@@ -61,6 +62,12 @@ rpc_clnt_prog_t cli_handshake_prog = {
.progver = GLUSTER_HNDSK_VERSION,
};
+rpc_clnt_prog_t cli_pmap_prog = {
+ .progname = "cli portmap",
+ .prognum = GLUSTER_PMAP_PROGRAM,
+ .progver = GLUSTER_PMAP_VERSION,
+};
+
int
gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov,
@@ -1062,6 +1069,36 @@ out:
return ret;
}
+int
+gf_cli3_1_pmap_b2p_cbk (struct rpc_req *req, struct iovec *iov,
+ int count, void *myframe)
+{
+ pmap_port_by_brick_rsp rsp = {0,};
+ int ret = 0;
+ char *spec = NULL;
+
+ if (-1 == req->rpc_status) {
+ goto out;
+ }
+
+ ret = xdr_to_pmap_port_by_brick_rsp (*iov, &rsp);
+ if (ret < 0 || rsp.op_ret == -1) {
+ gf_log ("", GF_LOG_ERROR, "error");
+ goto out;
+ }
+
+ gf_log ("cli", GF_LOG_NORMAL, "Received resp to pmap b2p");
+
+ cli_out ("%d", rsp.port);
+ GF_FREE (spec);
+
+ ret = rsp.op_ret;
+
+out:
+ cli_cmd_broadcast_response (ret);
+ return ret;
+}
+
int32_t
gf_cli3_1_probe (call_frame_t *frame, xlator_t *this,
@@ -1873,6 +1910,35 @@ out:
return ret;
}
+int32_t
+gf_cli3_1_pmap_b2p (call_frame_t *frame, xlator_t *this, void *data)
+{
+ pmap_port_by_brick_req req = {0,};
+ int ret = 0;
+ dict_t *dict = NULL;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+
+ dict = data;
+
+ ret = dict_get_str (dict, "brick", &req.brick);
+ if (ret)
+ goto out;
+
+ ret = cli_cmd_submit (&req, frame, &cli_pmap_prog,
+ GF_PMAP_PORTBYBRICK, NULL,
+ xdr_from_pmap_port_by_brick_req,
+ this, gf_cli3_1_pmap_b2p_cbk);
+
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_NULL] = {"NULL", NULL },
@@ -1895,6 +1961,7 @@ struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_LOG_LOCATE] = {"LOG LOCATE", gf_cli3_1_log_locate},
[GF1_CLI_LOG_ROTATE] = {"LOG ROTATE", gf_cli3_1_log_rotate},
[GF1_CLI_GETSPEC] = {"GETSPEC", gf_cli3_1_getspec},
+ [GF1_CLI_PMAP_PORTBYBRICK] = {"PMAP PORTBYBRICK", gf_cli3_1_pmap_b2p},
};
struct rpc_clnt_program cli3_1_prog = {