mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-24 15:58:08 +00:00
Return link object when start capturing
This commit is contained in:
parent
76b2ca2bc0
commit
92d1594afd
@ -63,10 +63,11 @@ class LinkHandler:
|
||||
"link_id": "UUID of the link"
|
||||
},
|
||||
status_codes={
|
||||
204: "Capture started",
|
||||
201: "Capture started",
|
||||
400: "Invalid request"
|
||||
},
|
||||
input=LINK_CAPTURE_SCHEMA,
|
||||
output=LINK_OBJECT_SCHEMA,
|
||||
description="Start capture on a link instance. By default we consider it as an ethernet link")
|
||||
def start_capture(request, response):
|
||||
|
||||
@ -74,7 +75,8 @@ class LinkHandler:
|
||||
project = controller.getProject(request.match_info["project_id"])
|
||||
link = project.getLink(request.match_info["link_id"])
|
||||
yield from link.start_capture(data_link_type=request.json.get("data_link_type", "DLT_EN10MB"), capture_file_name=request.json.get("capture_file_name"))
|
||||
response.set_status(204)
|
||||
response.set_status(201)
|
||||
response.json(link)
|
||||
|
||||
@classmethod
|
||||
@Route.post(
|
||||
@ -84,7 +86,7 @@ class LinkHandler:
|
||||
"link_id": "UUID of the link"
|
||||
},
|
||||
status_codes={
|
||||
204: "Capture stopped",
|
||||
201: "Capture stopped",
|
||||
400: "Invalid request"
|
||||
},
|
||||
description="Stop capture on a link instance")
|
||||
@ -94,7 +96,8 @@ class LinkHandler:
|
||||
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)
|
||||
response.set_status(201)
|
||||
response.json(link)
|
||||
|
||||
@classmethod
|
||||
@Route.delete(
|
||||
|
@ -83,7 +83,7 @@ def test_start_capture(http_controller, tmpdir, project, compute, async_run):
|
||||
with asyncio_patch("gns3server.controller.link.Link.start_capture") as mock:
|
||||
response = http_controller.post("/projects/{}/links/{}/start_capture".format(project.id, link.id), example=True)
|
||||
assert mock.called
|
||||
assert response.status == 204
|
||||
assert response.status == 201
|
||||
|
||||
|
||||
def test_stop_capture(http_controller, tmpdir, project, compute, async_run):
|
||||
@ -92,7 +92,7 @@ def test_stop_capture(http_controller, tmpdir, project, compute, async_run):
|
||||
with asyncio_patch("gns3server.controller.link.Link.stop_capture") as mock:
|
||||
response = http_controller.post("/projects/{}/links/{}/stop_capture".format(project.id, link.id), example=True)
|
||||
assert mock.called
|
||||
assert response.status == 204
|
||||
assert response.status == 201
|
||||
|
||||
|
||||
def test_pcap(http_controller, tmpdir, project, compute, async_run):
|
||||
|
Loading…
Reference in New Issue
Block a user