Skip to content

Commit 24b3266

Browse files
committed
Added documentation for added private key parameter. Updated documentation. Bump version number for new release
1 parent c301b66 commit 24b3266

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

pssh.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,17 @@ def __init__(self, host,
6262
:param user: (Optional) User to login as. Defaults to logged in user or \
6363
user from ~/.ssh/config if set
6464
:type user: str
65-
:raises: ssh_client.AuthenticationException on authentication error
66-
:raises: ssh_client.UnknownHostException on DNS resolution error
67-
:raises: ssh_client.ConnectionErrorException on error connecting"""
65+
:param password: (Optional) Password to use for login. Defaults to\
66+
no password
67+
:type password: str
68+
:param port: (Optional) Port number to use for SSH connection. Defaults\
69+
to None which uses SSH default
70+
:type port: int
71+
:param pkey: (Optional) Client's private key to be used to connect with
72+
:type pkey: :mod:`paramiko.PKey`
73+
:raises: AuthenticationException on authentication error
74+
:raises: UnknownHostException on DNS resolution error
75+
:raises: ConnectionErrorException on error connecting"""
6876
ssh_config = paramiko.SSHConfig()
6977
_ssh_config_file = os.path.sep.join([os.path.expanduser('~'),
7078
'.ssh',
@@ -224,23 +232,36 @@ def __init__(self, hosts,
224232
:param port: (Optional) Port number to use for SSH connection. Defaults\
225233
to None which uses SSH default
226234
:type port: int
235+
:param pkey: (Optional) Client's private key to be used to connect with
236+
:type pkey: :mod:`paramiko.PKey`
227237
:param pool_size: (Optional) Greenlet pool size. Controls on how many\
228238
hosts to execute tasks in parallel. Defaults to 10
229239
:type pool_size: int
230-
:raises: paramiko.AuthenticationException on authentication error
231-
:raises: ssh_client.UnknownHostException on DNS resolution error
232-
:raises: ssh_client.ConnectionErrorException on error connecting
240+
:raises: AuthenticationException on authentication error
241+
:raises: UnknownHostException on DNS resolution error
242+
:raises: ConnectionErrorException on error connecting
233243
234244
**Example**
235245
236-
>>> client = ParallelSSHClient(['myhost1', 'myhost2'])
246+
>>> from pssh import ParallelSSHClient, AuthenticationException,\
247+
UnknownHostException, ConnectionErrorException
248+
>>> try:
249+
>>> ... client = ParallelSSHClient(['myhost1', 'myhost2'])
250+
>>> except (AuthenticationException, UnknownHostException, ConnectionErrorException):
251+
>>> ... return
237252
>>> cmds = client.exec_command('ls -ltrh /tmp/aasdfasdf', sudo = True)
238253
>>> output = [client.get_stdout(cmd) for cmd in cmds]
239254
[myhost1] ls: cannot access /tmp/aasdfasdf: No such file or directory
240255
[myhost2] ls: cannot access /tmp/aasdfasdf: No such file or directory
241256
>>> print output
242257
[{'myhost1': {'exit_code': 2}}, {'myhost2': {'exit_code': 2}}]
243258
259+
**Example with specified private key**
260+
261+
>>> import paramiko
262+
>>> client_key = paramiko.RSAKey.from_private_key_file('user.key')
263+
>>> client = ParallelSSHClient(['myhost1', 'myhost2'], pkey=client_key)
264+
244265
.. note ::
245266
246267
**Connection persistence**

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import find_packages
33

44
setup(name='parallel-ssh',
5-
version='0.3',
5+
version='0.4',
66
description='Wrapper library over paramiko to allow remote execution of tasks. Supports parallel execution on multiple hosts',
77
author='Panos Kittenis',
88
author_email='pkittenis@gmail.com',

0 commit comments

Comments
 (0)