Merge pull request #6410 from Vicente-Cheng/ceph-disk-list-plain-single-failure

ceph-disk: get Nonetype when ceph-disk list with --format plain on single device.

Reviewed-by: Loic Dachary <ldachary@redhat.com>
This commit is contained in:
Loic Dachary 2015-11-03 08:05:19 +01:00
commit cab3d3f2f2
2 changed files with 10 additions and 4 deletions

View File

@ -2738,6 +2738,8 @@ def list_format_dev_plain(dev, devices=[], prefix=''):
desc = ['ceph data (dmcrypt %s)' % dmcrypt['type'], 'not currently mapped']
elif len(dmcrypt['holders']) == 1:
holder = '/dev/' + dmcrypt['holders'][0]
# re-list with the dm-x path
devices = list_devices([holder])
def lookup_dev(devices, path):
for device in devices:
if device['path'] == path:
@ -2851,8 +2853,8 @@ def list_dev(dev, uuid_map, journal_map):
return info
def list_devices(args):
partmap = list_all_partitions(args.path)
def list_devices(path):
partmap = list_all_partitions(path)
uuid_map = {}
journal_map = {}
@ -2912,7 +2914,7 @@ def list_devices(args):
return devices
def main_list(args):
devices = list_devices(args)
devices = list_devices(args.path)
if args.format == 'json':
print json.dumps(devices)
else:

View File

@ -136,7 +136,11 @@ class TestCephDisk(object):
'ptype': ptype,
'state': 'prepared',
}
out = ceph_disk.list_format_dev_plain(dev, devices)
with patch.multiple(
ceph_disk,
list_devices=lambda path: devices,
):
out = ceph_disk.list_format_dev_plain(dev, devices)
assert 'data' in out
assert 'dmcrypt' in out
assert type in out