Skip to content

Commit d39a71c

Browse files
author
Pan
committed
Refactoring - moved clients to pssh.clients. Added paramiko and import deprecation warnings. Updated readme, docs for new modules.
1 parent 2690b1a commit d39a71c

19 files changed

+2022
-1922
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ The new client is based on ``libssh2`` via the ``ssh2-python`` extension library
7777

7878
See `this post <https://parallel-ssh.org/post/parallel-ssh-libssh2>`_ for a performance comparison of the available clients.
7979

80-
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.pssh2_client`` instead. Their respective APIs are almost identical.
80+
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.clients.native`` instead. Their respective APIs are almost identical.
8181

82-
The new client will become the default and will replace the current ``pssh.pssh_client`` in a new major version of the library - ``2.0.0`` - once remaining features have been implemented.
82+
The new client will become the default and will replace the current ``pssh.pssh_client`` in a new major version of the library - ``2.0.0``.
8383

84-
The current default client will remain available as an option under a new name.
84+
The paramiko based client will remain available under ``pssh.clients.miko``.
8585

8686
For example:
8787

8888
.. code-block:: python
8989
9090
from pprint import pprint
91-
from pssh.pssh2_client import ParallelSSHClient
91+
from pssh.clients.native import ParallelSSHClient
9292
9393
hosts = ['myhost1', 'myhost2']
9494
client = ParallelSSHClient(hosts)
@@ -187,7 +187,7 @@ To copy a local file to remote hosts in parallel:
187187

188188
.. code-block:: python
189189
190-
from pssh.pssh_client import ParallelSSHClient
190+
from pssh.clients import ParallelSSHClient
191191
from pssh.utils import enable_logger, logger
192192
from gevent import joinall
193193

doc/advanced.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A private key can also be provided programmatically.
2727
.. code-block:: python
2828
2929
from pssh.utils import load_private_key
30-
from pssh import ParallelSSHClient
30+
from pssh.pssh_client import ParallelSSHClient
3131
3232
client = ParallelSSHClient(hosts, pkey=load_private_key('my_key'))
3333
@@ -60,13 +60,15 @@ Use of an available SSH agent can also be disabled.
6060
Programmatic SSH Agent
6161
-----------------------
6262

63+
*Paramiko client only*.
64+
6365
It is also possible to programmatically provide an SSH agent for the client to use, instead of a system provided one. This is useful in cases where hosts need different private keys and a system SSH agent is not available.
6466

6567
.. code-block:: python
6668
6769
from pssh.agent import SSHAgent
6870
from pssh.utils import load_private_key
69-
from pssh import ParallelSSHClient
71+
from pssh.clients.miko import ParallelSSHClient
7072
7173
agent = SSHAgent()
7274
agent.add_key(load_private_key('my_private_key_filename'))
@@ -94,11 +96,11 @@ The new client is based on ``libssh2`` via the ``ssh2-python`` extension library
9496

9597
See `this post <https://parallel-ssh.org/post/parallel-ssh-libssh2>`_ for a performance comparison of the available clients.
9698

97-
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.pssh2_client`` instead. Their respective APIs are almost identical.
99+
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.clients.native`` instead. Their respective APIs are almost identical.
98100

99101
.. code-block:: python
100102
101-
from pssh.pssh2_client import ParallelSSHClient
103+
from pssh.clients.native import ParallelSSHClient
102104
103105
hosts = ['my_host', 'my_other_host']
104106
client = ParallelSSHClient(hosts)
@@ -316,7 +318,7 @@ Run with sudo
316318
output = client.run_command(<..>, sudo=True)
317319
client.join(output)
318320
319-
While not best practice and password-less `sudo` is best configured for a limited set of commands, a sudo password may be provided via the stdin channel:
321+
While not best practice and password-less ``sudo`` is best configured for a limited set of commands, a sudo password may be provided via the stdin channel:
320322

321323
.. code-block:: python
322324
@@ -350,8 +352,6 @@ Contents of ``stdout`` will be `UTF-16` encoded.
350352
Disabling use of pseudo terminal emulation
351353
--------------------------------------------
352354

