Validate output of list_logical_volumes

The charm was checking for the zeroth value of the return value of
list_logical_volumes. However, if no logical volumes are found it
returns an empty list.

This change validates that the list has an entry.

Depends-On: I75a6b1dda15dd7c2cece8cfe97b28317b3d5162b
Change-Id: I2d371dae94dca328cf4782a79e85c1c6fd77f547
Closes-Bug: #1819382
This commit is contained in:
David Ames 2019-05-14 13:24:38 -07:00
parent b8f6265158
commit e6086328f4
1 changed files with 6 additions and 3 deletions

View File

@ -1555,7 +1555,7 @@ def _ceph_disk(dev, osd_format, osd_journal, encrypt=False, bluestore=False):
cmd.append(osd_format)
# NOTE(jamespage): enable experimental bluestore support
if cmp_pkgrevno('ceph', '10.2.0') >= 0 and bluestore:
if cmp_pkgrevno('ceph', '12.2.0') >= 0 and bluestore:
cmd.append('--bluestore')
wal = get_devices('bluestore-wal')
if wal:
@ -1567,7 +1567,7 @@ def _ceph_disk(dev, osd_format, osd_journal, encrypt=False, bluestore=False):
cmd.append('--block.db')
least_used_db = find_least_used_utility_device(db)
cmd.append(least_used_db)
elif cmp_pkgrevno('ceph', '12.1.0') >= 0 and not bluestore:
elif cmp_pkgrevno('ceph', '12.2.0') >= 0 and not bluestore:
cmd.append('--filestore')
cmd.append(os.path.realpath(dev))
@ -1692,7 +1692,10 @@ def is_active_bluestore_device(dev):
return False
vg_name = lvm.list_lvm_volume_group(dev)
lv_name = lvm.list_logical_volumes('vg_name={}'.format(vg_name))[0]
try:
lv_name = lvm.list_logical_volumes('vg_name={}'.format(vg_name))[0]
except IndexError:
return False
block_symlinks = glob.glob('/var/lib/ceph/osd/ceph-*/block')
for block_candidate in block_symlinks: