diff --git a/src/middlewared/middlewared/plugins/disk_/availability.py b/src/middlewared/middlewared/plugins/disk_/availability.py index 07a0afeeccb0a..6dc88f98bfc85 100644 --- a/src/middlewared/middlewared/plugins/disk_/availability.py +++ b/src/middlewared/middlewared/plugins/disk_/availability.py @@ -32,7 +32,7 @@ async def details_impl(self, data): in_use_disks_imported = {} for in_use_disk, info in ( await self.middleware.call('zpool.status', {'real_paths': True}) - )['disks'].items(): + )['.disks'].items(): in_use_disks_imported[in_use_disk] = info['pool_name'] in_use_disks_exported = {} diff --git a/src/middlewared/middlewared/plugins/webui/enclosure.py b/src/middlewared/middlewared/plugins/webui/enclosure.py index ea1e2ffe4da13..5697e4db8e11a 100644 --- a/src/middlewared/middlewared/plugins/webui/enclosure.py +++ b/src/middlewared/middlewared/plugins/webui/enclosure.py @@ -55,7 +55,7 @@ def dashboard_impl(self): # work with UI to remove unnecessary ones self.map_disk_details(slot_info, disk_deets) - if pool_info := disks_to_pools['disks'].get(slot_info['dev']): + if pool_info := disks_to_pools['.disks'].get(slot_info['dev']): # now map zpool info self.map_zpool_info(enc['id'], disk_slot, slot_info['dev'], pool_info) diff --git a/src/middlewared/middlewared/plugins/zfs_/pool_status.py b/src/middlewared/middlewared/plugins/zfs_/pool_status.py index d73782e862c02..5d7e795ad6cf6 100644 --- a/src/middlewared/middlewared/plugins/zfs_/pool_status.py +++ b/src/middlewared/middlewared/plugins/zfs_/pool_status.py @@ -81,7 +81,7 @@ def status(self, data): An example of what this returns looks like the following: { - "disks": { + ".disks": { "/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec": { "pool_name": "evo", "disk_status": "ONLINE", @@ -120,7 +120,10 @@ def status(self, data): """ pools = get_zpool_status(data.get('name')) - final = {'disks': dict()} + # Yes, the key is prefixed with a period and is not + # a mistake. A user can name their zpool "disks" + # which would cause a key collision + final = {'.disks': dict()} for pool_name, pool_info in pools.items(): final[pool_name] = dict() # We need some normalization for data vdev here @@ -136,6 +139,6 @@ def status(self, data): # this was designed, primarily, for the # `webui.enclosure.dashboard` endpoint final[pool_name][vdev_type] = info - final['disks'].update(info) + final['.disks'].update(info) return final diff --git a/tests/api2/test_zpool_status.py b/tests/api2/test_zpool_status.py index 9ca5e462ff4ee..88a1df0648718 100644 --- a/tests/api2/test_zpool_status.py +++ b/tests/api2/test_zpool_status.py @@ -24,7 +24,7 @@ def get_disk_uuid_mapping(unused_disks): def get_pool_status(unused_disks, real_paths=False, replaced=False): disk_uuid_mapping = get_disk_uuid_mapping(unused_disks) return { - 'disks': { + '.disks': { 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 'ONLINE',