8 from teuthology import misc as teuthology
9 from teuthology import contextutil
10 from teuthology.orchestra import run
11 from teuthology.orchestra.daemon import DaemonGroup
13 log = logging.getLogger(__name__)
16 @contextlib.contextmanager
17 def run_rest_api_daemon(ctx, api_clients):
19 Wrapper starts the rest api daemons
21 if not hasattr(ctx, 'daemons'):
22 ctx.daemons = DaemonGroup()
23 remotes = ctx.cluster.only(teuthology.is_type('client')).remotes
24 for rems, roles in remotes.iteritems():
25 for whole_id_ in roles:
26 if whole_id_ in api_clients:
27 id_ = whole_id_[len('clients'):]
34 'client.rest{id}'.format(id=id_), ]
35 cl_rest_id = 'client.rest{id}'.format(id=id_)
36 ctx.daemons.add_daemon(rems, 'restapi',
39 logger=log.getChild(cl_rest_id),
43 for i in range(1, 12):
44 log.info('testing for ceph-rest-api try {0}'.format(i))
50 'http://localhost:5000/api/v0.1/status'
56 if proc.exitstatus == 0:
59 if proc.exitstatus != 0:
60 raise RuntimeError('Cannot contact ceph-rest-api')
66 TO DO: destroy daemons started -- modify iter_daemons_of_role
68 teuthology.stop_daemons_of_type(ctx, 'restapi')
70 @contextlib.contextmanager
71 def task(ctx, config):
75 To start on on all clients::
81 To only run on certain clients::
85 - rest-api: [client.0, client.3]
95 The general flow of things here is:
96 1. Find clients on which rest-api is supposed to run (api_clients)
97 2. Generate keyring values
98 3. Start up ceph-rest-api daemons
101 5. Delete keyring value files.
104 remotes = ctx.cluster.only(teuthology.is_type('client')).remotes
107 api_clients = ['client.{id}'.format(id=id_)
108 for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
111 log.info(api_clients)
112 testdir = teuthology.get_testdir(ctx)
113 coverage_dir = '{tdir}/archive/coverage'.format(tdir=testdir)
114 for rems, roles in remotes.iteritems():
115 for whole_id_ in roles:
116 if whole_id_ in api_clients:
117 id_ = whole_id_[len('client.'):]
118 keyring = '/etc/ceph/ceph.client.rest{id}.keyring'.format(
129 '--name=client.rest{id}'.format(id=id_),
131 '--cap', 'mon', 'allow *',
132 '--cap', 'osd', 'allow *',
133 '--cap', 'mds', 'allow',
149 '[client.rest{id}]'.format(id=id_),
151 "/etc/ceph/ceph.conf",
165 '/etc/ceph/ceph.client.rest{id}.keyring'.format(id=id_),
167 '/etc/ceph/ceph.conf',
178 '/etc/ceph/ceph.client.rest{id}.keyring'.format(id=id_),
181 with contextutil.nested(
182 lambda: run_rest_api_daemon(ctx=ctx, api_clients=api_clients),):