Handle the setup, starting, and clean-up of a Ceph cluster.
"""
from io import BytesIO
+from io import StringIO
import argparse
import configobj
import time
import gevent
import re
-import six
import socket
from paramiko import SSHException
testdir = teuthology.get_testdir(ctx)
remote_logrotate_conf = '%s/logrotate.ceph-test.conf' % testdir
rotate_conf_path = os.path.join(os.path.dirname(__file__), 'logrotate.conf')
- with open(rotate_conf_path, 'rb') as f:
+ with open(rotate_conf_path) as f:
conf = ""
for daemon, size in daemons.items():
log.info('writing logrotate stanza for {}'.format(daemon))
- conf += six.ensure_str(f.read()).format(daemon_type=daemon,
- max_size=size)
+ conf += f.read().format(daemon_type=daemon,
+ max_size=size)
f.seek(0, 0)
for remote in ctx.cluster.remotes.keys():
"/dev/null | sort | uniq",
wait=False,
check_status=False,
- stdout=BytesIO(),
+ stdout=StringIO(),
)
lookup_procs.append((proc, remote))
valgrind_exception = None
for (proc, remote) in lookup_procs:
proc.wait()
- out = six.ensure_str(proc.stdout.getvalue())
+ out = proc.stdout.getvalue()
for line in out.split('\n'):
if line == '':
continue
if type_ == 'osd':
datadir='/var/lib/ceph/osd/{cluster}-{id}'.format(
cluster=cluster_name, id=id_)
- osd_uuid = six.ensure_str(teuthology.get_file(
+ osd_uuid = teuthology.get_file(
remote=remote,
path=datadir + '/fsid',
sudo=True,
- )).strip()
+ ).decode().strip()
osd_uuids[id_] = osd_uuid
for osd_id in range(len(osd_uuids)):
id_ = str(osd_id)
import threading
import traceback
import os
-import six
-from io import BytesIO
-from six import StringIO
+from io import BytesIO, StringIO
from teuthology import misc as teuthology
from tasks.scrub import Scrubber
from tasks.util.rados import cmd_erasure_code_profile
"exp list-pgs failure with status {ret}".
format(ret=proc.exitstatus))
- pgs = six.ensure_str(proc.stdout.getvalue()).split('\n')[:-1]
+ pgs = proc.stdout.getvalue().split('\n')[:-1]
if len(pgs) == 0:
self.log("No PGs found for osd.{osd}".format(osd=exp_osd))
return
raise Exception("ceph-objectstore-tool: "
"imp list-pgs failure with status {ret}".
format(ret=proc.exitstatus))
- pgs = six.ensure_str(proc.stdout.getvalue()).split('\n')[:-1]
+ pgs = proc.stdout.getvalue().split('\n')[:-1]
if pg not in pgs:
self.log("Moving pg {pg} from osd.{fosd} to osd.{tosd}".
format(pg=pg, fosd=exp_osd, tosd=imp_osd))
lines.append(cmd)
return "\n".join(lines)
- def run(self, options, args, stdin=None, stdout=None):
- if stdout is None:
- stdout = BytesIO()
+ def run(self, options, args):
self.manager.kill_osd(self.osd)
- cmd = self.build_cmd(options, args, stdin)
+ cmd = self.build_cmd(options, args, None)
self.manager.log(cmd)
try:
proc = self.remote.run(args=['bash', '-e', '-x', '-c', cmd],
check_status=False,
- stdout=stdout,
+ stdout=BytesIO(),
stderr=BytesIO())
proc.wait()
if proc.exitstatus != 0:
self.manager.log("failed with " + str(proc.exitstatus))
- error = six.ensure_str(proc.stdout.getvalue()) + " " + \
- six.ensure_str(proc.stderr.getvalue())
+ error = proc.stdout.getvalue().decode() + " " + \
+ proc.stderr.getvalue().decode()
raise Exception(error)
finally:
if self.do_revive:
:param erasure_code_use_overwrites: if true, allow overwrites
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
assert isinstance(pg_num, int)
assert pool_name not in self.pools
self.log("creating pool_name %s" % (pool_name,))
:param pool_name: Pool to be removed
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
assert pool_name in self.pools
self.log("removing pool_name %s" % (pool_name,))
del self.pools[pool_name]
Return the number of pgs in the pool specified.
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
if pool_name in self.pools:
return self.pools[pool_name]
return 0
:returns: property as string
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
- assert isinstance(prop, six.string_types)
+ assert isinstance(pool_name, str)
+ assert isinstance(prop, str)
output = self.raw_cluster_cmd(
'osd',
'pool',
This routine retries if set operation fails.
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
- assert isinstance(prop, six.string_types)
+ assert isinstance(pool_name, str)
+ assert isinstance(prop, str)
assert isinstance(val, int)
tries = 0
while True:
Increase the number of pgs in a pool
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
assert isinstance(by, int)
assert pool_name in self.pools
if self.get_num_creating() > 0:
with self.lock:
self.log('contract_pool %s by %s min %s' % (
pool_name, str(by), str(min_pgs)))
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
assert isinstance(by, int)
assert pool_name in self.pools
if self.get_num_creating() > 0:
Set pgpnum property of pool_name pool.
"""
with self.lock:
- assert isinstance(pool_name, six.string_types)
+ assert isinstance(pool_name, str)
assert pool_name in self.pools
if not force and self.get_num_creating() > 0:
return False