Skip to content

Commit 1ed6654

Browse files
qa/tasks: a new cephadm exec task similar to vip.exec but generalized
Add a new cephadm.exec task that works similarly to the existing vip.exec but instead of only considering VIP related string replacements it uses that templating feature that was recently added to the cephadm module for generalized string templating. Signed-off-by: John Mulligan <[email protected]>
1 parent 3ec0bfa commit 1ed6654

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

qa/tasks/cephadm.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,41 @@ def _shell_command(obj):
14631463
raise ValueError(f'invalid command item: {obj!r}')
14641464

14651465

1466+
def exec(ctx, config):
1467+
"""
1468+
This is similar to the standard 'exec' task, but does template substitutions.
1469+
1470+
TODO: this should probably be moved out of cephadm.py as it's pretty generic.
1471+
"""
1472+
assert isinstance(config, dict), "task exec got invalid config"
1473+
1474+
testdir = teuthology.get_testdir(ctx)
1475+
1476+
if 'all-roles' in config and len(config) == 1:
1477+
a = config['all-roles']
1478+
roles = teuthology.all_roles(ctx.cluster)
1479+
config = dict((id_, a) for id_ in roles if not id_.startswith('host.'))
1480+
elif 'all-hosts' in config and len(config) == 1:
1481+
a = config['all-hosts']
1482+
roles = teuthology.all_roles(ctx.cluster)
1483+
config = dict((id_, a) for id_ in roles if id_.startswith('host.'))
1484+
1485+
for role, ls in config.items():
1486+
(remote,) = ctx.cluster.only(role).remotes.keys()
1487+
log.info('Running commands on role %s host %s', role, remote.name)
1488+
for c in ls:
1489+
c.replace('$TESTDIR', testdir)
1490+
remote.run(
1491+
args=[
1492+
'sudo',
1493+
'TESTDIR={tdir}'.format(tdir=testdir),
1494+
'bash',
1495+
'-ex',
1496+
'-c',
1497+
_template_transform(ctx, config, c)],
1498+
)
1499+
1500+
14661501
def apply(ctx, config):
14671502
"""
14681503
Apply spec

0 commit comments

Comments
 (0)