353-
By default, ``parallel-ssh`` uses the user's configured shell to run commands with. As a shell is used by default, a pseudo terminal (`PTY`) is also requested by default.
354-
355355
For cases where use of a `PTY` is not wanted, such as having separate stdout and stderr outputs, the remote command is a daemon that needs to fork and detach itself or when use of a shell is explicitly disabled, use of PTY can also be disabled.
356356

357357
The following example prints to stderr with PTY disabled.
@@ -374,7 +374,7 @@ The following example prints to stderr with PTY disabled.
374374
Combined stdout/stderr
375375
-----------------------
376376

377-
With a PTY, stdout and stderr output is combined.
377+
With a PTY on the paramiko client, stdout and stderr output is combined.
378378

379379
The same example as above with a PTY:
380380

@@ -470,14 +470,14 @@ If wanting to copy a file from a single remote host and retain the original file
470470

471471
.. code-block:: python
472472
473-
from pssh.ssh_client import SSHClient
473+
from pssh.pssh_client import SSHClient
474474
475475
client = SSHClient('localhost')
476476
client.copy_remote_file('remote_filename', 'local_filename')
477477
478478
.. seealso::
479479

480-
:py:func:`SSHClient.copy_remote_file <pssh.ssh_client.SSHClient.copy_remote_file>` API documentation and exceptions raised.
480+
:py:func:`SSHClient.copy_remote_file <pssh.clients.native.SSHClient.copy_remote_file>` API documentation and exceptions raised.
481481

482482

483483
Hosts filtering and overriding

doc/quickstart.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ First, make sure that ``parallel-ssh`` is `installed <installation.html>`_.
1212

1313
If you are seeing messages like ``This operation would block forever``, this is the cause.
1414

15-
Monkey patching is only done for the clients under ``pssh.pssh_client`` and ``pssh.ssh_client`` for parallel and single host clients respectively.
15+
Monkey patching is only done for the clients under ``pssh.clients.miko``.
1616

17-
New native library based clients under ``pssh.pssh2_client`` and ``pssh.ssh2_client`` **do not perform monkey patching** and are an option if monkey patching is not suitable. These clients will become the default in a future major release - ``2.0.0``.
17+
New native library based clients under ``pssh.clients.native`` **do not perform monkey patching** and are an option if monkey patching is not suitable. These clients will become the default, replacing the current ``pssh.pssh_client``, in a future major release - ``2.0.0``.
1818

1919
Run a command on hosts in parallel
2020
------------------------------------
@@ -138,19 +138,19 @@ For the native client (``pssh.pssh2_client``), only private key filepath is need
138138

139139
.. code-block:: python
140140
141-
from pssh.pssh2_client import ParallelSSHClient
141+
from pssh.clients.native import ParallelSSHClient
142142
143143
client = ParallelSSHClient(hosts, pkey='my_pkey')
144144
145145
Paramiko Client
146146
__________________
147147

148-
For the paramiko based client, the helper function :py:func:`load_private_key <pssh.utils.load_private_key>` is provided to easily load all possible key types. It takes either a file path or a file-like object.
148+
For the paramiko based client only, the helper function :py:func:`load_private_key <pssh.utils.load_private_key>` is provided to easily load all possible key types. It takes either a file path or a file-like object.
149149

150150
:File path:
151151
.. code-block:: python
152152
153-
from pssh.pssh_client import ParallelSSHClient
153+
from pssh.clients.miko import ParallelSSHClient
154154
from pssh.utils import load_private_key
155155
156156
pkey = load_private_key('my_pkey.pem')

pssh/clients/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# flake8: noqa: F401
2+
3+
from .native.parallel import ParallelSSHClient
4+
from .native.single import SSHClient

pssh/base_pssh.py renamed to pssh/clients/base_pssh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import gevent.pool
2525
from gevent.hub import Hub
2626

27-
from .exceptions import HostArgumentException
28-
from .constants import DEFAULT_RETRIES, RETRY_DELAY
29-
from .output import HostOutput
27+
from ..exceptions import HostArgumentException
28+
from ..constants import DEFAULT_RETRIES, RETRY_DELAY
29+
from ..output import HostOutput
3030

3131

3232
Hub.NOT_ERROR = (Exception,)

pssh/clients/miko/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# flake8: noqa: F401
2+
3+
from .parallel import ParallelSSHClient
4+
from .single import SSHClient, logger

0 commit comments

Comments
 (0)