]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/util/rados.py
update sources to v12.2.1
[ceph.git] / ceph / qa / tasks / util / rados.py
CommitLineData
7c673cae
FG
1import logging
2
3from teuthology import misc as teuthology
4
5log = logging.getLogger(__name__)
6
7def 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
b5b8bbf5 27def create_ec_pool(remote, name, profile_name, pgnum, profile={}, cluster_name="ceph", application=None):
7c673cae
FG
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 ])
b5b8bbf5
FG
34 if application:
35 remote.run(args=[
36 'sudo', 'ceph', 'osd', 'pool', 'application', 'enable', name, application, '--cluster', cluster_name
37 ])
7c673cae 38
b5b8bbf5 39def create_replicated_pool(remote, name, pgnum, cluster_name="ceph", application=None):
7c673cae
FG
40 remote.run(args=[
41 'sudo', 'ceph', 'osd', 'pool', 'create', name, str(pgnum), str(pgnum), '--cluster', cluster_name
42 ])
b5b8bbf5
FG
43 if application:
44 remote.run(args=[
45 'sudo', 'ceph', 'osd', 'pool', 'application', 'enable', name, application, '--cluster', cluster_name
46 ])
7c673cae 47
181888fb 48def create_cache_pool(remote, base_name, cache_name, pgnum, size, cluster_name="ceph"):
7c673cae
FG
49 remote.run(args=[
50 'sudo', 'ceph', 'osd', 'pool', 'create', cache_name, str(pgnum), '--cluster', cluster_name
51 ])
52 remote.run(args=[
53 'sudo', 'ceph', 'osd', 'tier', 'add-cache', base_name, cache_name,
54 str(size), '--cluster', cluster_name
55 ])
56
57def cmd_erasure_code_profile(profile_name, profile):
58 """
59 Return the shell command to run to create the erasure code profile
60 described by the profile parameter.
61
62 :param profile_name: a string matching [A-Za-z0-9-_.]+
63 :param profile: a map whose semantic depends on the erasure code plugin
64 :returns: a shell command as an array suitable for Remote.run
65
66 If profile is {}, it is replaced with
67
224ce89b 68 { 'k': '2', 'm': '1', 'crush-failure-domain': 'osd'}
7c673cae
FG
69
70 for backward compatibility. In previous versions of teuthology,
71 these values were hardcoded as function arguments and some yaml
72 files were designed with these implicit values. The teuthology
73 code should not know anything about the erasure code profile
74 content or semantic. The valid values and parameters are outside
75 its scope.
76 """
77
78 if profile == {}:
79 profile = {
80 'k': '2',
81 'm': '1',
224ce89b 82 'crush-failure-domain': 'osd'
7c673cae
FG
83 }
84 return [
85 'osd', 'erasure-code-profile', 'set',
86 profile_name
87 ] + [ str(key) + '=' + str(value) for key, value in profile.iteritems() ]