Table Of Contents

This Page

nepi.resources.linux package

Submodules

nepi.resources.linux.application module

class nepi.resources.linux.application.LinuxApplication(ec, guid)[source]

Bases: nepi.execution.resource.ResourceManager

Class Args :
Parameters:
  • ec (ExperimentController) – The Experiment controller
  • guid (int) – guid of the RM

Note

A LinuxApplication RM represents a process that can be executed in a remote Linux host using SSH.

The LinuxApplication RM takes care of uploadin sources and any files needed to run the experiment, to the remote host. It also allows to provide source compilation (build) and installation instructions, and takes care of automating the sources build and installation tasks for the user.

It is important to note that files uploaded to the remote host have two possible scopes: single-experiment or multi-experiment. Single experiment files are those that will not be re-used by other experiments. Multi-experiment files are those that will. Sources and shared files are always made available to all experiments.

Directory structure:

The directory structure used by LinuxApplication RM at the Linux host is the following:

${HOME}/.nepi/nepi-usr –> Base directory for multi-experiment files

${LIB} |- /lib –> Base directory for libraries ${BIN} |- /bin –> Base directory for binary files ${SRC} |- /src –> Base directory for sources ${SHARE} |- /share –> Base directory for other files

${HOME}/.nepi/nepi-exp –> Base directory for single-experiment files

${EXP_HOME} |- /<exp-id> –> Base directory for experiment exp-id

${APP_HOME} |- /<app-guid> –> Base directory for application
specific files (e.g. command.sh, input)

${RUN_HOME} |- /<run-id> –> Base directory for run specific

app_home[source]
build(build=None)[source]
do_deploy()[source]
do_provision()[source]
do_release()[source]
do_start()[source]
do_stop()[source]

Stops application execution

execute_command(command, env=None, sudo=False, tty=False, forward_x11=False, blocking=False)[source]
execute_deploy_command(command, prefix='deploy')[source]
in_foreground[source]

Returns True if the command needs to be executed in foreground. This means that command will be executed using ‘execute’ instead of ‘run’ (‘run’ executes a command in background and detached from the terminal)

When using X11 forwarding option, the command can not run in background and detached from a terminal, since we need to keep the terminal attached to interact with it.

install(install=None)[source]
install_dependencies(depends=None)[source]
log_message(msg)[source]
node[source]
pid[source]
ppid[source]
replace_paths(command, node=None, app_home=None, run_home=None)[source]

Replace all special path tags with shell-escaped actual paths.

run_home[source]
state[source]

Returns the state of the application

trace(name, attr='all', block=512, offset=0)[source]
trace_filepath(filename)[source]
upload_binaries(bins=None)[source]
upload_code(code=None)[source]
upload_files(files=None)[source]
upload_libraries(libs=None)[source]
upload_sources(sources=None, src_dir=None)[source]
upload_start_command(overwrite=False)[source]
upload_stdin(stdin=None)[source]
valid_connection(guid)[source]

nepi.resources.linux.channel module

class nepi.resources.linux.channel.LinuxChannel(ec, guid)[source]

Bases: nepi.execution.resource.ResourceManager

log_message(msg)[source]
valid_connection(guid)[source]

nepi.resources.linux.debfuncs module

nepi.resources.linux.debfuncs.install_packages_command(os, packages)[source]
nepi.resources.linux.debfuncs.remove_packages_command(os, packages)[source]

nepi.resources.linux.gretunnel module

class nepi.resources.linux.gretunnel.LinuxGRETunnel(ec, guid)[source]

Bases: nepi.resources.linux.tunnel.LinuxTunnel

check_state_connection()[source]
establish_connection(endpoint, remote_endpoint, data)[source]
get_endpoints()[source]

Returns the list of RM that are endpoints to the tunnel

initiate_connection(endpoint, remote_endpoint)[source]
log_message(msg)[source]
terminate_connection(endpoint, remote_endpoint)[source]
valid_connection(guid)[source]
verify_connection(endpoint, remote_endpoint)[source]

nepi.resources.linux.interface module

class nepi.resources.linux.interface.LinuxInterface(ec, guid)[source]

