Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-128546 / 24.10 / Improvements requested by UI team for new enclosure.dashboard #13622

Merged
merged 2 commits into from Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/middlewared/middlewared/plugins/disk_/availability.py
Expand Up @@ -39,32 +39,36 @@ async def get_unused_impl(self, jp=False):
for in_use_disk in await self.get_exported_disks(i['groups']):
in_use_disks_exported[in_use_disk] = i['name']

enc_info = dict()
for enc in await self.middleware.call('enclosure2.query'):
for slot, info in filter(lambda x: x[1], enc['elements']['Array Device Slot'].items()):
enc_info[info['dev']] = (int(slot), enc['id'])

unused = []
unsupported_md_devices_mapping = await self.middleware.call('disk.get_disks_to_unsupported_md_devices_mapping')
serial_to_disk = defaultdict(list)
for i in await self.middleware.call(
'datastore.query', 'storage.disk', [['disk_expiretime', '=', None]], {'prefix': 'disk_'}
):
for dname, i in (await self.middleware.call('device.get_disks')).items():
if not i['size']:
# seen on an internal system during QA. The disk had actually been spun down
# by OS because it had so many errors so the size was an empty string in our db
# SMART data reported the following for the disk: "device is NOT READY (e.g. spun down, busy)"
continue

i['enclosure_slot'] = enc_info.get(dname, ())
serial_to_disk[(i['serial'], i['lunid'])].append(i)

if i['name'] in in_use_disks_imported:
if dname in in_use_disks_imported:
# exclude disks that are currently in use by imported zpool(s)
continue

# disk is "technically" not "in use" but the zpool is exported
# and can be imported so the disk would be "in use" if the zpool
# was imported so we'll mark this disk specially so that end-user
# can be warned appropriately
i['exported_zpool'] = in_use_disks_exported.get(i['name'])
i['exported_zpool'] = in_use_disks_exported.get(dname)
# User might have unsupported md devices configured and a single disk might have multiple
# partitions which are being used by different md devices so this value will be a list or null
i['unsupported_md_devices'] = unsupported_md_devices_mapping.get(i['name'])
i['unsupported_md_devices'] = unsupported_md_devices_mapping.get(dname)

unused.append(i)

Expand All @@ -77,9 +81,8 @@ async def get_unused_impl(self, jp=False):

# add enclosure information
i['enclosure'] = {}
enc_info = i.pop('enclosure_slot', None)
if enc_info is not None:
i['enclosure'] = {'number': enc_info // 1000, 'slot': enc_info % 1000}
if enc := i.pop('enclosure_slot'):
i['enclosure'].update({'drive_bay_number': enc[0], 'id': enc[1]})

# query partitions for the disk(s) if requested
i['partitions'] = []
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/webui/enclosure.py
Expand Up @@ -49,7 +49,7 @@ def dashboard_impl(self):
slot_info.pop(to_pop)

pool_info = None
slot_info.update(self.disk_detail_dict())
slot_info.update({'drive_bay_number': int(disk_slot), **self.disk_detail_dict()})
if slot_info['dev']:
# map disk details
# NOTE: some of these fields need to be removed
Expand Down