Skip to content

Commit 1bc4080

Browse files
author
Pan
committed
Updated ssh2 client sftp functions.
Updated travis, appveyor cfgs. Updated readme. Updated documentation. Updated sftp tests.
1 parent 7332242 commit 1bc4080

File tree

14 files changed

+371
-266
lines changed

14 files changed

+371
-266
lines changed

.appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ install:
7676
# about it being out of date.
7777
- "pip install --disable-pip-version-check --user --upgrade pip"
7878

79+
- git submodule update --init --recursive
80+
- "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat"
7981
# Install the build dependencies of the project. If some dependencies contain
8082
# compiled extensions and are not provided as pre-built wheel packages,
8183
# pip will build them from source using the MSVC compiler matching the
8284
# target Python version and architecture
8385
- "%CMD_IN_ENV% pip install -r requirements.txt"
8486
- "%CMD_IN_ENV% pip install -U wheel setuptools twine"
85-
- git submodule update --init --recursive
8687

8788
build_script:
88-
- "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat"
8989
# Build the compiled extension
9090
- "%CMD_IN_ENV% python setup.py build_ext -i"
9191

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
install:
2323
- pip install -r requirements_dev.txt
2424
script:
25-
- nosetests --with-coverage --cover-package=pssh tests/test_ssh2_client.py tests/test_pssh_ssh2_client.py
25+
- nosetests --with-coverage --cover-package=pssh
2626
- flake8 pssh
2727
- cd doc; make html; cd ..
2828
after_success:

Changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Change Log
77
Changes
88
---------
99

10-
* New ``ssh2-python`` (``libssh2``) based clients
10+
* New ``ssh2-python`` (``libssh2``) native library based clients
1111

1212
Fixes
1313
--------

README.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Native code based client with extremely high performance - based on ``libssh2``
1616
:alt: Latest Version
1717
.. image:: https://travis-ci.org/ParallelSSH/parallel-ssh.svg?branch=master
1818
:target: https://travis-ci.org/ParallelSSH/parallel-ssh
19-
.. image:: https://coveralls.io/repos/ParallelSSH/parallel-ssh/badge.png?branch=master
20-
:target: https://coveralls.io/r/ParallelSSH/parallel-ssh?branch=master
19+
.. image:: https://codecov.io/gh/ParallelSSH/parallel-ssh/branch/master/graph/badge.svg
20+
:target: https://codecov.io/gh/ParallelSSH/parallel-ssh
2121
.. image:: https://img.shields.io/pypi/wheel/parallel-ssh.svg
2222
:target: https://pypi.python.org/pypi/parallel-ssh
2323
.. image:: https://readthedocs.org/projects/parallel-ssh/badge/?version=latest
@@ -63,19 +63,21 @@ Run ``uname`` on two remote hosts in parallel with ``sudo``.
6363
Linux
6464
Linux
6565
66-
*******************
67-
Native code client
68-
*******************
66+
**************
67+
Native client
68+
**************
6969

70-
As of version ``1.2.0``, a new client is supported in ``ParallelSSH`` which offers much greater performance and reduced overhead than the current default client library. Binary wheel packages with ``libssh2`` included are provided for Linux, OSX and Windows platforms and all supported Python versions.
70+
Starting from version ``1.2.0``, a new client is supported in ``parallel-ssh`` which offers much greater performance and reduced overhead than the current default client.
7171

72-
The new client is based on ``libssh2`` via the ``ssh2-python`` extension library and supports non-blocking mode natively. In addition, SFTP push/pull operations in the new client have also been implemented in native code, allowing for much greater performance and significantly reduced overhead.
72+
The new client is based on ``libssh2`` via the ``ssh2-python`` extension library and supports non-blocking mode natively. Binary wheel packages with ``libssh2`` included are provided for Linux, OSX and Windows platforms and all supported Python versions.
7373

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

7676
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.pssh2_client`` instead. Their respective APIs are almost identical.
7777

78-
Note that the new client will become the default and will replace the current ``pssh.pssh_client`` in a new major version of the library - ``2.x.x`` - once remaining features have been implemented. The current client will remain available as an option under a new name.
78+
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. The native client should be considered as *beta* status until the ``2.0.0`` release when it is made the default.
79+
80+
The current default client will remain available as an option under a new name.
7981

8082
For example:
8183

@@ -101,9 +103,8 @@ Native Code Client Features
101103
****************************
102104

