This commit is contained in:
Chris MacNaughton 2016-05-12 16:53:52 -04:00
parent 3e633ce608
commit d5f23b7b00

View File

@ -238,7 +238,7 @@ def get_osd_tree(service):
try: try:
tree = subprocess.check_output( tree = subprocess.check_output(
['ceph', '--id', service, ['ceph', '--id', service,
'osd', 'tree', '--format=json']) 'osd', 'tree', '--format=json']).decode('utf-8')
try: try:
json_tree = json.loads(tree) json_tree = json.loads(tree)
crush_list = [] crush_list = []
@ -366,7 +366,7 @@ def is_quorum():
] ]
if os.path.exists(asok): if os.path.exists(asok):
try: try:
result = json.loads(subprocess.check_output(cmd)) result = json.loads(subprocess.check_output(cmd).decode('utf-8'))
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return False return False
except ValueError: except ValueError:
@ -393,7 +393,7 @@ def is_leader():
] ]
if os.path.exists(asok): if os.path.exists(asok):
try: try:
result = json.loads(subprocess.check_output(cmd)) result = json.loads(subprocess.check_output(cmd).decode('utf-8'))
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return False return False
except ValueError: except ValueError:
@ -535,7 +535,7 @@ def replace_osd(dead_osd_number,
def is_osd_disk(dev): def is_osd_disk(dev):
try: try:
info = subprocess.check_output(['sgdisk', '-i', '1', dev]) info = subprocess.check_output(['sgdisk', '-i', '1', dev]).decode('utf-8')
info = info.split("\n") # IGNORE:E1103 info = info.split("\n") # IGNORE:E1103
for line in info: for line in info:
for ptype in CEPH_PARTITIONS: for ptype in CEPH_PARTITIONS:
@ -616,7 +616,7 @@ def generate_monitor_secret():
'--name=mon.', '--name=mon.',
'--gen-key' '--gen-key'
] ]
res = subprocess.getoutput(cmd) res = subprocess.getoutput(' '.join(cmd))
return "{}==".format(res.split('=')[1].strip()) return "{}==".format(res.split('=')[1].strip())
@ -740,7 +740,7 @@ def get_named_key(name, caps=None):
subsystem, subsystem,
'; '.join(subcaps), '; '.join(subcaps),
]) ])
return parse_key(subprocess.check_output(cmd).strip()) # IGNORE:E1103 return parse_key(subprocess.check_output(cmd).decode('utf-8').strip()) # IGNORE:E1103
def upgrade_key_caps(key, caps): def upgrade_key_caps(key, caps):
@ -779,6 +779,7 @@ def bootstrap_monitor_cluster(secret):
mkdir('/var/run/ceph', owner=ceph_user(), mkdir('/var/run/ceph', owner=ceph_user(),
group=ceph_user(), perms=0o755) group=ceph_user(), perms=0o755)
mkdir(path, owner=ceph_user(), group=ceph_user()) mkdir(path, owner=ceph_user(), group=ceph_user())
mkdir("/var/lib/ceph/tmp", owner=ceph_user(), group=ceph_user())
# end changes for Ceph >= 0.61.3 # end changes for Ceph >= 0.61.3
try: try:
subprocess.check_call(['ceph-authtool', keyring, subprocess.check_call(['ceph-authtool', keyring,
@ -832,7 +833,7 @@ def maybe_zap_journal(journal_dev):
def get_partitions(dev): def get_partitions(dev):
cmd = ['partx', '--raw', '--noheadings', dev] cmd = ['partx', '--raw', '--noheadings', dev]
try: try:
out = subprocess.check_output(cmd).splitlines() out = subprocess.check_output(cmd).decode('utf-8').splitlines()
log("get partitions: {}".format(out), level=DEBUG) log("get partitions: {}".format(out), level=DEBUG)
return out return out
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
@ -942,7 +943,7 @@ def get_running_osds():
"""Returns a list of the pids of the current running OSD daemons""" """Returns a list of the pids of the current running OSD daemons"""
cmd = ['pgrep', 'ceph-osd'] cmd = ['pgrep', 'ceph-osd']
try: try:
result = subprocess.check_output(cmd) result = subprocess.check_output(cmd).decode('utf-8')
return result.split() return result.split()
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return [] return []