"""
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
],
)
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:
[
'/usr/local/etc/rc.d/ceph stop osd.{osd_id}'
.format(osd_id=osd_id),
- 'stop',
],
)
else:
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):
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