103105
* Highest performance and least overhead of any Python SSH libraries
104-
* Thread safe - utilises both native threads for blocking calls like authentication and non-blocking I/O
106+
* Thread safe - makes use of native threads for blocking calls like authentication
105107
* Natively non-blocking utilising ``libssh2`` via ``ssh2-python`` - **no monkey patching of the Python standard library**
106-
* Native binary-like SFTP speeds thanks to SFTP and local file read/write native code implementations
107108
* Significantly reduced overhead in CPU and memory usage
108109

109110

doc/Changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../Changelog.rst

doc/advanced.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ will disable this behaviour.
2020
Programmatic Private Keys
2121
--------------------------
2222

23-
By default, ``ParallelSSH`` will use all keys in an available SSH agent and identity keys under the user's SSH directory - ``id_rsa`` and ``id_dsa`` in ``~/.ssh``.
23+
By default, ``parallel-ssh`` will use all keys in an available SSH agent and identity keys under the user's SSH directory - ``id_rsa``, ``id_dsa`` and ``identity`` in ``~/.ssh``.
2424

2525
A private key can also be provided programmatically.
2626

@@ -55,7 +55,7 @@ Use of an available SSH agent can also be disabled.
5555

5656
If the number of hosts is large enough, available connections to the system SSH agent may be exhausted which will stop the client from working on a subset of hosts.
5757

58-
This is a limitation of the underlying SSH client used by ``ParallelSSH``.
58+
This is a limitation of the underlying SSH client used by ``parallel-ssh``.
5959

6060
Programmatic SSH Agent
6161
-----------------------
@@ -85,6 +85,32 @@ It is also possible to programmatically provide an SSH agent for the client to u
8585
:py:class:`pssh.agent.SSHAgent`
8686

8787

88+
Native clients
89+
*****************
90+
91+
Starting from version ``1.2.0``, a new client is supported in ``parallel-ssh`` which offers much greater performance and reduced overhead than the current default client.
92+
93+
The new client is based on ``libssh2`` via the ``ssh2-python`` extension library and supports non-blocking mode natively. Binary wheel packages with ``libssh2`` included are provided for Linux, OSX and Windows platforms and all supported Python versions.
94+
95+
See `this post <https://parallel-ssh.org/post/parallel-ssh-libssh2>`_ for a performance comparison of the available clients.
96+
97+
To make use of this new client, ``ParallelSSHClient`` can be imported from ``pssh.pssh2_client`` instead. Their respective APIs are almost identical.
98+
99+
.. code-block:: python
100+
101+
from pssh.pssh2_client import ParallelSSHClient
102+
103+
hosts = ['my_host', 'my_other_host']
104+
client = ParallelSSHClient(hosts)
105+
client.run_command(<..>)
106+
107+
108+
.. seealso::
109+
110+
`Feature comparison <ssh2.html>`_ for how the client features compare.
111+
112+
API documentation for `parallel <pssh2_client.html>`_ and `single <ssh2_client.html>`_ native clients.
113+
88114
Tunneling
89115
**********
90116

@@ -119,7 +145,7 @@ In the above example, connections to the target hosts are made via ``my_proxy_us
119145

120146
Proxy host connections are asynchronous and use the SSH protocol's native TCP tunneling - aka local port forward. No external commands or processes are used for the proxy connection, unlike the `ProxyCommand` directive in OpenSSH and other utilities.
121147

122-
While connections initiated by ``ParallelSSH`` are asynchronous, connections from proxy host -> target hosts may not be, depending on SSH server implementation. If only one proxy host is used to connect to a large number of target hosts and proxy SSH server connections are *not* asynchronous, this may adversely impact performance on the proxy host.
148+
While connections initiated by ``parallel-ssh`` are asynchronous, connections from proxy host -> target hosts may not be, depending on SSH server implementation. If only one proxy host is used to connect to a large number of target hosts and proxy SSH server connections are *not* asynchronous, this may adversely impact performance on the proxy host.
123149

