Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / tasks / ceph_client.py
1 """
2 Set up client keyring
3 """
4 import logging
5
6 from teuthology import misc as teuthology
7 from teuthology.orchestra import run
8
9 log = logging.getLogger(__name__)
10
11 def create_keyring(ctx, cluster_name):
12     """
13     Set up key ring on remote sites
14     """
15     log.info('Setting up client nodes...')
16     clients = ctx.cluster.only(teuthology.is_type('client', cluster_name))
17     testdir = teuthology.get_testdir(ctx)
18     coverage_dir = '{tdir}/archive/coverage'.format(tdir=testdir)
19     for remote, roles_for_host in clients.remotes.iteritems():
20         for role in teuthology.cluster_roles_of_type(roles_for_host, 'client',
21                                                      cluster_name):
22             name = teuthology.ceph_role(role)
23             client_keyring = '/etc/ceph/{0}.{1}.keyring'.format(cluster_name, name)
24             remote.run(
25                 args=[
26                     'sudo',
27                     'adjust-ulimits',
28                     'ceph-coverage',
29                     coverage_dir,
30                     'ceph-authtool',
31                     '--create-keyring',
32                     '--gen-key',
33                     # TODO this --name= is not really obeyed, all unknown "types" are munged to "client"
34                     '--name={name}'.format(name=name),
35                     client_keyring,
36                     run.Raw('&&'),
37                     'sudo',
38                     'chmod',
39                     '0644',
40                     client_keyring,
41                     ],
42                 )