be more careful when intializing disks by checking for the ceph UUID in the GPT

This commit is contained in:
Paul Collins 2012-10-05 22:53:28 +13:00
parent bb478f29b8
commit bcaa44a719
3 changed files with 22 additions and 4 deletions

View File

@ -57,3 +57,15 @@ def add_bootstrap_hint(peer):
if os.path.exists(asok):
# Ignore any errors for this call
subprocess.call(cmd)
def is_osd_disk(dev):
try:
info = subprocess.check_output(['sgdisk', '-i', '1', dev])
info = info.split("\n")
for line in info:
if line.startswith('Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'):
return True
except subprocess.CalledProcessError:
pass
return False

View File

@ -133,12 +133,18 @@ def osdize(dev):
# XXX hack for instances
subprocess.call(['umount', '/mnt'])
if ceph.is_osd_disk(dev):
utils.juju_log('INFO',
'Looks like {} is already an OSD, skipping.'.format(dev))
return
if subprocess.call(['grep', '-wqs', dev + '1', '/proc/mounts']) == 0:
utils.juju_log('INFO',
'Looks like {} is in use, skipping.'.format(dev))
else:
if os.path.exists(dev):
subprocess.call(['ceph-disk-prepare', dev])
return
if os.path.exists(dev):
subprocess.call(['ceph-disk-prepare', dev])
def mon_relation():

View File

@ -1 +1 @@
57
65