]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "Revert "Show hostname instead of IP in errors""
authorZack Cerza <zack@cerza.org>
Tue, 6 May 2014 21:17:34 +0000 (16:17 -0500)
committerZack Cerza <zack@cerza.org>
Sat, 10 May 2014 14:10:21 +0000 (09:10 -0500)
This reverts commit 10fee0e368750cf4cd953db5700df59c7f611119.

Conflicts:
teuthology/orchestra/run.py

teuthology/orchestra/remote.py
teuthology/orchestra/run.py
teuthology/orchestra/test/test_remote.py

index a80c3a31bc6166ea2704a5a9595d02eafbae6017..5cf1e35c94b98b07fc881420f3d041e038c53490 100644 (file)
@@ -106,7 +106,7 @@ class Remote(object):
 
         TODO refactor to move run.run here?
         """
-        r = self._runner(client=self.ssh, **kwargs)
+        r = self._runner(client=self.ssh, name=self.name, **kwargs)
         r.remote = self
         return r
 
index 9d72ed628da1ef5a981e4a27337aca30eb5f7bb6..52d6eb975f881680d904891043dc9654e1b16300 100644 (file)
@@ -251,12 +251,14 @@ class KludgeFile(object):
         self._wrapped.close()
         self._wrapped.channel.shutdown_write()
 
+
 def run(
     client, args,
     stdin=None, stdout=None, stderr=None,
     logger=None,
     check_status=True,
     wait=True,
+    name=None
     ):
     """
     Run a command remotely.
@@ -270,6 +272,7 @@ def run(
     :param logger: If logging, write stdout/stderr to "out" and "err" children of this logger. Defaults to logger named after this module.
     :param check_status: Whether to raise CommandFailedError on non-zero exit status, and . Defaults to True. All signals and connection loss are made to look like SIGHUP.
     :param wait: Whether to wait for process to exit. If False, returned ``r.exitstatus`` s a `gevent.event.AsyncResult`, and the actual status is available via ``.get()``.
+    :param name: Human readable name (probably hostname) of the destination host
     """
     r = execute(client, args)
 
@@ -285,11 +288,15 @@ def run(
     if logger is None:
         logger = log
     (host, port) = client.get_transport().getpeername()
+
+    if name is None:
+        name = host
+
     g_err = None
     if stderr is not PIPE:
         if stderr is None:
             stderr = logger.getChild('err')
-        g_err = gevent.spawn(copy_file_to, r.stderr, stderr, host)
+        g_err = gevent.spawn(copy_file_to, r.stderr, stderr, name)
         r.stderr = stderr
     else:
         assert not wait, "Using PIPE for stderr without wait=False would deadlock."
@@ -298,7 +305,7 @@ def run(
     if stdout is not PIPE:
         if stdout is None:
             stdout = logger.getChild('out')
-        g_out = gevent.spawn(copy_file_to, r.stdout, stdout, host)
+        g_out = gevent.spawn(copy_file_to, r.stdout, stdout, name)
         r.stdout = stdout
     else:
         assert not wait, "Using PIPE for stdout without wait=False would deadlock."
@@ -329,8 +336,7 @@ def run(
                 # signal; sadly SSH does not tell us which signal
                 raise CommandCrashedError(command=r.command)
             if status != 0:
-                (host, port) = client.get_transport().getpeername()
-                raise CommandFailedError(command=r.command, exitstatus=status, node=host)
+                raise CommandFailedError(command=r.command, exitstatus=status, node=name)
         return status
 
     if wait:
index dbff6ffc42f9c62f98ae500510477c44f27b0fc6..13e3c31043907ca9179ac3a8282bac7c054011c3 100644 (file)
@@ -45,6 +45,7 @@ class TestRemote(object):
             client=fudge.inspector.arg.passes_test(lambda v: v is ssh),
             args=fudge.inspector.arg.passes_test(lambda v: v is args),
             foo=fudge.inspector.arg.passes_test(lambda v: v is foo),
+            name='jdoe@xyzzy.example.com'
             ).returns(ret)
         r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=ssh)
         # monkey patch ook ook