return False
-DEFAULT_FS_TYPE = 'xfs'
SYSFS = '/sys'
if platform.system() == 'FreeBSD':
FREEBSD = True
+ DEFAULT_FS_TYPE = 'zfs'
PROCDIR = '/compat/linux/proc'
+ # FreeBSD does not have blockdevices any more
+ BLOCKDIR = '/dev'
else:
FREEBSD = False
+ DEFAULT_FS_TYPE = 'xfs'
PROCDIR = '/proc'
+ BLOCKDIR = '/sys/block'
"""
OSD STATUS Definition
# that user_xattr helped
ext4='noatime,user_xattr',
xfs='noatime,inode64',
- zfs='atime=off',
)
MKFS_ARGS = dict(
'-f',
'-i', 'size=2048',
],
+ zfs=[
+ '-o', 'atime=off'
+ ],
)
INIT_SYSTEMS = [
executables *will* be found and will error nicely otherwise.
This returns the output of the command and the return code of the
- process in a tuple: (output, returncode).
+ process in a tuple: (stdout, stderr, returncode).
"""
arguments = list(map(_bytes2str, _get_command_executable(arguments)))
distro = platform.system()
release = platform.version().split()[1]
codename = platform.version().split()[3]
- version = platform.version().split('-')[0]
+ version = platform.version().split('-')[0][:-1]
major_version = version.split('.')[0]
major, minor = release.split('.')
else:
True if the path is managed by multipath
"""
if FREEBSD:
- return True
+ return False
uuid = get_dm_uuid(dev)
return (uuid and
(re.match('part\d+-mpath-', uuid) or
"""
get device name from path. e.g.::
- /dev/sda -> sdas, /dev/cciss/c0d1 -> cciss!c0d1
+ /dev/sda -> sda, /dev/cciss/c0d1 -> cciss!c0d1
a device "name" is something like::
partname = get_partition_mpath(dev, pnum)
else:
name = get_dev_name(os.path.realpath(dev))
- sys_entry = os.path.join('/sys/block', name)
+ sys_entry = os.path.join(BLOCKDIR, name)
error_msg = " in %s" % sys_entry
for f in os.listdir(sys_entry):
if f.startswith(name) and f.endswith(str(pnum)):
Return a list of devices and partitions
"""
if not FREEBSD:
- names = os.listdir('/sys/block')
+ names = os.listdir(BLOCKDIR)
dev_part_list = {}
for name in names:
# /dev/fd0 may hang http://tracker.ceph.com/issues/6827
raise Error('not a block device', dev)
name = get_dev_name(dev)
- if os.path.exists(os.path.join('/sys/block', name)):
+ if os.path.exists(os.path.join(BLOCKDIR, name)):
return False
# make sure it is a partition of something else
raise Error('ceph osd stop failed', e)
-def detect_fstype(
- dev,
-):
- fstype = _check_output(
- args=[
- '/sbin/blkid',
- # we don't want stale cached results
- '-p',
- '-s', 'TYPE',
- '-o', 'value',
- '--',
- dev,
- ],
- )
+def detect_fstype(dev):
+ if FREEBSD:
+ fstype = _check_output(
+ args=[
+ 'fstyp',
+ '-u',
+ dev,
+ ],
+ )
+ else:
+ fstype = _check_output(
+ args=[
+ '/sbin/blkid',
+ # we don't want stale cached results
+ '-p',
+ '-s', 'TYPE',
+ '-o', 'value',
+ '--',
+ dev,
+ ],
+ )
fstype = must_be_one_line(fstype)
return fstype
def get_dev_fs(dev):
- fscheck, _, _ = command(
- [
- 'blkid',
- '-s',
- 'TYPE',
- dev,
- ],
- )
- if 'TYPE' in fscheck:
- fstype = fscheck.split()[1].split('"')[1]
- return fstype
+ if FREEBSD:
+ fstype, _, ret = command(
+ [
+ 'fstyp',
+ '-u',
+ dev,
+ ],
+ )
+ if ret == 0:
+ return fstype
else:
- return None
+ fscheck, _, _ = command(
+ [
+ 'blkid',
+ '-s',
+ 'TYPE',
+ dev,
+ ],
+ )
+ if 'TYPE' in fscheck:
+ fstype = fscheck.split()[1].split('"')[1]
+ return fstype
+ return None
def split_dev_base_partnum(dev):
'fails.\n (Error: %s)' % e)
raise
lines = out.splitlines()
- for line in lines[2:]:
+ for line in lines[1:]:
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],
+ print(vdevline[0], "ceph data, active, cluster ceph,", elems[1],
"mounted on:", vdevline[1])
else:
print(vdevline[0] + " other, zfs, mounted on: " + vdevline[1])