mirror of
https://github.com/ceph/ceph
synced 2024-12-24 20:33:27 +00:00
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:
commit
b7df96b8e5
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user