MoleQueue 0.9.0
Loading...
Searching...
No Matches
SshConnection Class Reference

#include <molequeue/sshconnection.h>

Inheritance diagram for SshConnection:
SshCommand OpenSshCommand PuttyCommand

Public Slots

void setPersistent (bool persist)
void setUserName (const QString &newUserName)
void setHostName (const QString &newHostName)
void setIdentityFile (const QString &newIdentityFile)
void setPortNumber (int newPortNumber)
virtual bool execute (const QString &command)
virtual bool copyTo (const QString &localFile, const QString &remoteFile)
virtual bool copyFrom (const QString &remoteFile, const QString &localFile)
virtual bool copyDirTo (const QString &localDir, const QString &remoteDir)
virtual bool copyDirFrom (const QString &remoteDir, const QString &localDir)

Signals

void requestSent ()
void requestComplete ()

Public Member Functions

 SshConnection (QObject *parentObject=0)
bool isPersistent () const
QString userName () const
QString hostName () const
QString identityFile () const
int portNumber () const
virtual bool isValid () const
virtual QString output () const
virtual int exitCode () const
virtual bool waitForCompletion (int msecs=30000)
virtual bool isComplete () const
QVariant & data ()
const QVariant & data () const
void setData (const QVariant &newData)

Static Protected Member Functions

static bool debug ()

Protected Attributes

bool m_persistent
QVariant m_data
QString m_userName
QString m_hostName
QString m_identityFile
int m_portNumber

Detailed Description

Abstract base class defining remote execution and file transfer operations over the ssh protocol.

Author
Marcus D. Hanwell, David C. Lonie

The SshConnection is the interface to use when writing code that requires interactions with a remote host. Subclasses provide concrete implementations of the interface, e.g. SshCommand, which calls the ssh and scp commands in a TerminalProcess.

Member Function Documentation

◆ isPersistent()

bool isPersistent ( ) const
Returns
If the SSH connection is set as persistent or not.

◆ userName()

QString userName ( ) const
Returns
The user name that will be used.

◆ hostName()

QString hostName ( ) const
Returns
The host that will be used.

◆ identityFile()

QString identityFile ( ) const
Returns
The path to the identity file that will be used.

◆ portNumber()

int portNumber ( ) const
Returns
The port that will be used.

◆ isValid()

virtual bool isValid ( ) const
virtual
Returns
Whether the connection is valid, at a minimum need a host name.

◆ output()

virtual QString output ( ) const
virtual
Returns
The merged stdout and stderr of the remote command.

Reimplemented in SshCommand.

◆ exitCode()

virtual int exitCode ( ) const
virtual
Returns
The exit code returned from a remote command.

Reimplemented in SshCommand.

◆ waitForCompletion()

virtual bool waitForCompletion ( int msecs = 30000)
virtual

Wait until the request has been completed.

Parameters
msecsTimeout in milliseconds. Default is 30 seconds.
Returns
True if request finished, false on timeout.

Reimplemented in SshCommand.

◆ isComplete()

virtual bool isComplete ( ) const
virtual
Returns
True if the request has completed. False otherwise.

Reimplemented in SshCommand.

◆ data() [1/2]

QVariant & data ( )
Returns
A reference to arbitrary data stored in the command.

◆ data() [2/2]

const QVariant & data ( ) const
Returns
A reference to arbitrary data stored in the command.

◆ setData()

void setData ( const QVariant & newData)
Parameters
newDataArbitrary data to store in the command.

◆ setPersistent

void setPersistent ( bool persist)
slot

Set whether the connection should be persistent, or each issuesd command uses a short-lived connection, e.g. on the command line a non-persistent connection would be the equivalent of,

ssh user@host ls

◆ setUserName

void setUserName ( const QString & newUserName)
slot

Set the user name to use for the connection.

◆ setHostName

void setHostName ( const QString & newHostName)
slot

Set the host name to use for the connection.

◆ setIdentityFile

void setIdentityFile ( const QString & newIdentityFile)
slot

Set the identity file to use for the connection. This is the path to the private key to be used when establishing the connection.

◆ setPortNumber

void setPortNumber ( int newPortNumber)
slot

Set the host name to use for the connection.

◆ execute

virtual bool execute ( const QString & command)
virtualslot

Execute the supplied command on the remote host.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See also
requestSent() requestCompleted() waitForCompeletion()
Parameters
commandThe command to execute.
Returns
True on success, false on failure.

◆ copyTo

virtual bool copyTo ( const QString & localFile,
const QString & remoteFile )
virtualslot

Copy a local file to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localFileThe path of the local file.
remoteFileThe path of the file on the remote system.
Returns
True on success, false on failure.

◆ copyFrom

virtual bool copyFrom ( const QString & remoteFile,
const QString & localFile )
virtualslot

Copy a remote file to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteFileThe path of the file on the remote system.
localFileThe path of the local file.
Returns
True on success, false on failure.

◆ copyDirTo

virtual bool copyDirTo ( const QString & localDir,
const QString & remoteDir )
virtualslot

Copy a local directory recursively to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localDirThe path of the local directory.
remoteDirThe path of the directory on the remote system.
Returns
True on success, false on failure.

◆ copyDirFrom

virtual bool copyDirFrom ( const QString & remoteDir,
const QString & localDir )
virtualslot

Copy a remote directory recursively to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteDirThe path of the directory on the remote system.
localFileThe path of the local directory.
Returns
True on success, false on failure.

◆ requestSent

void requestSent ( )
signal

Emitted when the request has been sent to the server.

◆ requestComplete

void requestComplete ( )
signal

Emitted when the request has been sent and the reply (if any) received.


The documentation for this class was generated from the following file: