]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
nicer API to do remote check_calls
authorAlfredo Deza <alfredo@deza.pe>
Mon, 29 Jul 2013 19:30:57 +0000 (15:30 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Mon, 29 Jul 2013 19:30:57 +0000 (15:30 -0400)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
ceph_deploy/util/wrappers.py

index ede9163d528ea66747917cb1cf2421c09db6d468..5ef36dae50d3c169e1b0742f84ca4b99e670f180 100644 (file)
@@ -9,7 +9,13 @@ from ceph_deploy.util.decorators import remote_compile
 from ceph_deploy.util import context
 
 
-def check_call(args, logger, conn, *a, **kw):
+def check_call(conn, logger, args, *a, **kw):
+    """
+    Wraps ``subprocess.check_call`` for a remote call via ``pushy``
+    doing all the capturing and logging nicely upon failure/success
+
+    :param args: The args to be passed onto ``check_call``
+    """
     command = ' '.join(args)
     logger.info('Running command: %s' % command)
 
@@ -21,33 +27,5 @@ def check_call(args, logger, conn, *a, **kw):
             **kw
         )
 
-    compile_ = remote_compile(conn, remote_call)
-    with context.capsys(conn, logger):
-        try:
-            return compile_(args, *a, **kw)
-        except Exception as err:
-            if getattr(err, 'remote_traceback'):
-                for line in err.remote_traceback:
-                    logger.error(line)
-            else:
-                raise
-
-
-def generic_remote(func, logger, conn, *a, **kw):
-    """
-    This generic remote wrapper will introspect the docstring from ``func`` to
-    log out the action about to be done. It better be succinct.
-    """
-    action = getattr(func, 'func_doc', func.func_name)
-    logger.info('Executing action: %s' % action)
-
-    compile_ = remote_compile(conn, func)
-    with context.capsys(conn, logger):
-        try:
-            return compile_(*a, **kw)
-        except Exception as err:
-            if getattr(err, 'remote_traceback'):
-                for line in err.remote_traceback:
-                    logger.error(line)
-            else:
-                raise
+    with context.remote(conn, logger, remote_call) as call:
+        return call(args, *a, **kw)