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.
master
Alejandro Sirgo Rica 2024-10-11 11:32:14 +02:00
parent bcffdff135
commit 66b663e051
1 changed files with 22 additions and 11 deletions

View File

@ -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']}"
choice = (item_key,
f"{os['name']} (Disk:{os['disk']}, Partition:{os['partition']})")
form.os.choices.append(choice)
if item_key in os_groups:
os_groups[item_key].append(ip)
else:
os_groups[item_key] = [ip]
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())