-Restore Current SSH Connection From Index
- [Arguments] ${connection_index}
- [Documentation] Restore active SSH connection in SSHLibrary to given index.
- ...
- ... Restore the currently active connection state in
- ... SSHLibrary to match the state returned by "Switch
- ... Connection" or "Get Connection". More specifically makes
- ... sure that there will be no active connection when the
- ... \${connection_index} reported by these means is None.
- ...
- ... There is a misfeature in SSHLibrary: Invoking "SSHLibrary.Switch_Connection"
- ... and passing None as the "index_or_alias" argument to it has exactly the
- ... same effect as invoking "Close Connection".
- ... https://github.com/robotframework/SSHLibrary/blob/master/src/SSHLibrary/library.py#L560
- ...
- ... We want to have Keyword which will "switch out" to previous
- ... "no connection active" state without killing the background one.
- ...
- ... As some suites may hypothetically rely on non-writability of active connection,
- ... workaround is applied by opening and closing temporary connection.
- ... Unfortunately this will fail if run on Jython and there is no SSH server
- ... running on localhost, port 22 but there is nothing easy that can be done about it.
- BuiltIn.Run Keyword And Return If ${connection_index} is not None SSHLibrary.Switch Connection ${connection_index}
- # The background connection is still current, bury it.
- SSHLibrary.Open Connection 127.0.0.1
- SSHLibrary.Close Connection
-
-Open Controller Karaf Console On Background
- [Documentation] Connect to the controller's karaf console, but do not switch to it.
- ${current_ssh_connection}= SSHLibrary.Get Connection
- SSHLibrary.Open Connection ${ODL_SYSTEM_IP} port=${KARAF_SHELL_PORT} prompt=${KARAF_DETAILED_PROMPT}
- ${karaf_connection}= SSHLibrary.Get Connection
+Open_Controller_Karaf_Console_On_Background
+ [Arguments] ${member_index}=${1} ${timeout}=10 ${loglevel}=INFO
+ [Documentation] If there is a stored ssh connection index of connection to the controller's karaf console for ${member_index},
+ ... close the previous connection. In any case create a new connection
+ ... to karaf console for ${member_index}, set correct prompt set and login to karaf console.
+ ... Store connection index for ${member_index} and restore the previous active connection.
+ ${current_ssh_connection_object}= SSHLibrary.Get_Connection
+ BuiltIn.Log ${connection_index_dict}
+ BuiltIn.Log ${member_index}
+ ${status} ${old_connection_index} = BuiltIn.Run_Keyword_And_Ignore_Error Get From Dictionary ${connection_index_dict} ${member_index}
+ BuiltIn.Run_Keyword_If '${status}'=='PASS' BuiltIn.Run_Keywords SSHLibrary.Switch_Connection ${old_connection_index}
+ ... AND SSHLibrary.Close_Connection
+ ${odl_ip} = ClusterManagement.Resolve_IP_Address_For_Member ${member_index}
+ SSHLibrary.Open_Connection ${odl_ip} port=${KARAF_SHELL_PORT} prompt=${KARAF_PROMPT_LOGIN} timeout=${timeout}
+ ${karaf_connection_object} = SSHLibrary.Get_Connection
+ Collections.Set_To_Dictionary ${connection_index_dict} ${member_index} ${karaf_connection_object.index}
+ SSHLibrary.Login ${KARAF_USER} ${KARAF_PASSWORD} loglevel=${loglevel}
+ [Teardown] SSHKeywords.Restore_Current_Ssh_Connection_From_Index ${current_ssh_connection_object.index}
+
+Open_Controller_Karaf_Console_With_Timeout
+ [Arguments] ${member_index}=${1} ${timeout}=3s
+ [Documentation] Open new connection to karaf console for member index with specified timeout.
+ BuiltIn.Log ${member_index}
+ ${odl_ip} = ClusterManagement.Resolve_IP_Address_For_Member ${member_index}
+ SSHLibrary.Open_Connection ${odl_ip} port=${KARAF_SHELL_PORT} prompt=${KARAF_PROMPT_LOGIN} timeout=${timeout}