2013-07-22 21:21:51 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def rados(ctx, remote, cmd, wait=True, check_status=False):
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
log.info("rados %s" % ' '.join(cmd))
|
|
|
|
pre = [
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-07-22 21:21:51 +00:00
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'rados',
|
|
|
|
];
|
|
|
|
pre.extend(cmd)
|
|
|
|
proc = remote.run(
|
|
|
|
args=pre,
|
|
|
|
check_status=check_status,
|
|
|
|
wait=wait,
|
|
|
|
)
|
|
|
|
if wait:
|
|
|
|
return proc.exitstatus
|
|
|
|
else:
|
|
|
|
return proc
|
2014-03-25 01:19:41 +00:00
|
|
|
|
2017-08-22 17:55:47 +00:00
|
|
|
def create_ec_pool(remote, name, profile_name, pgnum, profile={}, cluster_name="ceph", application=None):
|
2015-09-11 16:11:31 +00:00
|
|
|
remote.run(args=['sudo', 'ceph'] +
|
2016-12-16 18:23:09 +00:00
|
|
|
cmd_erasure_code_profile(profile_name, profile) + ['--cluster', cluster_name])
|
2014-03-25 01:19:41 +00:00
|
|
|
remote.run(args=[
|
2015-09-11 16:11:31 +00:00
|
|
|
'sudo', 'ceph', 'osd', 'pool', 'create', name,
|
2016-12-16 18:23:09 +00:00
|
|
|
str(pgnum), str(pgnum), 'erasure', profile_name, '--cluster', cluster_name
|
2014-03-25 01:19:41 +00:00
|
|
|
])
|
2017-08-22 17:55:47 +00:00
|
|
|
if application:
|
|
|
|
remote.run(args=[
|
|
|
|
'sudo', 'ceph', 'osd', 'pool', 'application', 'enable', name, application, '--cluster', cluster_name
|
2017-10-09 14:11:14 +00:00
|
|
|
], check_status=False) # may fail as EINVAL when run in jewel upgrade test
|
2014-03-25 01:19:41 +00:00
|
|
|
|
2017-08-22 17:55:47 +00:00
|
|
|
def create_replicated_pool(remote, name, pgnum, cluster_name="ceph", application=None):
|
2014-03-25 01:19:41 +00:00
|
|
|
remote.run(args=[
|
2016-12-16 18:23:09 +00:00
|
|
|
'sudo', 'ceph', 'osd', 'pool', 'create', name, str(pgnum), str(pgnum), '--cluster', cluster_name
|
2014-03-25 01:19:41 +00:00
|
|
|
])
|
2017-08-22 17:55:47 +00:00
|
|
|
if application:
|
|
|
|
remote.run(args=[
|
|
|
|
'sudo', 'ceph', 'osd', 'pool', 'application', 'enable', name, application, '--cluster', cluster_name
|
2017-10-09 14:11:14 +00:00
|
|
|
], check_status=False)
|
2014-05-01 21:36:08 +00:00
|
|
|
|
2017-08-28 14:14:03 +00:00
|
|
|
def create_cache_pool(remote, base_name, cache_name, pgnum, size, cluster_name="ceph"):
|
2014-05-01 21:36:08 +00:00
|
|
|
remote.run(args=[
|
2016-12-16 18:23:09 +00:00
|
|
|
'sudo', 'ceph', 'osd', 'pool', 'create', cache_name, str(pgnum), '--cluster', cluster_name
|
2015-09-11 16:11:31 +00:00
|
|
|
])
|
2014-05-01 21:36:08 +00:00
|
|
|
remote.run(args=[
|
2015-09-11 16:11:31 +00:00
|
|
|
'sudo', 'ceph', 'osd', 'tier', 'add-cache', base_name, cache_name,
|
2016-12-16 18:23:09 +00:00
|
|
|
str(size), '--cluster', cluster_name
|
2015-09-11 16:11:31 +00:00
|
|
|
])
|
2014-06-10 15:17:26 +00:00
|
|
|
|
|
|
|
def cmd_erasure_code_profile(profile_name, profile):
|
|
|
|
"""
|
|
|
|
Return the shell command to run to create the erasure code profile
|
|
|
|
described by the profile parameter.
|
|
|
|
|
|
|
|
:param profile_name: a string matching [A-Za-z0-9-_.]+
|
|
|
|
:param profile: a map whose semantic depends on the erasure code plugin
|
|
|
|
:returns: a shell command as an array suitable for Remote.run
|
|
|
|
|
|
|
|
If profile is {}, it is replaced with
|
|
|
|
|
2017-06-30 18:59:39 +00:00
|
|
|
{ 'k': '2', 'm': '1', 'crush-failure-domain': 'osd'}
|
2014-06-10 15:17:26 +00:00
|
|
|
|
|
|
|
for backward compatibility. In previous versions of teuthology,
|
|
|
|
these values were hardcoded as function arguments and some yaml
|
|
|
|
files were designed with these implicit values. The teuthology
|
|
|
|
code should not know anything about the erasure code profile
|
|
|
|
content or semantic. The valid values and parameters are outside
|
|
|
|
its scope.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if profile == {}:
|
|
|
|
profile = {
|
|
|
|
'k': '2',
|
|
|
|
'm': '1',
|
2017-06-30 18:59:39 +00:00
|
|
|
'crush-failure-domain': 'osd'
|
2014-06-10 15:17:26 +00:00
|
|
|
}
|
|
|
|
return [
|
2014-07-01 10:21:17 +00:00
|
|
|
'osd', 'erasure-code-profile', 'set',
|
2014-06-10 15:17:26 +00:00
|
|
|
profile_name
|
2014-07-01 10:19:54 +00:00
|
|
|
] + [ str(key) + '=' + str(value) for key, value in profile.iteritems() ]
|