124150
Per-Host Configuration
125151
***********************
@@ -205,7 +231,7 @@ See :py:func:`run_command API documentation <pssh.pssh_client.ParallelSSHClient.
205231
Run with sudo
206232
---------------
207233
208-
``ParallelSSH`` can be instructed to run its commands under ``sudo``:
234+
``parallel-ssh`` can be instructed to run its commands under ``sudo``:
209235
210236
.. code-block:: python
211237
@@ -248,7 +274,7 @@ Contents of ``stdout`` will be `UTF-16` encoded.
248274
Disabling use of pseudo terminal emulation
249275
--------------------------------------------
250276
251-
By default, ``ParallelSSH`` 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.
277+
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.
252278
253279
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.
254280
@@ -425,7 +451,7 @@ Hosts list can be modified in place. A call to ``run_command`` will create new c
425451
Additional options for underlying SSH libraries
426452
************************************************
427453
428-
Not all SSH library configuration options are used directly by ``Parallel-SSH``.
454+
Not all SSH library configuration options are used directly by ``parallel-ssh``.
429455
430456
Additional options can be passed on to the underlying SSH libraries used via an optional keyword argument.
431457

doc/index.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
.. Parallel-SSH documentation master file, created by
2-
sphinx-quickstart on Mon Mar 10 17:08:38 2014.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
5-
61
===========================
72
Parallel-SSH Documentation
83
===========================
@@ -15,16 +10,17 @@ Parallel-SSH Documentation
1510
:alt: Latest Version
1611
.. image:: https://travis-ci.org/ParallelSSH/parallel-ssh.svg?branch=master
1712
:target: https://travis-ci.org/ParallelSSH/parallel-ssh
18-
.. image:: https://coveralls.io/repos/ParallelSSH/parallel-ssh/badge.png?branch=master
19-
:target: https://coveralls.io/r/ParallelSSH/parallel-ssh?branch=master
13+
.. image:: https://codecov.io/gh/ParallelSSH/parallel-ssh/branch/master/graph/badge.svg
14+
:target: https://codecov.io/gh/ParallelSSH/parallel-ssh
15+
.. image:: https://img.shields.io/pypi/wheel/parallel-ssh.svg
16+
:target: https://pypi.python.org/pypi/parallel-ssh
2017
.. image:: https://readthedocs.org/projects/parallel-ssh/badge/?version=latest
2118
:target: http://parallel-ssh.readthedocs.org/en/latest/
2219
:alt: Latest documentation
2320

21+
``parallel-ssh`` is a non-blocking parallel SSH client library.
2422

25-
``parallel-ssh`` is a parallel SSH client library.
26-
27-
It uses asynchronous non-blocking SSH connections and is, to date, the only publicly available non-blocking SSH client library for Python, as well as the only non-blocking *parallel* SSH client library available for Python.
23+
It uses non-blocking asynchronous SSH sessions and is, to date, the only publicly available non-blocking SSH client library for Python, as well as the only non-blocking *parallel* SSH client library available for Python.
2824

2925
.. toctree::
3026
:maxdepth: 2
@@ -34,6 +30,7 @@ It uses asynchronous non-blocking SSH connections and is, to date, the only publ
3430
quickstart
3531
ssh2
3632
advanced
33+
Changelog
3734
api
3835

3936
In a nutshell

doc/installation.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ To install from source run:
4343

4444
.. code-block:: shell
4545
46-
pip install -r requirements.txt
4746
python setup.py install
4847
4948
Or with `pip`'s development mode which will ensure local changes are made available:

doc/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Design And Goals
33
*****************
44

5-
``Parallel-SSH``'s design goals and motivation are to provide a *library* for running *asynchronous* SSH commands in parallel with little to no load induced on the system by doing so with the intended usage being completely programmatic and non-interactive.
5+
``parallel-ssh``'s design goals and motivation are to provide a *library* for running *asynchronous* SSH commands in parallel with little to no load induced on the system by doing so with the intended usage being completely programmatic and non-interactive.
66

77
To meet these goals, API driven solutions are preferred first and foremost. This frees up the developer to drive the library via any method desired, be that environment variables, CI driven tasks, command line tools, existing OpenSSH or new configuration files, from within an application et al.
88

doc/quickstart.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
Quickstart
33
***********
44

5-
First, make sure that ``parallel-ssh`` is `installed <installation>`_.
5+
First, make sure that ``parallel-ssh`` is `installed <installation.html>`_.
66

77
.. note::
88

9-
ParallelSSH uses gevent's monkey patching to enable asynchronous use of the Python standard library's network I/O.
9+
``parallel-ssh`` uses gevent's monkey patching to enable asynchronous use of the Python standard library's network I/O.
1010

1111
Make sure that ParallelSSH imports come **before** any other imports in your code. Otherwise, patching may not be done before the standard library is loaded which will then cause ParallelSSH to block.
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.
16+
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 are currently in beta and will become the default in a future major release - ``2.0.0``.
18+
1519
Run a command on hosts in parallel
1620
------------------------------------
1721

@@ -207,4 +211,4 @@ With this flag, the ``exception`` attribute will contain the exception on any fa
207211
208212
.. seealso::
209213

210-
Possible exceptions can be found in :mod:`pssh.exceptions` module.
214+
Exceptions raised by the library can be found in :mod:`pssh.exceptions` module.

0 commit comments

Comments
 (0)