Executes a local command, returns ((stdout,stderr),process)
Check the pidfile of a process spawned with remote_spawn.
Returns:
A (pid, ppid) tuple useful for calling remote_status and remote_kill, or None if the pidfile isn’t valid yet (maybe the process is still starting).
Kill a process spawned with lspawn.
First tries a SIGTERM, and if the process does not end in 10 seconds, it sends a SIGKILL.
pid/ppid: pid and parent-pid of the spawned process. See remote_check_pid
sudo: whether the command was run with sudo - careful killing like this.
Returns:
Nothing, should have killed the process
Spawn a local command such that it will continue working asynchronously.
command: the command to run - it should be a single line.
pidfile: path of a (ideally unique to this task) pidfile for tracking the process.
stdin: path of a file with input to be piped into the command’s standard input
home: path of a folder to use as working directory - should exist, unless you specify create_home
create_home: if True, the home folder will be created first with mkdir -p
sudo: whether the command needs to be executed as root
(stdout, stderr), process
Of the spawning process, which only captures errors at spawning time. Usually only useful for diagnostics.
Bases: object
API to query different data platforms as SFA, TopHat, OML Central Server, using Manifold Framework, the backend of MySlice.
Add resource to user’s slice. The query needs to specify the new resource plus the previous resources already in the slice.
Create and execute the Manifold API Query to get the resources according fields and filters. :param filters: resource’s constraints for the experiment :type filters: dict :param fields: desire fields in the result of the query :type fields: list
Retrieves the resources urn of the resources matching filters.
Bases: object
API Factory to manage a map of MANIFOLDAPI instances as key-value pairs, it instanciate a single instance per key. The key represents the same SFA, MF (ManiFold) credentials.
Bases: object
NetGraph represents a network topology. Network graphs are internally using the networkx library.
Assign IP addresses to each end of each edge of the network graph, computing all the point to point subnets and addresses in the network representation.
param network: Base network address used for subnetting. type network: str param prefix: Prefix for the base network address used for subnetting. type prefixt: int param version: IP version (either 4 or 6). type version: int
Look for the connected boxes with the required tags, doing breath-first search, until max_depth ( max_depth = None will traverse the entire graph ).
returns True if box has required tags
Bases: object
API for quering the SFA service. It uses Sfi class from the tool sfi client.
Get the list of resources’ urn, build the rspec string and call the allocate and provision method.
Method to add all resources together to the slice. Previous deletion of slivers. Specially used for wilabt that doesn’t allow to add more resources to the slice after some resources are added. Every sliver have to be deleted and the batch has to be added at once.
Adding resource_hrn to blacklist, and taking the resource from the reserved list.
Remove hosts from the reserved and blacklist lists, and in case the persist attribute is set, it saves the blacklisted hosts in the blacklist file.
De-allocate and de-provision all slivers of the named slice. Currently sfi doesn’t support removing particular slivers, so this method works only for removing every sliver. Setting the resource_hrn parameter is not necessary.
Bases: object
API Factory to manage a map of SFAAPI instances as key-value pairs, it instanciate a single instance per key. The key represents the same SFA, credentials.
Bases: object
Class to process SFA RSpecs, parse the RSpec replies such as Advertisement RSpecs, and build in the case of Request RSpecs.
Build the XML RSpec from list of resources’ urns. eg. resources = [“urn:publicid:IDN+ple:modenaple+node+planetlab-1.ing.unimo.it“]
Codes for status of remote spawned process
Special value that when given to rspawn in stderr causes stderr to redirect to whatever stdout was redirected to.
Returns a reference to a temporary known_hosts file, to which the server key has been added.
Make sure to hold onto the temp file reference until the process is done with it
Parameters: |
---|
The ssh_config options ControlMaster and ControlPersist allow to reuse a same network connection for multiple ssh sessions. In this way limitations on number of open ssh connections can be bypassed. However, older versions of openSSH do not support this feature. This function is used to determine if ssh connection persist features can be used.
Copies from/to remote sites.
Source and destination should have the user and host encoded as per scp specs.
Source can be a list of files to copy to a single destination, (in which case it is advised that the destination be a folder), or a single file in a string.
Executes a remote command, returns ((stdout,stderr),process)
Returns the pid and ppid of a process from a remote file where the information was stored.
param home: Path to directory where the pidfile is located type home: str param pidfile: Name of file containing the pid information type pidfile: str rtype: int A (pid, ppid) tuple useful for calling rstatus and rkill, or None if the pidfile isn’t valid yet (can happen when process is staring up)
Sends a kill signal to a remote process.
First tries a SIGTERM, and if the process does not end in 10 seconds, it sends a SIGKILL.
param pid: Process id of process to be killed type pid: int param ppid: Parent process id of process to be killed type ppid: int param sudo: Flag indicating if sudo should be used to kill the process type sudo: bool
Spawn a remote command such that it will continue working asynchronously in background.
param command: The command to run, it should be a single line. type command: str param pidfile: Path to a file where to store the pid and ppid of the spawned process type pidfile: str param stdout: Path to file to redirect standard output. The default value is /dev/null type stdout: str param stderr: Path to file to redirect standard error. If the special STDOUT value is used, stderr will be redirected to the same file as stdout type stderr: str param stdin: Path to a file with input to be piped into the command’s standard input type stdin: str param home: Path to working directory folder. It is assumed to exist unless the create_home flag is set. type home: str param create_home: Flag to force creation of the home folder before running the command type create_home: bool param sudo: Flag forcing execution with sudo user type sudo: bool rtype: tuple (stdout, stderr), process
Of the spawning process, which only captures errors at spawning time. Usually only useful for diagnostics.
Constructs a datetime object from a string date. The string date can be expressed as an absolute date ( i.e. format YYYYMMddHHMMSSffff ) or as a relative time ( e.g. format ‘5m’ or ‘10s’). If the date is a relative time and the dbase parameter is given (dbase must be datetime object), the returned date will be dbase + sdate. If dbase is None, current time will be used instead as base time.
:param date : string date :type date : date
Constructs a datetime object from a string date with format YYYYMMddHHMMSSffff
Returns difference ( date1 - date2 ) as a datetime object, where date1 and date 2 are datetime objects