]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Pass hostname to execute()
authorZack Cerza <zack@cerza.org>
Thu, 8 May 2014 21:24:57 +0000 (16:24 -0500)
committerZack Cerza <zack@cerza.org>
Sat, 10 May 2014 14:10:22 +0000 (09:10 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/orchestra/run.py

index 52d6eb975f881680d904891043dc9654e1b16300..c8ab2c6f96ed33f2df74db08876ba7e8bb624dd9 100644 (file)
@@ -60,7 +60,7 @@ def quote(args):
     return ' '.join(_quote(args))
 
 
-def execute(client, args):
+def execute(client, args, name=None):
     """
     Execute a command remotely.
 
@@ -68,6 +68,7 @@ def execute(client, args):
 
     :param client: SSHConnection to run the command with
     :param args: command to run
+    :param name: name of client (optional)
     :type args: string or list of strings
 
     Returns a RemoteProcess, where exitstatus is a callable that will
@@ -77,8 +78,13 @@ def execute(client, args):
         cmd = args
     else:
         cmd = quote(args)
-    (host, port) = client.get_transport().getpeername()
-    log.debug('Running [{h}]: {cmd!r}'.format(h=host, cmd=cmd))
+
+    if name:
+        host = name
+    else:
+        (host, port) = client.get_transport().getpeername()
+    log.info('Running [{h}]: {cmd!r}'.format(h=host, cmd=cmd))
+
     (in_, out, err) = client.exec_command(cmd)
 
     def get_exitstatus():
@@ -274,7 +280,12 @@ def run(
     :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)
+    (host, port) = client.get_transport().getpeername()
+
+    if name is None:
+        name = host
+
+    r = execute(client, args, name=name)
 
     r.stdin = KludgeFile(wrapped=r.stdin)
 
@@ -287,10 +298,6 @@ 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: