mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
src/ceph-disk/ceph_disk/main.py: Make ceph-disk list work on FreeBSD
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
This commit is contained in:
parent
b2faddfca0
commit
c8fda3f04c
@ -762,13 +762,21 @@ def list_all_partitions():
|
||||
"""
|
||||
Return a list of devices and partitions
|
||||
"""
|
||||
names = os.listdir('/sys/block')
|
||||
dev_part_list = {}
|
||||
for name in names:
|
||||
# /dev/fd0 may hang http://tracker.ceph.com/issues/6827
|
||||
if re.match(r'^fd\d$', name):
|
||||
continue
|
||||
dev_part_list[name] = list_partitions(get_dev_path(name))
|
||||
if not FREEBSD:
|
||||
names = os.listdir('/sys/block')
|
||||
dev_part_list = {}
|
||||
for name in names:
|
||||
# /dev/fd0 may hang http://tracker.ceph.com/issues/6827
|
||||
if re.match(r'^fd\d$', name):
|
||||
continue
|
||||
dev_part_list[name] = list_partitions(get_dev_path(name))
|
||||
else:
|
||||
with open(os.path.join(PROCDIR, "partitions")) as partitions:
|
||||
for line in partitions:
|
||||
columns = line.split()
|
||||
if len(columns) >= 4:
|
||||
name = columns[3]
|
||||
dev_part_list[name] = list_partitions(get_dev_path(name))
|
||||
return dev_part_list
|
||||
|
||||
|
||||
@ -3234,14 +3242,10 @@ def start_daemon(
|
||||
],
|
||||
)
|
||||
elif os.path.exists(os.path.join(path, 'bsdrc')):
|
||||
base_script = '/usr/local/etc/rc.d/ceph'
|
||||
osd_script = '{base} start osd.{osd_id}'.format(
|
||||
base=base_script,
|
||||
osd_id=osd_id
|
||||
)
|
||||
command_check_call(
|
||||
[
|
||||
osd_script,
|
||||
'/usr/local/etc/rc.d/ceph start osd.{osd_id}'
|
||||
.format(osd_id=osd_id),
|
||||
],
|
||||
)
|
||||
else:
|
||||
@ -3315,7 +3319,6 @@ def stop_daemon(
|
||||
[
|
||||
'/usr/local/etc/rc.d/ceph stop osd.{osd_id}'
|
||||
.format(osd_id=osd_id),
|
||||
'stop',
|
||||
],
|
||||
)
|
||||
else:
|
||||
@ -4524,9 +4527,35 @@ def list_devices():
|
||||
return devices
|
||||
|
||||
|
||||
def list_zfs():
|
||||
try:
|
||||
out, err, ret = command(
|
||||
[
|
||||
'zfs',
|
||||
'list',
|
||||
'-o', 'name,mountpoint'
|
||||
]
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
LOG.info('zfs list -o name,mountpoint '
|
||||
'fails.\n (Error: %s)' % e)
|
||||
lines = out.splitlines()
|
||||
for line in lines[2:]:
|
||||
vdevline = line.split()
|
||||
if os.path.exists(os.path.join(vdevline[1], 'active')):
|
||||
elems = os.path.split(vdevline[1])
|
||||
print(vdevline[0], "ceph data, active, cluster ceph,", elems[5],
|
||||
"mounted on:", vdevline[1])
|
||||
else:
|
||||
print(vdevline[0] + " other, zfs, mounted on: " + vdevline[1])
|
||||
|
||||
|
||||
def main_list(args):
|
||||
with activate_lock:
|
||||
main_list_protected(args)
|
||||
if FREEBSD:
|
||||
main_list_freebsd(args)
|
||||
else:
|
||||
main_list_protected(args)
|
||||
|
||||
|
||||
def main_list_protected(args):
|
||||
@ -4553,6 +4582,16 @@ def main_list_protected(args):
|
||||
print(output)
|
||||
|
||||
|
||||
def main_list_freebsd(args):
|
||||
# Currently accomodate only ZFS Filestore partitions
|
||||
# return a list of VDEVs and mountpoints
|
||||
# > zfs list
|
||||
# NAME USED AVAIL REFER MOUNTPOINT
|
||||
# osd0 1.01G 1.32T 1.01G /var/lib/ceph/osd/osd.0
|
||||
# osd1 1.01G 1.32T 1.01G /var/lib/ceph/osd/osd.1
|
||||
list_zfs()
|
||||
|
||||
|
||||
###########################
|
||||
#
|
||||
# Mark devices that we want to suppress activates on with a
|
||||
|
Loading…
Reference in New Issue
Block a user