mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 07:23:47 +02:00
Adds project id when requesting UDP port.
This commit is contained in:
parent
153914bf97
commit
24300b2502
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
from ...web.route import Route
|
from ...web.route import Route
|
||||||
from ...modules.port_manager import PortManager
|
from ...modules.port_manager import PortManager
|
||||||
|
from ...modules.project_manager import ProjectManager
|
||||||
from ...utils.interfaces import interfaces
|
from ...utils.interfaces import interfaces
|
||||||
|
|
||||||
|
|
||||||
@ -24,15 +25,21 @@ class NetworkHandler:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@Route.post(
|
@Route.post(
|
||||||
r"/ports/udp",
|
r"/projects/{project_id}/ports/udp",
|
||||||
|
parameters={
|
||||||
|
"project_id": "The UUID of the project",
|
||||||
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
201: "UDP port allocated",
|
201: "UDP port allocated",
|
||||||
|
404: "The project doesn't exist"
|
||||||
},
|
},
|
||||||
description="Allocate an UDP port on the server")
|
description="Allocate an UDP port on the server")
|
||||||
def allocate_udp_port(request, response):
|
def allocate_udp_port(request, response):
|
||||||
|
|
||||||
|
pm = ProjectManager.instance()
|
||||||
|
project = pm.get_project(request.match_info["project_id"])
|
||||||
m = PortManager.instance()
|
m = PortManager.instance()
|
||||||
udp_port = m.get_free_udp_port()
|
udp_port = m.get_free_udp_port(project)
|
||||||
response.set_status(201)
|
response.set_status(201)
|
||||||
response.json({"udp_port": udp_port})
|
response.json({"udp_port": udp_port})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user