2 Exececute custom commands during unwind/cleanup
7 from teuthology import misc as teuthology
8 from teuthology import contextutil
10 log = logging.getLogger(__name__)
12 @contextlib.contextmanager
13 def task(ctx, config):
15 Execute commands on a given role
22 - "echo 'module libceph +p' > /sys/kernel/debug/dynamic_debug/control"
23 - "echo 'module ceph +p' > /sys/kernel/debug/dynamic_debug/control"
26 It stops and fails with the first command that does not return on success. It means
27 that if the first command fails, the second won't run at all.
29 To avoid confusion it is recommended to explicitly enclose the commands in
30 double quotes. For instance if the command is false (without double quotes) it will
31 be interpreted as a boolean by the YAML parser.
34 :param config: Configuration
39 log.info('Executing custom commands...')
40 assert isinstance(config, dict), "task exec got invalid config"
42 testdir = teuthology.get_testdir(ctx)
44 if 'all' in config and len(config) == 1:
46 roles = teuthology.all_roles(ctx.cluster)
47 config = dict((id_, a) for id_ in roles)
49 for role, ls in config.iteritems():
50 (remote,) = ctx.cluster.only(role).remotes.iterkeys()
51 log.info('Running commands on role %s host %s', role, remote.name)
53 c.replace('$TESTDIR', testdir)
57 'TESTDIR={tdir}'.format(tdir=testdir),