]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/util/rados.py
2d9d263d45f09f1c1dc033b215a634656d6e7aba
[ceph.git] / ceph / qa / tasks / util / rados.py
1 import logging
2
3 from teuthology import misc as teuthology
4
5 log = logging.getLogger(__name__)
6
7 def rados(ctx, remote, cmd, wait=True, check_status=False):
8 testdir = teuthology.get_testdir(ctx)
9 log.info("rados %s" % ' '.join(cmd))
10 pre = [
11 'adjust-ulimits',
12 'ceph-coverage',
13 '{tdir}/archive/coverage'.format(tdir=testdir),
14 'rados',
15 ];
16 pre.extend(cmd)
17 proc = remote.run(
18 args=pre,
19 check_status=check_status,
20 wait=wait,
21 )
22 if wait:
23 return proc.exitstatus
24 else:
25 return proc
26
27 def create_ec_pool(remote, name, profile_name, pgnum, profile={}, cluster_name="ceph"):
28 remote.run(args=['sudo', 'ceph'] +
29 cmd_erasure_code_profile(profile_name, profile) + ['--cluster', cluster_name])
30 remote.run(args=[
31 'sudo', 'ceph', 'osd', 'pool', 'create', name,
32 str(pgnum), str(pgnum), 'erasure', profile_name, '--cluster', cluster_name
33 ])
34
35 def create_replicated_pool(remote, name, pgnum, cluster_name="ceph"):
36 remote.run(args=[
37 'sudo', 'ceph', 'osd', 'pool', 'create', name, str(pgnum), str(pgnum), '--cluster', cluster_name
38 ])
39
40 def create_cache_pool(remote, base_name, cache_name, pgnum, size, cluster_name="ceph"):
41 remote.run(args=[
42 'sudo', 'ceph', 'osd', 'pool', 'create', cache_name, str(pgnum), '--cluster', cluster_name
43 ])
44 remote.run(args=[
45 'sudo', 'ceph', 'osd', 'tier', 'add-cache', base_name, cache_name,
46 str(size), '--cluster', cluster_name
47 ])
48
49 def cmd_erasure_code_profile(profile_name, profile):
50 """
51 Return the shell command to run to create the erasure code profile
52 described by the profile parameter.
53
54 :param profile_name: a string matching [A-Za-z0-9-_.]+
55 :param profile: a map whose semantic depends on the erasure code plugin
56 :returns: a shell command as an array suitable for Remote.run
57
58 If profile is {}, it is replaced with
59
60 { 'k': '2', 'm': '1', 'ruleset-failure-domain': 'osd'}
61
62 for backward compatibility. In previous versions of teuthology,
63 these values were hardcoded as function arguments and some yaml
64 files were designed with these implicit values. The teuthology
65 code should not know anything about the erasure code profile
66 content or semantic. The valid values and parameters are outside
67 its scope.
68 """
69
70 if profile == {}:
71 profile = {
72 'k': '2',
73 'm': '1',
74 'ruleset-failure-domain': 'osd'
75 }
76 return [
77 'osd', 'erasure-code-profile', 'set',
78 profile_name
79 ] + [ str(key) + '=' + str(value) for key, value in profile.iteritems() ]