*** Settings *** Documentation Resource enhancing SSHLibrary with Keywords used in multiple suites. ... ... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. ... ... This program and the accompanying materials are made available under the ... terms of the Eclipse Public License v1.0 which accompanies this distribution, ... and is available at http://www.eclipse.org/legal/epl-v10.html ... ... ... Some suites evolved utility Keywords re-usable with other suites. ... When the Keywords assume a SSH session is active, ... and if the Keywords do not fit into a more specific Resource, ... you can place them here. Library SSHLibrary *** Keywords *** Execute_Command_Passes [Arguments] ${command} [Documentation] Execute command via SSH. If RC is nonzero, log everything. Retrun bool string of command success. ${stdout} ${stderr} ${rc} = SSHLibrary.Execute_Command ${command} return_stderr=True return_rc=True BuiltIn.Return_From_Keyword_If ${rc} == 0 True BuiltIn.Log ${stdout} BuiltIn.Log ${stderr} BuiltIn.Log ${rc} [Return] False Require_Python [Documentation] Verify current SSH connection leads to machine with python working. Fatal fail otherwise. ${passed} = Execute_Command_Passes python --help BuiltIn.Return_From_Keyword_If ${passed} BuiltIn.Fatal_Error Python is not installed! Assure_Library_Ipaddr [Arguments] ${target_dir}=. [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}/ Assure_Library_Counter [Arguments] ${target_dir}=. [Documentation] Tests whether Counter is present in collections on ssh-connected machine, Puts Counter.py to workspace if not. ${passed} = Execute_Command_Passes bash -c 'cd "${target_dir}" && python -c "from collections import Counter"' # TODO: Move the bash-cd wrapper to separate keyword? BuiltIn.Return_From_Keyword_If ${passed} SSHLibrary.Put_File ${CURDIR}/Counter.py ${target_dir}/