From d787bca47fc038facb34221ee9855934f7230ef4 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 15 Sep 2010 08:11:16 +0000 Subject: cli: add "--remote-host=" option Signed-off-by: Csaba Henk Signed-off-by: Vijay Bellur BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570 --- cli/src/cli.c | 21 +++++++++++++++------ cli/src/cli.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cli/src/cli.c b/cli/src/cli.c index 4e25417f9ba..8730211bff9 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -340,6 +340,12 @@ cli_opt_parse (char *opt, struct cli_state *state) return -1; } + oarg = strtail (opt, "remote-host="); + if (oarg) { + state->remote_host = oarg; + return 0; + } + return -1; } @@ -391,6 +397,9 @@ cli_state_init (struct cli_state *state) struct cli_cmd_tree *tree = NULL; int ret = 0; + + state->remote_host = "localhost"; + tree = &state->tree; tree->state = state; @@ -439,14 +448,14 @@ cli_rpc_init (struct cli_state *state) if (!options) goto out; - ret = dict_set_str (options, "remote-host", "localhost"); + ret = dict_set_str (options, "remote-host", state->remote_host); if (ret) goto out; if (state->remote_port) port = state->remote_port; - rpc_cfg.remote_host = "localhost"; + rpc_cfg.remote_host = state->remote_host; rpc_cfg.remote_port = port; ret = dict_set_int32 (options, "remote-port", port); @@ -516,10 +525,6 @@ main (int argc, char *argv[]) if (ret) goto out; - global_rpc = cli_rpc_init (&state); - if (!global_rpc) - goto out; - state.ctx = ctx; global_state = &state; @@ -527,6 +532,10 @@ main (int argc, char *argv[]) if (ret) goto out; + global_rpc = cli_rpc_init (&state); + if (!global_rpc) + goto out; + ret = logging_init (ctx); if (ret) goto out; diff --git a/cli/src/cli.h b/cli/src/cli.h index 62aa02079da..091114fcaca 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -97,6 +97,7 @@ struct cli_state { char **matches; char **matchesp; + char *remote_host; int remote_port; int mode; }; -- cgit