From 2dad906f4ac4658381f3984a8fe99f696f710fac Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 19 Jul 2014 09:22:27 -0700 Subject: [PATCH] move ship_utilities to install task (from ceph test) No need to install ceph just to get daemon-helper, adjust-ulimits, etc.. These utilities are used by lots of tasks, not just ceph. Signed-off-by: Sage Weil --- teuthology/task/ceph.py | 69 -------------------------------------- teuthology/task/install.py | 69 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 5944dbbe20a59..36f3e3be12988 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -236,74 +236,6 @@ def ceph_log(ctx, config): pass -@contextlib.contextmanager -def ship_utilities(ctx, config): - """ - Write a copy of valgrind.supp to each of the remote sites. Set executables used - by Ceph in /usr/local/bin. When finished (upon exit of the teuthology run), remove - these files. - - :param ctx: Context - :param config: Configuration - """ - assert config is None - testdir = teuthology.get_testdir(ctx) - filenames = [] - - log.info('Shipping valgrind.supp...') - with file(os.path.join(os.path.dirname(__file__), 'valgrind.supp'), 'rb') as f: - fn = os.path.join(testdir, 'valgrind.supp') - filenames.append(fn) - for rem in ctx.cluster.remotes.iterkeys(): - teuthology.sudo_write_file( - remote=rem, - path=fn, - data=f, - ) - f.seek(0) - - FILES = ['daemon-helper', 'adjust-ulimits', 'kcon_most'] - destdir = '/usr/bin' - for filename in FILES: - log.info('Shipping %r...', filename) - src = os.path.join(os.path.dirname(__file__), filename) - dst = os.path.join(destdir, filename) - filenames.append(dst) - with file(src, 'rb') as f: - for rem in ctx.cluster.remotes.iterkeys(): - teuthology.sudo_write_file( - remote=rem, - path=dst, - data=f, - ) - f.seek(0) - rem.run( - args=[ - 'sudo', - 'chmod', - 'a=rx', - '--', - dst, - ], - ) - - try: - yield - finally: - log.info('Removing shipped files: %s...', ' '.join(filenames)) - run.wait( - ctx.cluster.run( - args=[ - 'sudo', - 'rm', - '-f', - '--', - ] + list(filenames), - wait=False, - ), - ) - - def assign_devs(roles, devs): """ Create a dictionary of devs indexed by roles @@ -1480,7 +1412,6 @@ def task(ctx, config): with contextutil.nested( lambda: ceph_log(ctx=ctx, config=None), - lambda: ship_utilities(ctx=ctx, config=None), lambda: valgrind_post(ctx=ctx, config=config), lambda: cluster(ctx=ctx, config=dict( conf=config.get('conf', {}), diff --git a/teuthology/task/install.py b/teuthology/task/install.py index 9ef3e211eb802..0aef437a05ee0 100644 --- a/teuthology/task/install.py +++ b/teuthology/task/install.py @@ -1089,6 +1089,74 @@ def upgrade(ctx, config): yield +@contextlib.contextmanager +def ship_utilities(ctx, config): + """ + Write a copy of valgrind.supp to each of the remote sites. Set executables used + by Ceph in /usr/local/bin. When finished (upon exit of the teuthology run), remove + these files. + + :param ctx: Context + :param config: Configuration + """ + assert config is None + testdir = teuthology.get_testdir(ctx) + filenames = [] + + log.info('Shipping valgrind.supp...') + with file(os.path.join(os.path.dirname(__file__), 'valgrind.supp'), 'rb') as f: + fn = os.path.join(testdir, 'valgrind.supp') + filenames.append(fn) + for rem in ctx.cluster.remotes.iterkeys(): + teuthology.sudo_write_file( + remote=rem, + path=fn, + data=f, + ) + f.seek(0) + + FILES = ['daemon-helper', 'adjust-ulimits', 'kcon_most'] + destdir = '/usr/bin' + for filename in FILES: + log.info('Shipping %r...', filename) + src = os.path.join(os.path.dirname(__file__), filename) + dst = os.path.join(destdir, filename) + filenames.append(dst) + with file(src, 'rb') as f: + for rem in ctx.cluster.remotes.iterkeys(): + teuthology.sudo_write_file( + remote=rem, + path=dst, + data=f, + ) + f.seek(0) + rem.run( + args=[ + 'sudo', + 'chmod', + 'a=rx', + '--', + dst, + ], + ) + + try: + yield + finally: + log.info('Removing shipped files: %s...', ' '.join(filenames)) + run.wait( + ctx.cluster.run( + args=[ + 'sudo', + 'rm', + '-f', + '--', + ] + list(filenames), + wait=False, + ), + ) + + @contextlib.contextmanager def task(ctx, config): """ @@ -1160,5 +1228,6 @@ def task(ctx, config): wait_for_package=ctx.config.get('wait_for_package', False), project=project, )), + lambda: ship_utilities(ctx=ctx, config=None), ): yield -- 2.39.5