From 66b663e0511b958041975568574afb3764d5a951 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 11 Oct 2024 11:32:14 +0200 Subject: views: update Boot OS to consume the new GET /session Add code to handle the consumption of the new GET /session payload from ogServer and ignore partitions with 'unknown' content. --- ogcp/views.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 8a7463a..d22cc23 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1300,8 +1300,14 @@ def action_session(): valid_ips = [] excluded_ips = [] - for os, ip in zip(sessions, ips): - if os['disk'] == int(disk) and os['partition'] == int(partition) and os['name'] == os_name: + for client_sessions in sessions: + ip = client_sessions['addr'] + os_found = False + for p_data in client_sessions['partitions']: + if p_data['disk'] == int(disk) and p_data['partition'] == int(partition) and p_data['name'] == os_name: + os_found = True + break + if os_found: valid_ips.append(ip) else: excluded_ips.append(ip) @@ -1338,17 +1344,22 @@ def action_session(): return redirect(url_for('commands')) os_groups = {} - for os, ip in zip(sessions, ips_list): - item_key = f"{os['disk']} {os['partition']} {os['name']}" + for client_sessions in sessions: + ip = client_sessions['addr'] + for p_data in client_sessions['partitions']: + if p_data['name'] == 'unknown': + continue - if item_key in os_groups: - os_groups[item_key].append(ip) - else: - os_groups[item_key] = [ip] + item_key = f"{p_data['disk']} {p_data['partition']} {p_data['name']}" + + if item_key in os_groups: + os_groups[item_key].append(ip) + else: + os_groups[item_key] = [ip] - choice = (item_key, - f"{os['name']} (Disk:{os['disk']}, Partition:{os['partition']})") - form.os.choices.append(choice) + choice = (item_key, + f"{p_data['name']} (Disk:{p_data['disk']}, Partition:{p_data['partition']})") + form.os.choices.append(choice) scopes, clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items()) -- cgit v1.2.3-18-g5258