RemoteProcess behaves more like subprocess.Popen, with some important
differences.
A summary of the API changes:
* RemoteProcess.exitstatus is either an int or None; it is never a callable
nor a gevent.AsyncResult.
* New method: RemoteProcess.execute()
* New method: RemoteProcess.poll()
* New method: RemoteProcess.wait()
* New attribute: RemoteProcess.returncode - alias to exitstatus
* New property: RemoteProcess.finished - added because returncode can be None
if the connection was interrupted
* run.execute() is removed.
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
If the connection is alive, do nothing. If not, reconnect. Allow any
exceptions to bubble up to the caller. This is intended to fix unhelpful
'Bad File Descriptor' errors we were seeing when VMs go down.
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
Modified remote.py to use the paramiko SFTPClient get
method to extract long files (mostly tar files) from
the remote host. The code formerly saved the data
in a long local string which was very inefficient.
Fixes: 8261
Signed-off-by: Warren Usui <warren.usui@inktank.com>
Fixed method names to be non-redundant (remote_mktemp in remote is
now just mktemp, for example), and made some parameters be more
self descriptive. Added some docstrings. Fixed sudo setting in
get_file method.
Made chmod independent of the actual sftp file getting.
Do not do extra file copy if non-sudo read is needed.
Fixed some parameter names. Made sure temp files are removed.
Paramiko 1.13.0 checks data in the Channel and fails if
invalid UTF-8 characters are sent. The teuthology/misc.py
functions that piped cat output (get_file) and piped tar
output (pull_directory and pull_directory_tarball) formerly
did not work for Paramiko 1.13.0.
Code was changed to use SFTPClient to copy raw data. The
remote_mktemp and function was changed to be a method of the
remote object. Remote object methods to copy files and write
tar files were also added.
In misc.py, get_file() was changed to be a wrapper around the
remote object call. Pull_directory() and pull_directory_tarball
were changed to use the remote object methods as well.
The remote methods used to send the data makes use of the
SFTPClient interface in Paramiko.
The remote_mktemp function was also modified slightly to insure
that new-lines do not appear in temp file names.
Fixes: 8116
Signed-off-by: Warren Usui <warren.usui@inktank.com>
Also rename Remote._connect() to Remote.connect() and change its
semantics to match Remote.reconnect()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
Previously, they required an active ssh connection object to be passed
to them. That behavior is still functional.
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>