diff --git a/src/middlewared/middlewared/plugins/zfs_/pool_status.py b/src/middlewared/middlewared/plugins/zfs_/pool_status.py index d73782e862c0..4901d2f717e4 100644 --- a/src/middlewared/middlewared/plugins/zfs_/pool_status.py +++ b/src/middlewared/middlewared/plugins/zfs_/pool_status.py @@ -95,47 +95,46 @@ def status(self, data): ] } }, - "evo": { - "spares": {}, - "logs": {}, - "dedup": {}, - "special": {}, - "l2cache": {}, - "data": { - "/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec": { - "pool_name": "evo", - "disk_status": "ONLINE", - "disk_read_errors": 0, - "disk_write_errors": 0, - "disk_checksum_errors": 0, - "vdev_name": "stripe", - "vdev_type": "data", - "vdev_disks": [ - "/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec" - ] - } + "pools": { + "evo": { + "spares": {}, + "logs": {}, + "dedup": {}, + "special": {}, + "l2cache": {}, + "data": { + "/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec": { + "pool_name": "evo", + "disk_status": "ONLINE", + "disk_read_errors": 0, + "disk_write_errors": 0, + "disk_checksum_errors": 0, + "vdev_name": "stripe", + "vdev_type": "data", + "vdev_disks": [ + "/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec" + ] + } + } } - } } """ - pools = get_zpool_status(data.get('name')) - - final = {'disks': dict()} - for pool_name, pool_info in pools.items(): - final[pool_name] = dict() + final = {'disks': dict(), 'pools': dict()} + for pool_name, pool_info in get_zpool_status(data.get('name')).items(): + final['pools'][pool_name] = dict() # We need some normalization for data vdev here pool_info['data'] = pool_info.get('vdevs', {}).get(pool_name, {}).get('vdevs', {}) for vdev_type in ('spares', 'logs', 'dedup', 'special', 'l2cache', 'data'): vdev_members = pool_info.get(vdev_type, {}) if not vdev_members: - final[pool_name][vdev_type] = dict() + final['pools'][pool_name][vdev_type] = dict() continue info = self.status_impl(pool_name, vdev_type, vdev_members, **data) # we key on pool name and disk id because # this was designed, primarily, for the # `webui.enclosure.dashboard` endpoint - final[pool_name][vdev_type] = info + final['pools'][pool_name][vdev_type] = info final['disks'].update(info) return final diff --git a/tests/api2/test_zpool_status.py b/tests/api2/test_zpool_status.py index 9ca5e462ff4e..3951c9f4cd72 100644 --- a/tests/api2/test_zpool_status.py +++ b/tests/api2/test_zpool_status.py @@ -104,117 +104,119 @@ def get_pool_status(unused_disks, real_paths=False, replaced=False): ] } }, - POOL_NAME: { - 'spares': { - f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'AVAIL' if not replaced else 'INUSE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'spares', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' - ] - } - }, - 'logs': { - f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'logs', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}' - ] - } - }, - 'dedup': { - f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'dedup', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}' - ] - } - }, - 'special': { - f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'special', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}' - ] - } - }, - 'l2cache': { - f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'l2cache', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}' - ] - } - }, - 'data': { - f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'stripe', - 'vdev_type': 'data', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}' - ] - } - } if not replaced else { - f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'spare-0', - 'vdev_type': 'data', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}', - f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' - ] + 'pools': { + POOL_NAME: { + 'spares': { + f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'AVAIL' if not replaced else 'INUSE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'spares', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' + ] + } + }, + 'logs': { + f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'logs', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}' + ] + } }, - f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': { - 'pool_name': POOL_NAME, - 'disk_status': 'ONLINE', - 'disk_read_errors': 0, - 'disk_write_errors': 0, - 'disk_checksum_errors': 0, - 'vdev_name': 'spare-0', - 'vdev_type': 'data', - 'vdev_disks': [ - f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}', - f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' - ] + 'dedup': { + f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'dedup', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}' + ] + } }, + 'special': { + f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'special', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}' + ] + } + }, + 'l2cache': { + f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'l2cache', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}' + ] + } + }, + 'data': { + f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'stripe', + 'vdev_type': 'data', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}' + ] + } + } if not replaced else { + f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'spare-0', + 'vdev_type': 'data', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}', + f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' + ] + }, + f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': { + 'pool_name': POOL_NAME, + 'disk_status': 'ONLINE', + 'disk_read_errors': 0, + 'disk_write_errors': 0, + 'disk_checksum_errors': 0, + 'vdev_name': 'spare-0', + 'vdev_type': 'data', + 'vdev_disks': [ + f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}', + f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}' + ] + }, + } } } }