2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Exececute custom commands
|
|
|
|
"""
|
2012-10-22 23:51:54 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
2013-10-12 08:28:27 +00:00
|
|
|
:param ctx: Context
|
|
|
|
:param config: Configuration
|
2012-10-22 23:51:54 +00:00
|
|
|
"""
|
|
|
|
log.info('Executing custom commands...')
|
|
|
|
assert isinstance(config, dict), "task exec got invalid config"
|
|
|
|
|
2013-02-25 17:59:21 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
|
2012-10-22 23:51:54 +00:00
|
|
|
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():
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
2012-10-22 23:51:54 +00:00
|
|
|
log.info('Running commands on role %s host %s', role, remote.name)
|
|
|
|
for c in ls:
|
2013-03-10 02:07:06 +00:00
|
|
|
c.replace('$TESTDIR', testdir)
|
2012-10-22 23:51:54 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
2013-02-25 17:59:21 +00:00
|
|
|
'TESTDIR={tdir}'.format(tdir=testdir),
|
2012-10-22 23:51:54 +00:00
|
|
|
'bash',
|
|
|
|
'-c',
|
|
|
|
c],
|
|
|
|
)
|
|
|
|
|