Bases: nepi.execution.resource.ResourceManager

add_set_hooks()[source]
channel[source]
do_deploy()[source]
do_discover()[source]
do_provision()[source]
do_release()[source]
load_configuration(devname, mac, ip4, mask4, ip6, mask6, mtu, up)[source]
log_message(msg)[source]
node[source]
set_hook_mtu(oldval, newval)[source]
set_hook_up(oldval, newval)[source]
valid_connection(guid)[source]

nepi.resources.linux.mtr module

class nepi.resources.linux.mtr.LinuxMtr(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

do_deploy()[source]
do_start()[source]
upload_start_command()[source]
valid_connection(guid)[source]

nepi.resources.linux.node module

class nepi.resources.linux.node.ExitCode[source]

Error codes that the rexitcode function can return if unable to check the exit code of a spawned process

CORRUPTFILE = -2
ERROR = -3
FILENOTFOUND = -1
OK = 0
class nepi.resources.linux.node.LinuxNode(ec, guid)[source]

Bases: nepi.execution.resource.ResourceManager

Class Args :
Parameters:
  • ec (ExperimentController) – The Experiment controller
  • guid (int) – guid of the RM

Note

There are different ways in which commands can be executed using the LinuxNode interface (i.e. ‘execute’ - blocking and non blocking, ‘run’, ‘run_and_wait’).

Brief explanation:

  • ‘execute’ (blocking mode) :

    HOW IT WORKS: ‘execute’, forks a process and run the command, synchronously, attached to the terminal, in foreground. The execute method will block until the command returns the result on ‘out’, ‘err’ (so until it finishes executing).

    USAGE: short-lived commands that must be executed attached to a terminal and in foreground, for which it IS necessary to block until the command has finished (e.g. if you want to run ‘ls’ or ‘cat’).

  • ‘execute’ (NON blocking mode - blocking = False) :

    HOW IT WORKS: Same as before, except that execute method will return immediately (even if command still running).

    USAGE: long-lived commands that must be executed attached to a terminal and in foreground, but for which it is not necessary to block until the command has finished. (e.g. start an application using X11 forwarding)

  • ‘run’ :

    HOW IT WORKS: Connects to the host ( using SSH if remote) and launches the command in background, detached from any terminal (daemonized), and returns. The command continues to run remotely, but since it is detached from the terminal, its pipes (stdin, stdout, stderr) can’t be redirected to the console (as normal non detached processes would), and so they are explicitly redirected to files. The pidfile is created as part of the process of launching the command. The pidfile holds the pid and ppid of the process forked in background, so later on it is possible to check whether the command is still running.

    USAGE: long-lived commands that can run detached in background, for which it is NOT necessary to block (wait) until the command has finished. (e.g. start an application that is not using X11 forwarding. It can run detached and remotely in background)

  • ‘run_and_wait’ :

    HOW IT WORKS: Similar to ‘run’ except that it ‘blocks’ until the command has finished execution. It also checks whether errors occurred during runtime by reading the exitcode file, which contains the exit code of the command that was run (checking stderr only is not always reliable since many commands throw debugging info to stderr and the only way to automatically know whether an error really happened is to check the process exit code).

    Another difference with respect to ‘run’, is that instead of directly executing the command as a bash command line, it uploads the command to a bash script and runs the script. This allows to use the bash script to debug errors, since it remains at the remote host and can be run manually to reproduce the error.

    USAGE: medium-lived commands that can run detached in background, for which it IS necessary to block (wait) until the command has finished. (e.g. Package installation, source compilation, file download, etc)

bin_dir[source]
check_errors(home, ecodefile='exitcode', stderr='stderr')[source]

Checks whether errors occurred while running a command. It first checks the exit code for the command, and only if the exit code is an error one it returns the error output.

check_output(home, filename)[source]

Retrives content of file

clean_experiment()[source]

Cleans all experiment related files in the Linux host. It preserves NEPI files and folders that have a multi experiment scope.

clean_home()[source]

Cleans all NEPI related folders in the Linux host

clean_processes()[source]
copy(src, dst)[source]
do_deploy()[source]
do_provision()[source]
do_release()[source]
download(src, dst, raise_on_error=True)[source]
execute(command, sudo=False, env=None, tty=False, forward_x11=False, retry=3, connect_timeout=30, strict_host_checking=False, persistent=True, blocking=True, with_lock=False)[source]

Notice that this invocation will block until the execution finishes. If this is not the desired behavior, use ‘run’ instead.

exitcode(home, ecodefile='exitcode')[source]

Get the exit code of an application. Returns an integer value with the exit code

exp_dir[source]
exp_home[source]
filter_existing_files(src, dst)[source]

Removes files that already exist in the Linux host from src list

find_home()[source]

Retrieves host home directory

format_environment(env, inline=False)[source]
Formats the environment variables for a command to be executed
either as an inline command (i.e. export PYTHONPATH=src/..; export LALAL= ..;python script.py) or as a bash script (i.e. export PYTHONPATH=src/..

export LALA=..

)

get_os()[source]
getpid(home, pidfile='pidfile')[source]
home_dir[source]
install_packages(packages, home, run_home=None, raise_on_error=True)[source]

Install packages in the Linux host.

‘home’ is the directory to upload the package installation script. ‘run_home’ is the directory from where to execute the script.

install_packages_command(packages)[source]
is_alive()[source]

Checks if host is responsive

kill(pid, ppid, sudo=False)[source]
lib_dir[source]
localhost[source]
log_message(msg)[source]
mkdir(paths, clean=False)[source]

Paths is either a single remote directory path to create, or a list of directories to create.

nepi_home[source]
node_home[source]
os[source]
remove_packages(packages, home, run_home=None, raise_on_error=True)[source]

Uninstall packages from the Linux host.

‘home’ is the directory to upload the package un-installation script. ‘run_home’ is the directory from where to execute the script.

rmdir(paths)[source]

Paths is either a single remote directory path to delete, or a list of directories to delete.

run(command, home, create_home=False, pidfile='pidfile', stdin=None, stdout='stdout', stderr='stderr', sudo=False, tty=False, strict_host_checking=False)[source]
run_and_wait(command, home, shfile='cmd.sh', env=None, overwrite=True, wait_run=True, pidfile='pidfile', ecodefile='exitcode', stdin=None, stdout='stdout', stderr='stderr', sudo=False, tty=False, raise_on_error=True)[source]

Uploads the ‘command’ to a bash script in the host. Then runs the script detached in background in the host, and busy-waites until the script finishes executing.

run_home[source]
share_dir[source]
src_dir[source]
status(pid, ppid)[source]
upload(src, dst, text=False, overwrite=True, raise_on_error=True)[source]

Copy content to destination

src string with the content to copy. Can be:
  • plain text
  • a string with the path to a local file
  • a string with a semi-colon separeted list of local files
  • a string with a local directory
dst string with destination path on the remote host (remote is
always self.host)

text src is text input, it must be stored into a temp file before uploading

upload_command(command, shfile='cmd.sh', ecodefile='exitcode', overwrite=True, env=None)[source]

Saves the command as a bash script file in the remote host, and forces to save the exit code of the command execution to the ecodefile

use_deb[source]
use_rpm[source]
usr_dir[source]
valid_connection(guid)[source]
wait_pid(home, pidfile='pidfile', raise_on_error=False)[source]

Waits until the pid file for the command is generated, and returns the pid and ppid of the process

wait_run(pid, ppid, trial=0)[source]

wait for a remote process to finish execution

class nepi.resources.linux.node.OSType[source]

Supported flavors of Linux OS

DEBIAN = 1
FEDORA = 4
FEDORA_12 = 20
FEDORA_14 = 36
FEDORA_8 = 12
UBUNTU = 2

nepi.resources.linux.nping module

class nepi.resources.linux.nping.LinuxNPing(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

do_deploy()[source]
valid_connection(guid)[source]

nepi.resources.linux.ping module

class nepi.resources.linux.ping.LinuxPing(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

do_deploy()[source]
do_start()[source]
upload_start_command()[source]
valid_connection(guid)[source]

nepi.resources.linux.route module

class nepi.resources.linux.route.LinuxRoute(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

device[source]
do_deploy()[source]
do_start()[source]
do_stop()[source]
node[source]
upload_sources()[source]
upload_start_command()[source]

nepi.resources.linux.rpmfuncs module

nepi.resources.linux.rpmfuncs.install_packages_command(os, packages)[source]
nepi.resources.linux.rpmfuncs.install_rpmfusion_command(os)[source]
nepi.resources.linux.rpmfuncs.remove_packages_command(os, packages)[source]

nepi.resources.linux.tap module

class nepi.resources.linux.tap.LinuxTap(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

IFF_TAP = 2
IFF_TUN = 1
check_status()[source]
do_deploy()[source]
do_release()[source]
do_start()[source]
do_stop()[source]
establish_udp_connection(remote_endpoint, connection_app_home, connection_run_home, port)[source]
gre_connect(remote_endpoint, connection_app_home, connection_run_home)[source]
gre_enabled[source]
initiate_udp_connection(remote_endpoint, connection_app_home, connection_run_home, cipher, cipher_key, bwlimit, txqueuelen)[source]
node[source]
sock_name[source]
state[source]
terminate_connection(remote_endpoint, connection_app_home, connection_run_home)[source]
udp_connect(remote_endpoint, connection_app_home, connection_run_home, cipher, cipher_key, bwlimit, txqueuelen)[source]
upload_sources()[source]
upload_start_command()[source]
valid_connection(guid)[source]
verify_connection(remote_endpoint, connection_app_home, connection_run_home)[source]
vif_prefix[source]
vif_type[source]
vif_type_flag[source]
wait_file(home, filename)[source]

Waits until file on endpoint is generated

nepi.resources.linux.tcpdump module

class nepi.resources.linux.tcpdump.LinuxTcpdump(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

do_deploy()[source]
valid_connection(guid)[source]

nepi.resources.linux.traceroute module

class nepi.resources.linux.traceroute.LinuxTraceroute(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

do_deploy()[source]
do_start()[source]
upload_start_command()[source]
valid_connection(guid)[source]

nepi.resources.linux.tun module

class nepi.resources.linux.tun.LinuxTun(ec, guid)[source]

Bases: nepi.resources.linux.tap.LinuxTap

nepi.resources.linux.tunnel module

class nepi.resources.linux.tunnel.LinuxTunnel(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

app_home(endpoint)[source]
check_state_connection(endpoint, remote_endpoint)[source]
do_deploy()[source]
do_provision()[source]
do_start()[source]
do_stop()[source]

Stops application execution

endpoint1[source]
endpoint2[source]
endpoint_mkdir(endpoint)[source]
establish_connection(endpoint, remote_endpoint, data)[source]
get_endpoints()[source]

Returns the list of RM that are endpoints to the tunnel

initiate_connection(endpoint, remote_endpoint)[source]
log_message(msg)[source]
run_home(endpoint)[source]
state[source]

Returns the state of the application

terminate_connection(endpoint, remote_endpoint)[source]
valid_connection(guid)[source]
verify_connection(endpoint, remote_endpoint)[source]

nepi.resources.linux.udptest module

class nepi.resources.linux.udptest.LinuxUdpTest(ec, guid)[source]

Bases: nepi.resources.linux.application.LinuxApplication

Uses the hpcbench udptest tool to gather UDP measurements. Measurements require two ends, a server and a client RM.

http://hpcbench.sourceforge.net/

do_deploy()[source]
do_start()[source]
upload_start_command()[source]
valid_connection(guid)[source]

nepi.resources.linux.udptunnel module

class nepi.resources.linux.udptunnel.LinuxUdpTunnel(ec, guid)[source]

Bases: nepi.resources.linux.tunnel.LinuxTunnel

check_state_connection()[source]
establish_connection(endpoint, remote_endpoint, port)[source]
get_endpoints()[source]

Returns the list of RM that are endpoints to the tunnel

initiate_connection(endpoint, remote_endpoint)[source]
log_message(msg)[source]
terminate_connection(endpoint, remote_endpoint)[source]
verify_connection(endpoint, remote_endpoint)[source]

Module contents