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)
**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)