Island: Refactor ReportService.get_scanned

Update ReportService.get_scanned to use repositories instead of services
This commit is contained in:
Kekoa Kaaikala 2022-09-28 17:15:31 +00:00
parent 49c6839c10
commit 8acf2d9e91
1 changed files with 12 additions and 9 deletions

View File

@ -113,20 +113,23 @@ class ReportService:
def get_scanned(): def get_scanned():
formatted_nodes = [] formatted_nodes = []
nodes = ReportService.get_all_displayed_nodes() machines = ReportService.get_all_machines()
for node in nodes: for machine in machines:
# This information should be evident from the map, not sure a table/list is a good way # This information should be evident from the map, not sure a table/list is a good way
# to display it anyways # to display it anyways
nodes_that_can_access_current_node = node["accessible_from_nodes_hostnames"] addresses = [str(iface.ip) for iface in machine.network_interfaces]
accessible_machines = [
m.hostname for m in ReportService.get_accessible_machines(machine)
]
formatted_nodes.append( formatted_nodes.append(
{ {
"label": node["label"], "label": machine.hostname,
"ip_addresses": node["ip_addresses"], "ip_addresses": addresses,
"accessible_from_nodes": nodes_that_can_access_current_node, "accessible_from_nodes": accessible_machines,
"services": node["services"], "services": [],
"domain_name": node["domain_name"], "domain_name": "",
"pba_results": node["pba_results"] if "pba_results" in node else "None", "pba_results": "None",
} }
) )