diff --git a/src/aleph/vm/orchestrator/supervisor.py b/src/aleph/vm/orchestrator/supervisor.py index b8f3061f..646f3819 100644 --- a/src/aleph/vm/orchestrator/supervisor.py +++ b/src/aleph/vm/orchestrator/supervisor.py @@ -34,6 +34,7 @@ about_login, debug_haproxy, list_executions, + list_executions_resources, list_executions_v2, notify_allocation, operate_reserve_resources, @@ -128,6 +129,7 @@ def setup_webapp(pool: VmPool | None): web.get("/about/login", about_login), web.get("/about/executions/list", list_executions), web.get("/v2/about/executions/list", list_executions_v2), + web.get("/about/executions/resources", list_executions_resources), web.get("/about/executions/details", about_executions), web.get("/about/executions/records", about_execution_records), web.get("/about/usage/system", about_system_usage), diff --git a/src/aleph/vm/orchestrator/views/__init__.py b/src/aleph/vm/orchestrator/views/__init__.py index a964b72a..336cdda5 100644 --- a/src/aleph/vm/orchestrator/views/__init__.py +++ b/src/aleph/vm/orchestrator/views/__init__.py @@ -228,6 +228,36 @@ async def list_executions_v2(request: web.Request) -> web.Response: ) +@cors_allow_all +async def list_executions_resources(request: web.Request) -> web.Response: + """List all executions with detail on their resource usage""" + pool: VmPool = request.app["vm_pool"] + + return web.json_response( + { + item_hash: { + "networking": ( + { + "ipv4_network": execution.vm.tap_interface.ip_network, + "host_ipv4": pool.network.host_ipv4, + "ipv6_network": execution.vm.tap_interface.ipv6_network, + "ipv6_ip": execution.vm.tap_interface.guest_ipv6.ip, + "ipv4_ip": execution.vm.tap_interface.guest_ip.ip, + "mapped_ports": execution.mapped_ports, + } + if execution.vm and execution.vm.tap_interface + else {} + ), + "status": execution.times, + "message": execution.message, + "resources": execution.resources, + } + for item_hash, execution in pool.executions.items() + }, + dumps=dumps_for_json, + ) + + @cors_allow_all async def about_config(request: web.Request) -> web.Response: authenticate_request(request)