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.
16 Resource ${CURDIR}/Utils.robot
19 Open_Connection_To_ODL_System
20 [Documentation] Open a connection to the ODL system and return its identifier.
21 ... On clustered systems this opens the connection to the first node.
22 ${odl}= SSHLibrary.Open_Connection ${ODL_SYSTEM_IP} prompt=${ODL_SYSTEM_PROMPT} timeout=10s
23 Utils.Flexible_Controller_Login
26 Open_Connection_To_Tools_System
27 [Documentation] Open a connection to the tools system and return its identifier.
28 ${tools}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${TOOLS_SYSTEM_PROMPT}
29 Utils.Flexible_Mininet_Login
32 Execute_Command_Passes
33 [Arguments] ${command}
34 [Documentation] Execute command via SSH. If RC is nonzero, log everything. Retrun bool string of command success.
35 ${stdout} ${stderr} ${rc} = SSHLibrary.Execute_Command ${command} return_stderr=True return_rc=True
36 BuiltIn.Return_From_Keyword_If ${rc} == 0 True
43 [Documentation] Verify current SSH connection leads to machine with python working. Fatal fail otherwise.
44 ${passed} = Execute_Command_Passes python --help
45 BuiltIn.Return_From_Keyword_If ${passed}
46 BuiltIn.Fatal_Error Python is not installed!
49 [Arguments] ${target_dir}=.
50 [Documentation] Tests whether ipaddr module is present on ssh-connected machine, Puts ipaddr.py to target_dir if not.
51 ${passed} = Execute_Command_Passes bash -c 'cd "${target_dir}" && python -c "import ipaddr"'
52 BuiltIn.Return_From_Keyword_If ${passed}
53 SSHLibrary.Put_File ${CURDIR}/ipaddr.py ${target_dir}/
55 Assure_Library_Counter
56 [Arguments] ${target_dir}=.
57 [Documentation] Tests whether Counter is present in collections on ssh-connected machine, Puts Counter.py to workspace if not.
58 ${passed} = Execute_Command_Passes bash -c 'cd "${target_dir}" && python -c "from collections import Counter"'
59 # TODO: Move the bash-cd wrapper to separate keyword?
60 BuiltIn.Return_From_Keyword_If ${passed}
61 SSHLibrary.Put_File ${CURDIR}/Counter.py ${target_dir}/
64 [Arguments] ${port} ${state} ${name}
65 [Documentation] Run 'netstat' on the remote machine and count occurences of given port in the given state connected to process with the given name.
66 ${output}= SSHLibrary.Execute_Command netstat -natp 2> /dev/null | grep -E ":${port} .+ ${state} .+${name}" | wc -l