"""
ceph manager -- Thrasher and CephManager objects
"""
-from cStringIO import StringIO
from functools import wraps
import contextlib
import random
import threading
import traceback
import os
+
+from io import BytesIO
from teuthology import misc as teuthology
from tasks.scrub import Scrubber
from util.rados import cmd_erasure_code_profile
)
def write_conf(ctx, conf_path=DEFAULT_CONF_PATH, cluster='ceph'):
- conf_fp = StringIO()
+ conf_fp = BytesIO()
ctx.ceph[cluster].conf.write(conf_fp)
conf_fp.seek(0)
writes = ctx.cluster.run(
allremotes = list(set(allremotes))
for remote in allremotes:
proc = remote.run(args=['type', cmd], wait=True,
- check_status=False, stdout=StringIO(),
- stderr=StringIO())
+ check_status=False, stdout=BytesIO(),
+ stderr=BytesIO())
if proc.exitstatus != 0:
return False;
return True;
args=['ceph-objectstore-tool'] + cmd,
name=osd,
wait=True, check_status=False,
- stdout=StringIO(),
- stderr=StringIO())
+ stdout=BytesIO(),
+ stderr=BytesIO())
else:
return remote.run(
args=['sudo', 'adjust-ulimits', 'ceph-objectstore-tool'] + cmd,
- wait=True, check_status=False, stdout=StringIO(),
- stderr=StringIO())
+ wait=True, check_status=False, stdout=BytesIO(),
+ stderr=BytesIO())
def kill_osd(self, osd=None, mark_down=False, mark_out=False):
"""
with safe_while(sleep=15, tries=40, action="type ceph-objectstore-tool") as proceed:
while proceed():
proc = exp_remote.run(args=['type', 'ceph-objectstore-tool'],
- wait=True, check_status=False, stdout=StringIO(),
- stderr=StringIO())
+ wait=True, check_status=False, stdout=BytesIO(),
+ stderr=BytesIO())
if proc.exitstatus == 0:
break
log.debug("ceph-objectstore-tool binary not present, trying again")
raise Exception("ceph-objectstore-tool: "
"imp list-pgs failure with status {ret}".
format(ret=proc.exitstatus))
- pgs = proc.stdout.getvalue().split('\n')[:-1]
+ pgs = six.ensure_str(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))
'--journal-path', JPATH.format(id=imp_osd),
])
+ " --op apply-layout-settings --pool " + pool).format(id=osd)
- proc = imp_remote.run(args=cmd, wait=True, check_status=False, stderr=StringIO())
- output = proc.stderr.getvalue()
+ output = imp_remote.sh(cmd, wait=True, check_status=False)
if 'Couldn\'t find pool' in output:
continue
if proc.exitstatus:
def run(self, options, args, stdin=None, stdout=None):
if stdout is None:
- stdout = StringIO()
+ stdout = BytesIO()
self.manager.kill_osd(self.osd)
cmd = self.build_cmd(options, args, stdin)
self.manager.log(cmd)
proc = self.remote.run(args=['bash', '-e', '-x', '-c', cmd],
check_status=False,
stdout=stdout,
- stderr=StringIO())
+ stderr=BytesIO())
proc.wait()
if proc.exitstatus != 0:
self.manager.log("failed with " + str(proc.exitstatus))
- error = proc.stdout.getvalue() + " " + proc.stderr.getvalue()
+ error = six.ensure_str(proc.stdout.getvalue()) + " " + \
+ six.ensure_str(proc.stderr.getvalue())
raise Exception(error)
finally:
if self.do_revive:
if self.cephadm:
proc = shell(self.ctx, self.cluster, self.controller,
args=['ceph'] + list(args),
- stdout=StringIO())
+ stdout=BytesIO())
else:
testdir = teuthology.get_testdir(self.ctx)
ceph_args = [
ceph_args.extend(args)
proc = self.controller.run(
args=ceph_args,
- stdout=StringIO(),
+ stdout=BytesIO(),
)
- return proc.stdout.getvalue()
+ return six.ensure_str(proc.stdout.getvalue())
def raw_cluster_cmd_result(self, *args, **kwargs):
"""
def run_ceph_w(self, watch_channel=None):
"""
- Execute "ceph -w" in the background with stdout connected to a StringIO,
+ Execute "ceph -w" in the background with stdout connected to a BytesIO,
and return the RemoteProcess.
:param watch_channel: Specifies the channel to be watched. This can be
if watch_channel is not None:
args.append("--watch-channel")
args.append(watch_channel)
- return self.controller.run(args=args, wait=False, stdout=StringIO(), stdin=run.PIPE)
+ return self.controller.run(args=args, wait=False, stdout=BytesIO(), stdin=run.PIPE)
def get_mon_socks(self):
"""
def osd_admin_socket(self, osd_id, command, check_status=True, timeout=0, stdout=None):
if stdout is None:
- stdout = StringIO()
+ stdout = BytesIO()
return self.admin_socket('osd', osd_id, command, check_status, timeout, stdout)
def find_remote(self, service_type, service_id):
to the admin socket
"""
if stdout is None:
- stdout = StringIO()
+ stdout = BytesIO()
remote = self.find_remote(service_type, service_id)
five seconds and try again.
"""
if stdout is None:
- stdout = StringIO()
+ stdout = BytesIO()
tries = 0
while True:
proc = self.admin_socket(service_type, service_id,