Fix netconf entity name creation during lookup
[integration/test.git] / csit / libraries / SSHKeywords.robot
index 2b83a592f6a1723ee4eaab7a250827d9ce2f568f..2d2080063304b749979c0a19d5ea558ac6d61047 100644 (file)
@@ -30,9 +30,9 @@ Open_Connection_To_ODL_System
     [Return]    ${odl_connection}
 
 Open_Connection_To_Tools_System
-    [Arguments]    ${ip_address}=${TOOLS_SYSTEM_IP}    ${timeout}=10s
+    [Arguments]    ${ip_address}=${TOOLS_SYSTEM_IP}    ${timeout}=10s    ${prompt}=${TOOLS_SYSTEM_PROMPT}
     [Documentation]    Open a connection to the tools system at ${ip_address} and return its identifier.
-    ${tools_connection} =    SSHLibrary.Open_Connection    ${ip_address}    prompt=${TOOLS_SYSTEM_PROMPT}    timeout=${timeout}
+    ${tools_connection} =    SSHLibrary.Open_Connection    ${ip_address}    prompt=${prompt}    timeout=${timeout}
     Flexible_Mininet_Login
     [Return]    ${tools_connection}
 
@@ -143,7 +143,7 @@ Assure_Library_Ipaddr
     [Documentation]    Tests whether ipaddr module is present on ssh-connected machine, Puts ipaddr.py to target_dir if not.
     ${passed} =    Execute_Command_Passes    bash -c 'cd "${target_dir}" && python -c "import ipaddr"'
     BuiltIn.Return_From_Keyword_If    ${passed}
-    SSHLibrary.Put_File    ${CURDIR}/ipaddr.py    ${target_dir}/
+    SSHLibrary.Put_File    ${CURDIR}/BGPCEP/ipaddr.py    ${target_dir}/
 
 Assure_Library_Counter
     [Arguments]    ${target_dir}=.
@@ -165,9 +165,10 @@ Virtual_Env_Set_Path
     BuiltIn.Set_Global_Variable    \${SSHKeywords__current_venv_path}    ${venv_path}
 
 Virtual_Env_Create
+    [Arguments]    ${upgrade_pip}=True
     [Documentation]    Creates virtual env. If not to use the default name, use Virtual_Env_Set_Path kw. Returns stdout.
     Execute_Command_At_Cwd_Should_Pass    virtualenv ${SSHKeywords__current_venv_path}
-    BuiltIn.Run_Keyword_And_Return    Virtual_Env_Run_Cmd_At_Cwd    pip install --upgrade pip
+    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.
@@ -186,11 +187,11 @@ Virtual_Env_Install_Package
 Virtual_Env_Uninstall_Package
     [Arguments]    ${package}
     [Documentation]    Uninstalls python package from virtual env and returns stdout.
-    BuiltIn.Run_Keyword_And_Return    Virtual_Env_Run_Cmd_At_Cwd    pip uninstall -y ${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
+    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
     [Arguments]    ${log_output}=${False}
@@ -251,3 +252,22 @@ Flexible_Controller_Login
     [Arguments]    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${delay}=0.5s
     [Documentation]    Call Flexible SSH Login, but with default values suitable for Controller machine.
     BuiltIn.Run Keyword And Return    Flexible SSH Login    user=${user}    password=${password}    delay=${delay}
+
+Move_File_To_Remote_System
+    [Arguments]    ${system}    ${source}    ${destination}=./    ${user}=${DEFAULT_USER}    ${password}=${DEFAULT_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}
+    ...    ${prompt_timeout}=5s
+    [Documentation]    Moves the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active
+    ...    ssh connection will be retained.
+    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
+    [Arguments]    ${system}    ${source}    ${destination}=./    ${user}=${DEFAULT_USER}    ${password}=${DEFAULT_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}
+    ...    ${prompt_timeout}=5s
+    [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.
+    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