Method for start / stop capture on a link

Ref https://github.com/GNS3/gns3-gui/issues/1117
This commit is contained in:
Julien Duponchelle
2016-04-21 12:14:09 +02:00
parent 78a9785819
commit 04a1b2df3b
9 changed files with 230 additions and 18 deletions

View File

@ -52,6 +52,46 @@ class LinkHandler:
response.set_status(201)
response.json(link)
@classmethod
@Route.post(
r"/projects/{project_id}/links/{link_id}/start_capture",
parameters={
"project_id": "UUID for the project",
"link_id": "UUID of the link"
},
status_codes={
204: "Capture started",
400: "Invalid request"
},
description="Start capture on a link instance")
def start_capture(request, response):
controller = Controller.instance()
project = controller.getProject(request.match_info["project_id"])
link = project.getLink(request.match_info["link_id"])
yield from link.start_capture()
response.set_status(204)
@classmethod
@Route.post(
r"/projects/{project_id}/links/{link_id}/stop_capture",
parameters={
"project_id": "UUID for the project",
"link_id": "UUID of the link"
},
status_codes={
204: "Capture stopped",
400: "Invalid request"
},
description="Stop capture on a link instance")
def stop_capture(request, response):
controller = Controller.instance()
project = controller.getProject(request.match_info["project_id"])
link = project.getLink(request.match_info["link_id"])
yield from link.stop_capture()
response.set_status(204)
@classmethod
@Route.delete(
r"/projects/{project_id}/links/{link_id}",