]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/python.py
import ceph 16.2.7
[ceph.git] / ceph / qa / tasks / python.py
CommitLineData
a4b75251
TL
1import logging
2from teuthology import misc as teuthology
3from tasks.vip import subst_vip
4
5log = logging.getLogger(__name__)
6
7
8def task(ctx, config):
9 """
10 Execute some python code.
11
12 tasks:
13 - python:
14 host.a: |
15 import boto3
16 c = boto3.resource(...)
17
18 The provided dict is normally indexed by role. You can also include a
19 'sudo: false' key to run the code without sudo.
20
21 tasks:
22 - python:
23 sudo: false
24 host.b: |
25 import boto3
26 c = boto3.resource(...)
27 """
28 assert isinstance(config, dict), "task python got invalid config"
29
30 testdir = teuthology.get_testdir(ctx)
31
32 sudo = config.pop('sudo', True)
33
34 for role, code in config.items():
35 (remote,) = ctx.cluster.only(role).remotes.keys()
36 log.info('Running python on role %s host %s', role, remote.name)
37 log.info(code)
38 args=[
39 'TESTDIR={tdir}'.format(tdir=testdir),
40 'python3',
41 ]
42 if sudo:
43 args = ['sudo'] + args
44 remote.run(args=args, stdin=subst_vip(ctx, code))
45