From 24300b2502568408f441b03b5cf701380e2d48e6 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 21 Mar 2015 22:27:40 -0600 Subject: [PATCH] Adds project id when requesting UDP port. --- gns3server/handlers/api/network_handler.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gns3server/handlers/api/network_handler.py b/gns3server/handlers/api/network_handler.py index e84cdb4f..8eb5a364 100644 --- a/gns3server/handlers/api/network_handler.py +++ b/gns3server/handlers/api/network_handler.py @@ -17,6 +17,7 @@ from ...web.route import Route from ...modules.port_manager import PortManager +from ...modules.project_manager import ProjectManager from ...utils.interfaces import interfaces @@ -24,15 +25,21 @@ class NetworkHandler: @classmethod @Route.post( - r"/ports/udp", + r"/projects/{project_id}/ports/udp", + parameters={ + "project_id": "The UUID of the project", + }, status_codes={ 201: "UDP port allocated", + 404: "The project doesn't exist" }, description="Allocate an UDP port on the server") def allocate_udp_port(request, response): + pm = ProjectManager.instance() + project = pm.get_project(request.match_info["project_id"]) m = PortManager.instance() - udp_port = m.get_free_udp_port() + udp_port = m.get_free_udp_port(project) response.set_status(201) response.json({"udp_port": udp_port})