2 Documentation Resource enhancing SSHLibrary with Keywords used in multiple suites.
4 ... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
11 ... Some suites evolved utility Keywords re-usable with other suites.
12 ... When the Keywords assume a SSH session is active,
13 ... and if the Keywords do not fit into a more specific Resource,
14 ... you can place them here.
18 Execute_Command_Passes
19 [Arguments] ${command}
20 [Documentation] Execute command via SSH. If RC is nonzero, log everything. Retrun bool string of command success.
21 ${stdout} ${stderr} ${rc} = SSHLibrary.Execute_Command ${command} return_stderr=True return_rc=True
22 BuiltIn.Return_From_Keyword_If ${rc} == 0 True
29 [Documentation] Verify current SSH connection leads to machine with python working. Fatal fail otherwise.
30 ${passed} = Execute_Command_Passes python --help
31 BuiltIn.Return_From_Keyword_If ${passed}
32 BuiltIn.Fatal_Error Python is not installed!
35 [Arguments] ${target_dir}=.
36 [Documentation] Tests whether ipaddr module is present on ssh-connected machine, Puts ipaddr.py to target_dir if not.
37 ${passed} = Execute_Command_Passes bash -c 'cd "${target_dir}" && python -c "import ipaddr"'
38 BuiltIn.Return_From_Keyword_If ${passed}
39 SSHLibrary.Put_File ${CURDIR}/ipaddr.py ${target_dir}/
41 Assure_Library_Counter
42 [Arguments] ${target_dir}=.
43 [Documentation] Tests whether Counter is present in collections on ssh-connected machine, Puts Counter.py to workspace if not.
44 ${passed} = Execute_Command_Passes bash -c 'cd "${target_dir}" && python -c "from collections import Counter"'
45 # TODO: Move the bash-cd wrapper to separate keyword?
46 BuiltIn.Return_From_Keyword_If ${passed}
47 SSHLibrary.Put_File ${CURDIR}/Counter.py ${target_dir}/
50 [Arguments] ${port} ${state} ${name}
51 [Documentation] Run 'netstat' on the remote machine and count occurences of given port in the given state connected to process with the given name.
52 ${output}= SSHLibrary.Execute_Command netstat -natp 2> /dev/null | grep -E ":${port} .+ ${state} .+${name}" | wc -l