aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlarry <larry@elsa>2014-08-29 09:44:01 +0200
committerlarry <larry@elsa>2014-08-29 09:44:01 +0200
commit386ed8b033df2de4edd26de9f6512202337edfb3 (patch)
tree8051dd6ea1520e6fa15850b9a0146cf1848e23d2
parentb1a15a8e248bcd2cd9ef826f75bb3ec77ae528ff (diff)
downloadotp-386ed8b033df2de4edd26de9f6512202337edfb3.tar.gz
otp-386ed8b033df2de4edd26de9f6512202337edfb3.tar.bz2
otp-386ed8b033df2de4edd26de9f6512202337edfb3.zip
ct_slave: ssh_port, ssh_opts options to start/3
Using these new options it is possible to specify ssh_port in a .spec file: [{node_start, [{ssh_port, 9999}]}]. And also to specify additional ssh options like paths to public-key files: [{node_start, [{ssh_opts, [{user_dir, "/home/shrek/e2/"}]}]}].
-rw-r--r--lib/common_test/src/ct_slave.erl19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl
index cac8bd4ee2..9ef6ec6e23 100644
--- a/lib/common_test/src/ct_slave.erl
+++ b/lib/common_test/src/ct_slave.erl
@@ -37,7 +37,7 @@
-record(options, {username, password, boot_timeout, init_timeout,
startup_timeout, startup_functions, monitor_master,
- kill_if_fail, erl_flags, env}).
+ kill_if_fail, erl_flags, env, ssh_port, ssh_opts}).
%%%-----------------------------------------------------------------
%%% @spec start(Node) -> Result
@@ -254,11 +254,13 @@ fetch_options(Options) ->
KillIfFail = get_option_value(kill_if_fail, Options, true),
ErlFlags = get_option_value(erl_flags, Options, []),
EnvVars = get_option_value(env, Options, []),
+ SSHPort = get_option_value(ssh_port, Options, []),
+ SSHOpts = get_option_value(ssh_opts, Options, []),
#options{username=UserName, password=Password,
boot_timeout=BootTimeout, init_timeout=InitTimeout,
startup_timeout=StartupTimeout, startup_functions=StartupFunctions,
monitor_master=Monitor, kill_if_fail=KillIfFail,
- erl_flags=ErlFlags, env=EnvVars}.
+ erl_flags=ErlFlags, env=EnvVars, ssh_port=SSHPort, ssh_opts=SSHOpts}.
% send a message when slave node is started
% @hidden
@@ -404,7 +406,13 @@ spawn_remote_node(Host, Node, Options) ->
#options{username=Username,
password=Password,
erl_flags=ErlFlags,
- env=Env} = Options,
+ env=Env,
+ ssh_port=MaybeSSHPort,
+ ssh_opts=SSHOpts} = Options,
+ SSHPort = case MaybeSSHPort of
+ [] -> 22; % Use default SSH port
+ A -> A
+ end,
SSHOptions = case {Username, Password} of
{[], []}->
[];
@@ -412,14 +420,13 @@ spawn_remote_node(Host, Node, Options) ->
[{user, Username}];
{_, _}->
[{user, Username}, {password, Password}]
- end ++ [{silently_accept_hosts, true}],
+ end ++ [{silently_accept_hosts, true}] ++ SSHOpts,
application:ensure_all_started(ssh),
- {ok, SSHConnRef} = ssh:connect(atom_to_list(Host), 22, SSHOptions),
+ {ok, SSHConnRef} = ssh:connect(atom_to_list(Host), SSHPort, SSHOptions),
{ok, SSHChannelId} = ssh_connection:session_channel(SSHConnRef, infinity),
ssh_setenv(SSHConnRef, SSHChannelId, Env),
ssh_connection:exec(SSHConnRef, SSHChannelId, get_cmd(Node, ErlFlags), infinity).
-
ssh_setenv(SSHConnRef, SSHChannelId, [{Var, Value} | Vars])
when is_list(Var), is_list(Value) ->
success = ssh_connection:setenv(SSHConnRef, SSHChannelId,