diff options
author | Sage Weil <sage@redhat.com> | 2017-04-13 16:09:26 +0200 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2017-04-13 23:11:19 +0200 |
commit | 5ca72c1193580aafef75accbe61429d75cd53688 (patch) | |
tree | 4499190071b92f096db8f8ee18c4ef1cf9b7eddc | |
parent | mon/OSDMonitor: fix initial map when require_luminous_osds not set on mkfs (diff) | |
download | ceph-5ca72c1193580aafef75accbe61429d75cd53688.tar.xz ceph-5ca72c1193580aafef75accbe61429d75cd53688.zip |
qa/tasks/exec_on_cleanup.py: add
Signed-off-by: Sage Weil <sage@redhat.com>
-rw-r--r-- | qa/tasks/exec_on_cleanup.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/qa/tasks/exec_on_cleanup.py b/qa/tasks/exec_on_cleanup.py new file mode 100644 index 00000000000..e3c09d5ec15 --- /dev/null +++ b/qa/tasks/exec_on_cleanup.py @@ -0,0 +1,62 @@ +""" +Exececute custom commands during unwind/cleanup +""" +import logging +import contextlib + +from teuthology import misc as teuthology +from teuthology import contextutil + +log = logging.getLogger(__name__) + +@contextlib.contextmanager +def task(ctx, config): + """ + Execute commands on a given role + + tasks: + - ceph: + - kclient: [client.a] + - exec: + client.a: + - "echo 'module libceph +p' > /sys/kernel/debug/dynamic_debug/control" + - "echo 'module ceph +p' > /sys/kernel/debug/dynamic_debug/control" + - interactive: + + It stops and fails with the first command that does not return on success. It means + that if the first command fails, the second won't run at all. + + To avoid confusion it is recommended to explicitly enclose the commands in + double quotes. For instance if the command is false (without double quotes) it will + be interpreted as a boolean by the YAML parser. + + :param ctx: Context + :param config: Configuration + """ + try: + yield + finally: + log.info('Executing custom commands...') + assert isinstance(config, dict), "task exec got invalid config" + + testdir = teuthology.get_testdir(ctx) + + if 'all' in config and len(config) == 1: + a = config['all'] + roles = teuthology.all_roles(ctx.cluster) + config = dict((id_, a) for id_ in roles) + + for role, ls in config.iteritems(): + (remote,) = ctx.cluster.only(role).remotes.iterkeys() + log.info('Running commands on role %s host %s', role, remote.name) + for c in ls: + c.replace('$TESTDIR', testdir) + remote.run( + args=[ + 'sudo', + 'TESTDIR={tdir}'.format(tdir=testdir), + 'bash', + '-c', + c], + ) + |