summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-11-02 18:52:03 +0530
committerVijay Bellur <vbellur@redhat.com>2015-11-23 11:22:28 -0800
commitc7b293beba0c327ad20a5c8b3e5635be80672f63 (patch)
tree24c30737873b9c746cd77a6b47168bad37297f8d /cli
parent2cd331dc3080f3a66edb12fa6cbab75c69b0147f (diff)
glusterd/geo-rep: Adding ssh-port option for geo-rep create
Geo-replication uses default ssh port 22 for setup. i.e., to distribute ssh keys to slaves. In container environments, custom port number might be used. Hence to support custom port number for ssh, option is provided in geo-rep create command to take the same. Change-Id: I0fb61959b1c085342b8e4c21ac4e076fba5462f1 BUG: 1283060 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/12504 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Aravinda VK <avishwan@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> (cherry picked from commit 5bb3c521431cc27b2826acd889bffb2f90ae7f73) Reviewed-on: http://review.gluster.org/12652 Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c87
-rw-r--r--cli/src/cli-cmd-volume.c2
2 files changed, 58 insertions, 31 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index cc0a9aba96c..94c9fddfe1f 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -2408,6 +2408,51 @@ out:
return ret;
}
+/* ssh_port_parse: Parses and validates when ssh_port is given.
+ * ssh_index refers to index of ssh_port and
+ * type refers to either push-pem or no-verify
+ */
+
+static int32_t
+parse_ssh_port (const char **words, int wordcount, dict_t *dict,
+ unsigned *cmdi, int ssh_index, char *type) {
+
+ int ret = 0;
+ char *end_ptr = NULL;
+ int64_t limit = 0;
+
+ if (!strcmp ((char *)words[ssh_index], "ssh-port")) {
+ if (strcmp ((char *)words[ssh_index-1], "create")) {
+ ret = -1;
+ goto out;
+ }
+ (*cmdi)++;
+ limit = strtol (words[ssh_index+1], &end_ptr, 10);
+ if (errno == ERANGE || errno == EINVAL || limit <= 0
+ || strcmp (end_ptr, "") != 0) {
+ ret = -1;
+ cli_err ("Please enter an interger value for ssh_port ");
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, "ssh_port", limit);
+ if (ret)
+ goto out;
+ (*cmdi)++;
+ } else if (strcmp ((char *)words[ssh_index+1], "create")) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, type, 1);
+ if (ret)
+ goto out;
+ (*cmdi)++;
+
+ out:
+ return ret;
+}
+
static int32_t
force_push_pem_no_verify_parse (const char **words, int wordcount,
dict_t *dict, unsigned *cmdi)
@@ -2432,44 +2477,26 @@ force_push_pem_no_verify_parse (const char **words, int wordcount,
(*cmdi)++;
if (!strcmp ((char *)words[wordcount-2], "push-pem")) {
- if (strcmp ((char *)words[wordcount-3], "create")) {
- ret = -1;
- goto out;
- }
- ret = dict_set_int32 (dict, "push_pem", 1);
+ ret = parse_ssh_port (words, wordcount, dict, cmdi,
+ wordcount-4, "push_pem");
if (ret)
goto out;
- (*cmdi)++;
} else if (!strcmp ((char *)words[wordcount-2], "no-verify")) {
- if (strcmp ((char *)words[wordcount-3], "create")) {
- ret = -1;
- goto out;
- }
- ret = dict_set_uint32 (dict, "no_verify",
- _gf_true);
+ ret = parse_ssh_port (words, wordcount, dict, cmdi,
+ wordcount-4, "no_verify");
if (ret)
goto out;
- (*cmdi)++;
}
} else if (!strcmp ((char *)words[wordcount-1], "push-pem")) {
- if (strcmp ((char *)words[wordcount-2], "create")) {
- ret = -1;
- goto out;
- }
- ret = dict_set_int32 (dict, "push_pem", 1);
+ ret = parse_ssh_port (words, wordcount, dict, cmdi, wordcount-3,
+ "push_pem");
if (ret)
goto out;
- (*cmdi)++;
} else if (!strcmp ((char *)words[wordcount-1], "no-verify")) {
- if ((strcmp ((char *)words[wordcount-2], "create"))) {
- ret = -1;
- goto out;
- }
- ret = dict_set_uint32 (dict, "no_verify",
- _gf_true);
+ ret = parse_ssh_port (words, wordcount, dict, cmdi, wordcount-3,
+ "no_verify");
if (ret)
goto out;
- (*cmdi)++;
}
out:
@@ -2490,9 +2517,9 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
unsigned glob = 0;
unsigned cmdi = 0;
char *opwords[] = { "create", "status", "start", "stop",
- "config", "force", "delete", "no-verify"
- "push-pem", "detail", "pause",
- "resume", NULL };
+ "config", "force", "delete",
+ "ssh-port", "no-verify", "push-pem",
+ "detail", "pause", "resume", NULL };
char *w = NULL;
char *save_ptr = NULL;
char *slave_temp = NULL;
@@ -2507,7 +2534,7 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
/* new syntax:
*
- * volume geo-replication $m $s create [[no-verify] | [push-pem]] [force]
+ * volume geo-replication $m $s create [[ssh-port n] [[no-verify] | [push-pem]]] [force]
* volume geo-replication [$m [$s]] status [detail]
* volume geo-replication [$m] $s config [[!]$opt [$val]]
* volume geo-replication $m $s start|stop [force]
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 48ac4201ac9..a89d004adc4 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -2720,7 +2720,7 @@ struct cli_cmd volume_cmds[] = {
"reset all the reconfigured options"},
#if (SYNCDAEMON_COMPILE)
- {"volume "GEOREP" [<VOLNAME>] [<SLAVE-URL>] {create [[no-verify]|[push-pem]] [force]"
+ {"volume "GEOREP" [<VOLNAME>] [<SLAVE-URL>] {create [[ssh-port n] [[no-verify]|[push-pem]]] [force]"
"|start [force]|stop [force]|pause [force]|resume [force]|config|status [detail]|delete} [options...]",
cli_cmd_volume_gsync_set_cbk,
"Geo-sync operations",