Commit Graph

76 Commits

Author SHA1 Message Date
Zack Cerza
7035c17ec9 Add RemoteProcess.__repr__()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-30 16:36:03 -05:00
Zack Cerza
b386f5e5df Refactor teuthology.orchestra.run
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>
2014-05-30 16:05:23 -05:00
Zack Cerza
010f83f19b Fix unit tests under Jenkins
os.getlogin() was throwing:
  OSError: [Errno 25] Inappropriate ioctl for device

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-13 13:09:04 -05:00
Zack Cerza
d945e56405 Add retries to orchestra.connection.connect()
This is an attempt to fix: http://tracker.ceph.com/issues/8314

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-12 16:09:30 -05:00
Zack Cerza
e0e012659f Fix name parsing
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-12 12:57:21 -05:00
Zack Cerza
22b51be46c Use 'stderr' and 'stdout' as logger names
We were using just 'err' and 'out', which isn't very intuitive.

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:23 -05:00
Zack Cerza
470f824c6b Catch any Unicode errors that manage to sneak in
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:23 -05:00
Zack Cerza
60bba80e41 Express hostnames as child logger names
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
a58174d752 Use Remote.user
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
3e65d18261 Add Remote.user attribute
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
3352b58d30 Use Remote.shortname in logs
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
30d1d518d5 Make Remote.shortname actually short
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
36fe6a5830 Remote.hostname doesn't have to be a property
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
b2648b21af Fix PEP-8 issues
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
8567352360 Pass hostname to execute()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
429553053f Use 'true' instead of 'echo online'
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
d0f7a47bf9 Add Remote.ensure_online()
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>
2014-05-10 09:10:22 -05:00
Zack Cerza
3adb7d4629 Use Remote.hostname in logs
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-10 09:10:22 -05:00
Zack Cerza
085c508fd4 Revert "Revert "Show hostname instead of IP in errors""
This reverts commit 10fee0e368.

Conflicts:
	teuthology/orchestra/run.py
2014-05-10 09:10:21 -05:00
Zack Cerza
8460c7a8d9 Force log lines to be interpreted as UTF-8
Any invalid UTF-8 byte will be replaced with a Unicode replacement
character: U+FFFD or '�'

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-09 10:45:01 -05:00
Zack Cerza
cd7f268d9d Use binary flag for paramiko ChannelFiles
This works around http://tracker.ceph.com/issues/8313

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-09 09:24:22 -05:00
Zack Cerza
a1838b2a0f Rewrite most file-retrieval functions
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-06 14:59:52 -05:00
Zack Cerza
01cf3671b4 Fix linter errors
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-05-06 14:59:52 -05:00
Warren Usui
8bed6ab625 FIx mktemp dir and redundant Paramiko connecting.
Use previously initialized connection for sftp_get calls.
Use local directory for tarball temp file location.
2014-05-06 14:59:52 -05:00
Warren Usui
36b07b8aee Use SFTPClienti get for long reads/writes
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>
2014-05-06 14:59:52 -05:00
Zack Cerza
091d1fe48d Revert "Revert "Clean up remote.py and misc.py changes.""
This reverts commit 02504c3fd2.
2014-05-06 14:59:52 -05:00
Zack Cerza
0268487057 Revert "Revert "Handle raw data I/O.""
This reverts commit 0c8a3e2334.
2014-05-06 14:59:51 -05:00
Zack Cerza
0c8a3e2334 Revert "Handle raw data I/O."
This reverts commit 257e1459fa.
2014-05-05 10:03:29 -05:00
Zack Cerza
02504c3fd2 Revert "Clean up remote.py and misc.py changes."
This reverts commit 74eff43ee1.
2014-05-05 10:03:18 -05:00
Warren Usui
74eff43ee1 Clean up remote.py and misc.py changes.
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.
2014-04-29 16:14:11 -05:00
Warren Usui
257e1459fa Handle raw data I/O.
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>
2014-04-29 16:14:11 -05:00
Zack Cerza
5de353e73f Update unit test for Cluster.__repr__()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-04-25 15:01:41 -05:00
Zack Cerza
e6e287446a Fix Cluster.__repr__()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-04-25 11:36:43 -05:00
Zack Cerza
b4205caedf Iterate more sensibly over processes
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-03-08 07:58:13 -06:00
Zack Cerza
7604a1b670 Update safe_while users to reflect new defaults
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-03-07 13:36:35 -06:00
Zack Cerza
081a5c4bf9 Look for ready() in the right place
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-03-07 13:03:58 -06:00
Zack Cerza
0be5f1f015 Introduce a timeout to radosbench's join phase
Set to 15min right now.

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-03-07 11:21:31 -06:00
Zack Cerza
5411613599 Add debug output for reconnect() failures
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-21 10:18:41 -06:00
Zack Cerza
aecd98d763 Fix incorrect exception name in docstring
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:09 -06:00
Zack Cerza
1a0be5a0ab Tweaks to is_online and reconnect()
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:07 -06:00
Zack Cerza
297096b560 Add Remote.reconnect()
Also rename Remote._connect() to Remote.connect() and change its
semantics to match Remote.reconnect()

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:07 -06:00
Zack Cerza
8dfac4381c Make Remote.is_online more accurate
To really know if the connection is active, we need to read something
from the remote host.

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:07 -06:00
Zack Cerza
71b4bfe226 Remote instances can now establish SSH connections
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>
2014-02-20 17:46:07 -06:00
Zack Cerza
1c71558e53 Add Remote.is_online property
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:07 -06:00
Zack Cerza
a2a5aed49f Add Remote.hostname property
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:07 -06:00
Zack Cerza
ed512568f0 Fix linter errors.
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2014-02-20 17:46:05 -06:00
Warren Usui
f3ac7870ea Fix syntax error in first docstring added. 2014-02-19 13:37:06 -08:00
Warren Usui
e0ed09cfa9 Add docstrings to the orchestra code. Also fix minor formatting issues
(mostly column start locations).

Fixes: 7003
Signed-off-by: Warren Usui <warren.usui@inktank.com>
2014-02-14 12:57:54 -08:00
John Spray
b80e510257 Make libvirt import optional (OS X) 2014-01-31 20:53:45 +00:00
John Spray
f3ce07c65f Respect .ssh/config when opening SSH connections
This handles that case where your private key is
in a non-default location that you're pointing
to in ~/.ssh/config.
2013-12-11 13:41:36 -08:00