summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-11 11:32:14 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-11 12:07:20 +0200
commit66b663e0511b958041975568574afb3764d5a951 (patch)
tree3ec2f297b94ae29d43c18d04b8be9f7bb5a01ea2
parentbcffdff1358ce4d7a7d26e84f19aca29f27687df (diff)
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.
-rw-r--r--ogcp/views.py33
1 files 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())