Introduction

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.

Keywords

Arguments

target_dir
= .

Documentation

Tests whether Counter is present in collections on ssh-connected machine, Puts Counter.py to workspace if not.

Arguments

target_dir
= .

Documentation

Tests whether ipaddr module is present on ssh-connected machine, Puts ipaddr.py to target_dir if not.

Documentation

Check if netstat is installed and install it if not.

Arguments

system source destination
= ./

Documentation

Wrapper keyword to make it easier to copy a file to an ODL specific system

Arguments

system source destination
= ./
user
= ${DEFAULT_USER}
password
= ${DEFAULT_PASSWORD}
prompt
= ${DEFAULT_LINUX_PROMPT}
prompt_timeout
= 5s

Documentation

Copy the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active ssh connection will be retained.

Arguments

system source destination
= ./

Documentation

Wrapper keyword to make it easier to copy a file to an Tools specific system

Arguments

port state name

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

command log_on_success
= True
log_on_failure
= True
stderr_must_be_empty
= True

Documentation

Run Execute_Command_At_Path_Should_Pass with previously set CWD as path.

Arguments

command path
= None
log_on_success
= True
log_on_failure
= True
stderr_must_be_empty
= False

Documentation

A keyword similar to Execute_Command_Should_Pass which performs "cd" to ${path} before executing the ${command}. This is useful when rewriting bash scripts, as series of SSHLibrary.Execute_Command do not share current working directory. TODO: Perhaps a Keyword which sets up environment variables would be useful as well.

Arguments

command return_success_only
= True
log_on_success
= False
log_on_failure
= True
stderr_must_be_empty
= False

Documentation

Execute command via the active SSH connection. For success, rc has to be zero and optionally stderr has to be empty. Log everything, depending on arguments and success. Return either success string or stdout. TODO: Do we want to support customizing return values the same way as SSHLibrary.Execute_Command does?

Arguments

command log_on_success
= True
log_on_failure
= True
stderr_must_be_empty
= False

Documentation

A wrapper for Execute_Command_Passes with return_success_only=False Also, log_on_success defaults to True (but is customizable, unlike return_success_only)..

Arguments

user
= ${ODL_SYSTEM_USER}
password
= ${ODL_SYSTEM_PASSWORD}
delay
= 0.5s

Documentation

Call Flexible SSH Login, but with default values suitable for Controller machine.

Arguments

user
= ${TOOLS_SYSTEM_USER}
password
= ${TOOLS_SYSTEM_PASSWORD}
delay
= 0.5s

Documentation

Call Flexible SSH Login, but with default values suitable for Mininet machine.

Arguments

user password
= ${EMPTY}
delay
= 0.5s

Documentation

On active SSH session: if given non-empty password, do Login, else do Login With Public Key.

Documentation

Install netstat if it is not already installed.

Arguments

stdout stderr rc

Documentation

Log everything returned by SSHLibrary.Execute_Command

Arguments

system source destination
= ./
user
= ${DEFAULT_USER}
password
= ${DEFAULT_PASSWORD}
prompt
= ${DEFAULT_LINUX_PROMPT}
prompt_timeout
= 5s

Documentation

Moves the ${source} file to the ${destination} file on the remote ${system}. Any pre-existing active ssh connection will be retained.

Arguments

ip_address
= ${ODL_SYSTEM_IP}
timeout
= 10s

Documentation

Open a connection to the ODL system at ${ip_address} and return its identifier.

Arguments

ip_address
= ${TOOLS_SYSTEM_IP}
timeout
= 10s
prompt
= ${TOOLS_SYSTEM_PROMPT}

Documentation

Open a connection to the tools system at ${ip_address} and return its identifier.

Documentation

Verify current SSH connection leads to machine with python working. Fatal fail otherwise.

Arguments

connection_index

Documentation

Restore active SSH connection in SSHLibrary to given index.

Restore the currently active connection state in SSHLibrary to match the state returned by "Switch Connection" or "Get Connection". More specifically makes sure that there will be no active connection when the ${connection_index} reported by these means is None.

There is a misfeature in SSHLibrary: Invoking "SSHLibrary.Switch_Connection" and passing None as the "index_or_alias" argument to it has exactly the same effect as invoking "Close Connection". https://github.com/robotframework/SSHLibrary/blob/master/src/SSHLibrary/library.py#L560

We want to have Keyword which will "switch out" to previous "no connection active" state without killing the background one.

As some suites may hypothetically rely on non-writability of active connection, workaround is applied by opening and closing temporary connection. Unfortunately this will fail if run on Jython and there is no SSH server running on localhost, port 22 but there is nothing easy that can be done about it.

Arguments

keyword_name * args ** kwargs

Documentation

Store current connection index, run keyword returning its result, restore connection in teardown. Note that in order to avoid "got positional argument after named arguments", it is safer to use positional (not named) arguments on call.

Arguments

ip_address keyword_name * args ** kwargs

Documentation

Open temporary connection to given IP address, run keyword, close connection, restore previously active connection, return result.

Arguments

ip_address keyword_name * args ** kwargs

Documentation

Open connection to given IP address, run keyword, close connection, return result. This is unsafe in the sense that previously active session will be switched out off, but safe in the sense only the temporary connection is closed.

Arguments

path

Documentation

Set ${SSHKeywords__current_remote_working_directory} variable to ${path}. If SSH default is desired, use dot.

Arguments

system source destination
= ./
user
= ${DEFAULT_USER}
password
= ${DEFAULT_PASSWORD}
prompt
= ${DEFAULT_LINUX_PROMPT}
prompt_timeout
= 5s

Documentation

Copy the ${source} file to the ${destination} file on the remote ${system}. The keyword opens and closes a single ssh connection and does not rely on any existing ssh connection that may be open.

Arguments

system source destination
= ./
user
= ${DEFAULT_USER}
password
= ${DEFAULT_PASSWORD}
prompt
= ${DEFAULT_LINUX_PROMPT}
prompt_timeout
= 5s

Documentation

Moves the ${source} file to the ${destination} file on the remote ${system}. The keyword opens and closes a single ssh connection and does not rely on any existing ssh connection that may be open.

Arguments

log_output
= ${False}

Documentation

Activates virtual environment. To run anything in the env activated this way you should use SSHLibrary.Write and Read commands.

Arguments

upgrade_pip
= True

Documentation

Creates virtual env. If not to use the default name, use Virtual_Env_Set_Path kw. Returns stdout.

Arguments

upgrade_pip
= True

Documentation

Creates virtual env. If not to use the default name, use Virtual_Env_Set_Path kw. Returns stdout.

Arguments

log_output
= ${False}

Documentation

Deactivates virtual environment.

Documentation

Deletes a directory with virtual env.

Documentation

Shows installed packages within the returned stdout.

Arguments

package

Documentation

Installs python package into virtual env. Use with version if needed (e.g. exabgp==3.4.16). Returns stdout.

Arguments

cmd log_on_success
= True
log_on_failure
= True
stderr_must_be_empty
= True

Documentation

Runs given command within activated virtual env and returns stdout.

Arguments

venv_path

Documentation

Set ${SSHKeywords__current_venv_path} variable to ${venv_path}. Path should be absolute.

Arguments

package

Documentation

Uninstalls python package from virtual env and returns stdout.

SSHKeywords

image/svg+xml