You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/05/10 03:28:33 UTC
svn commit: r1101285 - in /incubator/libcloud/trunk/libcloud/compute:
base.py ssh.py
Author: tomaz
Date: Tue May 10 01:28:33 2011
New Revision: 1101285
URL: http://svn.apache.org/viewvc?rev=1101285&view=rev
Log:
Allow user to specify ssh client timeout for the deploy_node step.
Modified:
incubator/libcloud/trunk/libcloud/compute/base.py
incubator/libcloud/trunk/libcloud/compute/ssh.py
Modified: incubator/libcloud/trunk/libcloud/compute/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/compute/base.py?rev=1101285&r1=1101284&r2=1101285&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/compute/base.py (original)
+++ incubator/libcloud/trunk/libcloud/compute/base.py Tue May 10 01:28:33 2011
@@ -471,6 +471,10 @@ class NodeDriver(object):
@keyword ssh_port: Optional SSH server port (default is 22)
@type ssh_port: C{int}
+ @keyword ssh_timeout: Optional SSH connection timeout in seconds
+ (default is None)
+ @type ssh_timeout: C{float}
+
See L{NodeDriver.create_node} for more keyword args.
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
@@ -540,7 +544,8 @@ class NodeDriver(object):
client = SSHClient(hostname=node.public_ip[0],
port=ssh_port, username=ssh_username,
- password=password)
+ password=password,
+ timeout=kwargs.get('ssh_timeout', None))
laste = None
while time.time() < end:
laste = None
Modified: incubator/libcloud/trunk/libcloud/compute/ssh.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/compute/ssh.py?rev=1101285&r1=1101284&r2=1101285&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/compute/ssh.py (original)
+++ incubator/libcloud/trunk/libcloud/compute/ssh.py Tue May 10 01:28:33 2011
@@ -35,7 +35,8 @@ class BaseSSHClient(object):
Base class representing a connection over SSH/SCP to a remote node.
"""
- def __init__(self, hostname, port=22, username='root', password=None, key=None):
+ def __init__(self, hostname, port=22, username='root', password=None,
+ key=None, timeout=None):
"""
@type hostname: C{str}
@keyword hostname: Hostname or IP address to connect to.
@@ -57,6 +58,7 @@ class BaseSSHClient(object):
self.username = username
self.password = password
self.key = key
+ self.timeout = timeout
def connect(self):
"""
@@ -99,7 +101,7 @@ class BaseSSHClient(object):
@type cmd: C{str}
@keyword cmd: Command to run.
-
+
@return C{list} of [stdout, stderr, exit_status]
"""
raise NotImplementedError, \
@@ -116,7 +118,8 @@ class ParamikoSSHClient(BaseSSHClient):
"""
A SSH Client powered by Paramiko.
"""
- def __init__(self, hostname, port=22, username='root', password=None, key=None):
+ def __init__(self, hostname, port=22, username='root', password=None,
+ key=None, timeout=None):
super(ParamikoSSHClient, self).__init__(hostname, port, username, password, key)
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@@ -128,6 +131,10 @@ class ParamikoSSHClient(BaseSSHClient):
'password': self.password,
'allow_agent': False,
'look_for_keys': False}
+
+ if self.timeout:
+ conninfo['timeout'] = self.timeout
+
self.client.connect(**conninfo)
return True