aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/unix_telnet.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/src/unix_telnet.erl')
-rw-r--r--lib/common_test/src/unix_telnet.erl36
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/common_test/src/unix_telnet.erl b/lib/common_test/src/unix_telnet.erl
index 99ce92e9f1..71df2ab44e 100644
--- a/lib/common_test/src/unix_telnet.erl
+++ b/lib/common_test/src/unix_telnet.erl
@@ -94,11 +94,16 @@ connect(Ip,Port,Timeout,KeepAlive,Extra) ->
{Username,Password} ->
connect1(Ip,Port,Timeout,KeepAlive,Username,Password);
Name ->
- case get_username_and_password(Name) of
- {ok,{Username,Password}} ->
- connect1(Ip,Port,Timeout,KeepAlive,Username,Password);
- Error ->
- Error
+ case not_require_user_and_pass(Name) of
+ true ->
+ connect_without_username_and_pass(Ip,Port,Timeout,KeepAlive);
+ _ ->
+ case get_username_and_password(Name) of
+ {ok,{Username,Password}} ->
+ connect1(Ip,Port,Timeout,KeepAlive,Username,Password);
+ Error ->
+ Error
+ end
end
end.
@@ -144,6 +149,27 @@ connect1(Ip,Port,Timeout,KeepAlive,Username,Password) ->
end_log(),
Result.
+connect_without_username_and_pass(Ip,Port,Timeout,KeepAlive) ->
+ start_log("unix_telnet:connect"),
+ Result =
+ case ct_telnet_client:open(Ip,Port,Timeout,KeepAlive) of
+ {ok,Pid} ->
+ {ok, Pid};
+ Error ->
+ cont_log("Could not open telnet connection\n~p\n",[Error]),
+ Error
+ end,
+ end_log(),
+ Result.
+
+not_require_user_and_pass(Name) ->
+ case ct:get_config({Name, not_require_user_and_pass}) of
+ undefined ->
+ false;
+ _ ->
+ true
+ end.
+
get_username_and_password(Name) ->
case ct:get_config({Name,username}) of
undefined ->