From cb38e3fc05bde68a563d5afb7737a6b8a98f8d53 Mon Sep 17 00:00:00 2001 From: lubos-cicut Date: Wed, 14 Aug 2024 13:48:58 +0200 Subject: [PATCH] Install net-tools if not already installed To check if the device is up, we use netstat, which is not pre-installed in newer versions of Ubuntu. Change-Id: Iab6c5773c441fe0f110f804fd2f66b37624b2828 Signed-off-by: lubos-cicut --- csit/libraries/SSHKeywords.robot | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/csit/libraries/SSHKeywords.robot b/csit/libraries/SSHKeywords.robot index c2073d5347..3f348d010d 100644 --- a/csit/libraries/SSHKeywords.robot +++ b/csit/libraries/SSHKeywords.robot @@ -197,10 +197,23 @@ Assure_Library_Counter Count_Port_Occurences [Documentation] Run 'netstat' on the remote machine and count occurences of given port in the given state connected to process with the given name. [Arguments] ${port} ${state} ${name} + BuiltIn.Run Keyword And Ignore Error Check_And_Install_Netstat ${output} = SSHLibrary.Execute_Command ... ${NETSTAT_COMMAND} 2> /dev/null | grep -E ":${port} .+ ${state} .+${name}" | wc -l RETURN ${output} +Check_And_Install_Netstat + [Documentation] Check if netstat is installed and install it if not. + ${netstat_installed} = SSHLibrary.Execute_Command netstat --version + IF '${netstat_installed}' is not string and '${netstat_installed}' != '0' + Install_Netstat + END + +Install_Netstat + [Documentation] Install netstat if it is not already installed. + SSHLibrary.Execute_Command sudo apt-get update + SSHLibrary.Execute_Command sudo apt-get install -y net-tools + Virtual_Env_Set_Path [Documentation] Set \${SSHKeywords__current_venv_path} variable to ${venv_path}. Path should be absolute. [Arguments] ${venv_path} -- 2.36.6