[Erp5-report] r35029 rafael - /erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 5 23:48:39 CEST 2010
Author: rafael
Date: Wed May 5 23:48:37 2010
New Revision: 35029
URL: http://svn.erp5.org?rev=35029&view=rev
Log:
Small ajustment to this implementation supports DSS and RSA keys. Print output of run script to stdout.
Modified:
erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py
Modified: erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py?rev=35029&r1=35028&r2=35029&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/ssh.py [utf8] Wed May 5 23:48:37 2010
@@ -12,6 +12,7 @@
self.username = username
self.host = host
self.port = port
+ self.password = ''
self.transport = None
self.sftp = None
if os.path.exists(key_path):
@@ -23,10 +24,14 @@
""" Connect and instantiate transport and sftp.
"""
self.transport = paramiko.Transport((self.host, int(self.port)))
- rsa_key = paramiko.RSAKey.from_private_key_file(self.key_path)
+ try:
+ key = paramiko.RSAKey.from_private_key_file(self.key_path)
+ except SSHException, e:
+ key = paramiko.DSSKey.from_private_key_file(self.key_path)
+
try:
self.transport.connect(username=self.username,
- pkey=rsa_key)
+ pkey=key)
except SSHException, e:
self.transport.close()
raise SSHException(str(e))
@@ -90,12 +95,14 @@
handler.put(remote_path, local_path)
return True
-def run(username, host, port, key_path, command):
+def run(username, host, port, key_path, command, use_stdout=1):
""" Connect into a remote instance and run a script
"""
handler = connection(username, host, port, key_path)
- handler.run(command)
- return True
+ output = handler.run(command)
+ if use_stdout:
+ print output
+ return output
def get(username, host, port, key_path, remote_path, local_path):
""" Get file by ssh
More information about the Erp5-report
mailing list