mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-24 15:58:08 +00:00
Merge remote-tracking branch 'origin/2.2' into 2.2
This commit is contained in:
commit
887b32c4bc
@ -108,6 +108,23 @@ class NodeHandler:
|
||||
response.set_status(200)
|
||||
response.json(node)
|
||||
|
||||
@Route.delete(
|
||||
r"/projects/{project_id}/nodes/{node_id}",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
"node_id": "Node UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "Instance deleted",
|
||||
400: "Invalid request",
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Delete a node instance")
|
||||
async def delete(request, response):
|
||||
project = await Controller.instance().get_loaded_project(request.match_info["project_id"])
|
||||
await project.delete_node(request.match_info["node_id"])
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/nodes/start",
|
||||
parameters={
|
||||
@ -291,23 +308,6 @@ class NodeHandler:
|
||||
response.json(node)
|
||||
response.set_status(200)
|
||||
|
||||
@Route.delete(
|
||||
r"/projects/{project_id}/nodes/{node_id}",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
"node_id": "Node UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "Instance deleted",
|
||||
400: "Invalid request",
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Delete a node instance")
|
||||
async def delete(request, response):
|
||||
project = await Controller.instance().get_loaded_project(request.match_info["project_id"])
|
||||
await project.delete_node(request.match_info["node_id"])
|
||||
response.set_status(204)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/nodes/{node_id}/links",
|
||||
parameters={
|
||||
|
@ -92,21 +92,6 @@ class ProjectHandler:
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
response.json(project)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/stats",
|
||||
description="Get a project statistics",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
},
|
||||
status_codes={
|
||||
200: "Project statistics returned",
|
||||
404: "The project doesn't exist"
|
||||
})
|
||||
def get(request, response):
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
response.json(project.stats())
|
||||
|
||||
@Route.put(
|
||||
r"/projects/{project_id}",
|
||||
status_codes={
|
||||
@ -127,6 +112,39 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.json(project)
|
||||
|
||||
@Route.delete(
|
||||
r"/projects/{project_id}",
|
||||
description="Delete a project from disk",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
},
|
||||
status_codes={
|
||||
204: "Changes have been written on disk",
|
||||
404: "The project doesn't exist"
|
||||
})
|
||||
async def delete(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
await project.delete()
|
||||
controller.remove_project(project)
|
||||
response.set_status(204)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/stats",
|
||||
description="Get a project statistics",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
},
|
||||
status_codes={
|
||||
200: "Project statistics returned",
|
||||
404: "The project doesn't exist"
|
||||
})
|
||||
def get(request, response):
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
response.json(project.stats())
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/close",
|
||||
description="Close a project",
|
||||
@ -189,24 +207,6 @@ class ProjectHandler:
|
||||
response.set_status(201)
|
||||
response.json(project)
|
||||
|
||||
@Route.delete(
|
||||
r"/projects/{project_id}",
|
||||
description="Delete a project from disk",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
},
|
||||
status_codes={
|
||||
204: "Changes have been written on disk",
|
||||
404: "The project doesn't exist"
|
||||
})
|
||||
async def delete(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
await project.delete()
|
||||
controller.remove_project(project)
|
||||
response.set_status(204)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/notifications",
|
||||
description="Receive notifications about projects",
|
||||
|
@ -261,15 +261,19 @@ class WebServer:
|
||||
# Background task started with the server
|
||||
self._app.on_startup.append(self._on_startup)
|
||||
|
||||
resource_options = aiohttp_cors.ResourceOptions(
|
||||
expose_headers="*", allow_headers="*", max_age=0
|
||||
)
|
||||
|
||||
# Allow CORS for this domains
|
||||
cors = aiohttp_cors.setup(self._app, defaults={
|
||||
# Default web server for web gui dev
|
||||
"http://127.0.0.1:8080": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
|
||||
"http://localhost:8080": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
|
||||
"http://127.0.0.1:4200": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
|
||||
"http://localhost:4200": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
|
||||
"http://gns3.github.io": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
|
||||
"https://gns3.github.io": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*")
|
||||
"http://127.0.0.1:8080": resource_options,
|
||||
"http://localhost:8080": resource_options,
|
||||
"http://127.0.0.1:4200": resource_options,
|
||||
"http://localhost:4200": resource_options,
|
||||
"http://gns3.github.io": resource_options,
|
||||
"https://gns3.github.io": resource_options
|
||||
})
|
||||
|
||||
PortManager.instance().console_host = self._host
|
||||
|
Loading…
Reference in New Issue
Block a user