Overtherepy is a Jython wrapper library around Overthere to manipulate files and execute processes on remote hosts, i.e. do stuff "over there".
Overtherepy is available under the GPLv2 with XebiaLabs FLOSS License Exception.
To get Overtherepy, you have two options:
- Add a dependency to your project.
- Build Overtherepy yourself.
Binary releases of Overtherepy can be downloaded straight from the Maven Central repository or from Github releases
-
If your project is built with Maven, add the following dependency to the pom.xml:
<dependency> <groupId>com.xebialabs.overthere</groupId> <artifactId>overtherepy</artifactId> <version>0.0.3</version> </dependency>
-
If your project is built using another build tool that uses the Maven Central repository, translate these dependencies into the format used by your build tool.
- Install Gradle 1.0 or up.
- Clone the Overthere repository.
- Define the jython interpreter executable in the
~/.gradle/gradle.properties
.- jythonInterpreter=$JYTHON_HOME/bin/jython
- Run the command
gradle clean build
.
To program Overtherepy, browse the source code and browse the Overtherepy PyDoc. Below gives you a basic usage example.
Depending on the target host, the following options are available :
- overtherepy.SshConnectionOptions
- overtherepy.CifsConnectionOptions
- overtherepy.LocalConnectionOptions
Please refer to the Overthere documentation for available options. Options are passed to the contructor as named parameters
from overtherepy import LocalConnectionOptions, OverthereHost, OverthereHostSession from com.xebialabs.overthere import OperatingSystemFamily from com.xebialabs.overthere.cifs import CifsConnectionType # Sample Local Connection Options localOpts = LocalConnectionOptions(os=OperatingSystemFamily.UNIX) # Sample SSH Connection options using custom port sshOpts = SshConnectionOptions("myhost","myusername", port=2222 ) # Sample CIFS Connection options using TELNET for connection type cifsOpts = CifsConnectionOptions("172.16.92.237", "Administrator", "secret", connectionType=CifsConnectionType.TELNET)
... host = OverthereHost(cifsOpts) session = OverthereHostSession(host) f = session.upload_classpath_resource_to_work_dir("testfiles/echo.sh", executable=True) response = session.execute([f.path, "ping"], check_success=False) if response.rc != 0: print "Failed to execute command" print response.stderr else: print "Response", str(response.stdout) session.close_conn()
The session supports the 'with' statement. You must first import the statement from the ___future___
package. The session's connection is automatically closed at the end of the 'with' body.
from __future__ import with_statement ... with session: # do stuff
Refer to Overtherepy PyDoc for a complete API reference. Below is a description of the main OverthereHostSession class.
class OverthereHostSession(__builtin__.object) | ||
Session with a target host | ||
Methods defined here:
|