Merge pull request #15642 from wjwithagen/wip-wjw-freebsd-ceph-disk-zap

ceph_disk/main.py: Allow FreeBSD zap a OSD disk

Reviewed-by: Loic Dachary <loic@dachary.org>
Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-07-05 21:52:29 +08:00 committed by GitHub
commit b7df96b8e5

View File

@ -1532,14 +1532,7 @@ def update_partition(dev, description):
command_check_call(['udevadm', 'settle', '--timeout=600'])
def zap(dev):
"""
Destroy the partition table and content of a given disk.
"""
dev = os.path.realpath(dev)
dmode = os.stat(dev).st_mode
if not stat.S_ISBLK(dmode) or is_partition(dev):
raise Error('not full block device; cannot zap', dev)
def zap_linux(dev):
try:
# Thoroughly wipe all partitions of any traces of
# Filesystems or OSD Journals
@ -1598,13 +1591,42 @@ def zap(dev):
dev,
],
)
update_partition(dev, 'zapped')
except subprocess.CalledProcessError as e:
raise Error(e)
def zap_freebsd(dev):
try:
# For FreeBSD we just need to zap the partition.
command_check_call(
[
'gpart',
'destroy',
'-F',
dev,
],
)
except subprocess.CalledProcessError as e:
raise Error(e)
def zap(dev):
"""
Destroy the partition table and content of a given disk.
"""
dev = os.path.realpath(dev)
dmode = os.stat(dev).st_mode
if not stat.S_ISBLK(dmode) or is_partition(dev):
raise Error('not full block device; cannot zap', dev)
if FREEBSD:
zap_freebsd(dev)
else:
zap_linux(dev)
def adjust_symlink(target, path):
create = True
if os.path.lexists(path):