More readable log message for ExecuteCommandOnRemoteSystem
[integration/test.git] / csit / libraries / Utils.robot
index 7afb4781cd18392cc2b65626435b082ad6cae01e..13b1dd1b29db890d5f4c5de847c1a6e231ef6446 100644 (file)
@@ -232,12 +232,14 @@ Run Command On Remote System
     [Documentation]    Reduces the common work of running a command on a remote system to a single higher level
     ...    robot keyword, taking care to log in with a public key and. The command given is written
     ...    and the output returned. No test conditions are checked.
-    Log    Attempting to execute ${cmd} on ${system} by ${user} with ${keyfile_pass} and ${prompt}
+    ${current_ssh_connection}=    SSHLibrary.Get Connection
+    Log    Attempting to execute command "${cmd}" on remote system "${system}" by user "${user}" with keyfile pass "${keyfile_pass}" and prompt "${prompt}"
     ${conn_id}=    SSHLibrary.Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
     Flexible SSH Login    ${user}    ${password}
     ${stdout}    ${stderr}    SSHLibrary.Execute Command    ${cmd}    return_stderr=True
     SSHLibrary.Close Connection
     Log    ${stderr}
+    [Teardown]    KarafKeywords.Restore_Current_SSH_Connection_From_Index    ${current_ssh_connection.index}
     [Return]    ${stdout}
 
 Write_Bare_Ctrl_C
@@ -482,9 +484,18 @@ Convert_To_Minutes
     [Return]    ${minutes}
 
 Write Commands Until Expected Prompt
-    [Arguments]    ${cmd}    ${prompt}    ${timeout}=${DEFAULT_TIMEOUT}
+    [Arguments]    ${cmd}    ${prompt}    ${timeout}=30s
     [Documentation]    quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
     SSHLibrary.Set Client Configuration    timeout=${timeout}
     SSHLibrary.Write    ${cmd}
     ${output}=    SSHLibrary.Read Until    ${prompt}
     [Return]    ${output}
+
+Install Package On Ubuntu System
+    [Arguments]    ${package_name}    ${system}=${TOOLS_SYSTEM_IP}    ${user}=${TOOLS_SYSTEM_USER}    ${password}=${TOOLS_SYSTEM_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}    ${prompt_timeout}=30s
+    [Documentation]    Keyword to install packages for testing to Ubuntu Mininet VM
+    Log    Keyword to install package to Mininet Ubuntu VM
+    Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
+    Flexible Mininet Login    user=${user}    password=${password}
+    Write    sudo apt-get install -y ${package_name}
+    Read Until    ${prompt}