+ [Arguments] ${port} ${state} ${name}
+ ${output} = SSHLibrary.Execute_Command
+ ... ${NETSTAT_COMMAND} 2> /dev/null | grep -E ":${port} .+ ${state} .+${name}" | wc -l
+ RETURN ${output}
+
+Virtual_Env_Set_Path
+ [Documentation] Set \${SSHKeywords__current_venv_path} variable to ${venv_path}. Path should be absolute.
+ [Arguments] ${venv_path}
+ BuiltIn.Set_Global_Variable \${SSHKeywords__current_venv_path} ${venv_path}
+
+Virtual_Env_Create
+ [Documentation] Creates virtual env. If not to use the default name, use Virtual_Env_Set_Path kw. Returns stdout.
+ [Arguments] ${upgrade_pip}=True
+ Execute_Command_At_Cwd_Should_Pass virtualenv ${SSHKeywords__current_venv_path}
+ BuiltIn.Run_Keyword_And_Return_If
+ ... ${upgrade_pip}
+ ... Virtual_Env_Run_Cmd_At_Cwd
+ ... pip install --upgrade pip
+ ... stderr_must_be_empty=False
+
+Virtual_Env_Create_Python3
+ [Documentation] Creates virtual env. If not to use the default name, use Virtual_Env_Set_Path kw. Returns stdout.
+ [Arguments] ${upgrade_pip}=True
+ Execute_Command_At_Cwd_Should_Pass python3 -m venv ${SSHKeywords__current_venv_path}
+ BuiltIn.Run_Keyword_And_Return_If
+ ... ${upgrade_pip}
+ ... Virtual_Env_Run_Cmd_At_Cwd
+ ... pip install --upgrade pip
+ ... stderr_must_be_empty=False
+
+Virtual_Env_Delete
+ [Documentation] Deletes a directory with virtual env.
+ Execute_Command_At_Cwd_Should_Pass rm -rf ${SSHKeywords__current_venv_path}
+
+Virtual_Env_Run_Cmd_At_Cwd
+ [Documentation] Runs given command within activated virtual env and returns stdout.
+ [Arguments] ${cmd} ${log_on_success}=True ${log_on_failure}=True ${stderr_must_be_empty}=True
+ BuiltIn.Run_Keyword_And_Return
+ ... Execute_Command_At_Cwd_Should_Pass
+ ... source ${SSHKeywords__current_venv_path}/bin/activate; ${cmd}; deactivate
+ ... log_on_success=${log_on_success}
+ ... log_on_failure=${log_on_failure}
+ ... stderr_must_be_empty=${stderr_must_be_empty}
+
+Virtual_Env_Install_Package
+ [Documentation] Installs python package into virtual env. Use with version if needed (e.g. exabgp==3.4.16). Returns stdout.
+ [Arguments] ${package}
+ BuiltIn.Run_Keyword_And_Return
+ ... Virtual_Env_Run_Cmd_At_Cwd
+ ... pip install ${package}
+ ... stderr_must_be_empty=False
+
+Virtual_Env_Uninstall_Package
+ [Documentation] Uninstalls python package from virtual env and returns stdout.
+ [Arguments] ${package}
+ BuiltIn.Run_Keyword_And_Return
+ ... Virtual_Env_Run_Cmd_At_Cwd
+ ... pip uninstall -y ${package}
+ ... stderr_must_be_empty=False
+
+Virtual_Env_Freeze
+ [Documentation] Shows installed packages within the returned stdout.
+ BuiltIn.Run_Keyword_And_Return Virtual_Env_Run_Cmd_At_Cwd pip freeze --all stderr_must_be_empty=False
+
+Virtual_Env_Activate_On_Current_Session
+ [Documentation] Activates virtual environment. To run anything in the env activated this way you should use SSHLibrary.Write and Read commands.
+ [Arguments] ${log_output}=${False}
+ SSHLibrary.Write source ${SSHKeywords__current_venv_path}/bin/activate
+ ${output} = SSHLibrary.Read_Until_Prompt
+ IF ${log_output}==${True} BuiltIn.Log ${output}
+
+Virtual_Env_Deactivate_On_Current_Session
+ [Documentation] Deactivates virtual environment.
+ [Arguments] ${log_output}=${False}
+ SSHLibrary.Write deactivate
+ ${output} = SSHLibrary.Read_Until_Prompt
+ IF ${log_output}==${True} BuiltIn.Log ${output}
+
+Unsafe_Copy_File_To_Remote_System
+ [Documentation] Copy the ${source} file to the ${destination} file on the remote ${system}. The keyword opens and closes a single
+ ... ssh connection and does not rely on any existing ssh connection that may be open.
+ [Arguments] ${system} ${source} ${destination}=./ ${user}=${DEFAULT_USER} ${password}=${DEFAULT_PASSWORD} ${prompt}=${DEFAULT_LINUX_PROMPT}
+ ... ${prompt_timeout}=5s
+ SSHLibrary.Open_Connection ${system} prompt=${prompt} timeout=${prompt_timeout}
+ Flexible_SSH_Login ${user} ${password}
+ SSHLibrary.Put_File ${source} ${destination}
+ SSHLibrary.Close Connection
+
+Copy_File_To_Remote_System
+ [Documentation] Copy the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active
+ ... ssh connection will be retained.
+ [Arguments] ${system} ${source} ${destination}=./ ${user}=${DEFAULT_USER} ${password}=${DEFAULT_PASSWORD} ${prompt}=${DEFAULT_LINUX_PROMPT}
+ ... ${prompt_timeout}=5s
+ SSHKeywords.Run_Keyword_Preserve_Connection
+ ... SSHKeywords.Unsafe_Copy_File_To_Remote_System
+ ... ${system}
+ ... ${source}
+ ... ${destination}
+ ... ${user}
+ ... ${password}
+ ... ${prompt}
+ ... ${prompt_timeout}
+
+Copy_File_To_Odl_System
+ [Documentation] Wrapper keyword to make it easier to copy a file to an ODL specific system
+ [Arguments] ${system} ${source} ${destination}=./
+ SSHKeywords.Copy_File_To_Remote_System
+ ... ${system}
+ ... ${source}
+ ... ${destination}
+ ... ${ODL_SYSTEM_USER}
+ ... ${ODL_SYSTEM_PASSWORD}
+ ... ${ODL_SYSTEM_PROMPT}
+
+Copy_File_To_Tools_System
+ [Documentation] Wrapper keyword to make it easier to copy a file to an Tools specific system
+ [Arguments] ${system} ${source} ${destination}=./
+ SSHKeywords.Copy_File_To_Remote_System
+ ... ${system}
+ ... ${source}
+ ... ${destination}
+ ... ${TOOLS_SYSTEM_USER}
+ ... ${TOOLS_SYSTEM_PASSWORD}
+ ... ${TOOLS_SYSTEM_PROMPT}
+
+Flexible_SSH_Login
+ [Documentation] On active SSH session: if given non-empty password, do Login, else do Login With Public Key.
+ [Arguments] ${user} ${password}=${EMPTY} ${delay}=0.5s
+ ${pwd_length} = BuiltIn.Get Length ${password}
+ # ${pwd_length} is guaranteed to be an integer, so we are safe to evaluate it as Python expression.
+ BuiltIn.Run Keyword And Return If
+ ... ${pwd_length} > 0
+ ... SSHLibrary.Login
+ ... ${user}
+ ... ${password}
+ ... delay=${delay}
+ BuiltIn.Run Keyword And Return
+ ... SSHLibrary.Login With Public Key
+ ... ${user}
+ ... ${USER_HOME}/.ssh/${SSH_KEY}
+ ... ${KEYFILE_PASS}
+ ... delay=${delay}
+
+Flexible_Mininet_Login
+ [Documentation] Call Flexible SSH Login, but with default values suitable for Mininet machine.
+ [Arguments] ${user}=${TOOLS_SYSTEM_USER} ${password}=${TOOLS_SYSTEM_PASSWORD} ${delay}=0.5s
+ BuiltIn.Run Keyword And Return Flexible SSH Login user=${user} password=${password} delay=${delay}
+
+Flexible_Controller_Login
+ [Documentation] Call Flexible SSH Login, but with default values suitable for Controller machine.
+ [Arguments] ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${delay}=0.5s
+ BuiltIn.Run Keyword And Return Flexible SSH Login user=${user} password=${password} delay=${delay}
+
+Move_File_To_Remote_System
+ [Documentation] Moves the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active
+ ... ssh connection will be retained.
+ [Arguments] ${system} ${source} ${destination}=./ ${user}=${DEFAULT_USER} ${password}=${DEFAULT_PASSWORD} ${prompt}=${DEFAULT_LINUX_PROMPT}
+ ... ${prompt_timeout}=5s
+ SSHKeywords.Run_Keyword_Preserve_Connection
+ ... Unsafe_Move_File_To_Remote_System
+ ... ${system}
+ ... ${source}
+ ... ${destination}
+ ... ${user}
+ ... ${password}
+ ... ${prompt}
+ ... ${prompt_timeout}
+
+Unsafe_Move_File_To_Remote_System
+ [Documentation] Moves the ${source} file to the ${destination} file on the remote ${system}. The keyword opens and closes a single
+ ... ssh connection and does not rely on any existing ssh connection that may be open.
+ [Arguments] ${system} ${source} ${destination}=./ ${user}=${DEFAULT_USER} ${password}=${DEFAULT_PASSWORD} ${prompt}=${DEFAULT_LINUX_PROMPT}
+ ... ${prompt_timeout}=5s
+ SSHLibrary.Open_Connection ${system} prompt=${prompt} timeout=${prompt_timeout}
+ Flexible_SSH_Login ${user} ${password}
+ SSHLibrary.Put File ${source} ${destination}
+ OperatingSystem.Remove File ${source}
+ SSHLibrary.Close Connection