mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Remove debug print.
This commit is contained in:
parent
8c760f3ccc
commit
65bfb4b907
@ -26,8 +26,12 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Link:
|
class Link:
|
||||||
|
"""
|
||||||
|
Base class for links.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, project):
|
def __init__(self, project):
|
||||||
|
|
||||||
self._id = str(uuid.uuid4())
|
self._id = str(uuid.uuid4())
|
||||||
self._nodes = []
|
self._nodes = []
|
||||||
self._project = project
|
self._project = project
|
||||||
@ -45,6 +49,7 @@ class Link:
|
|||||||
"adapter_number": adapter_number,
|
"adapter_number": adapter_number,
|
||||||
"port_number": port_number
|
"port_number": port_number
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(self._nodes) == 2:
|
if len(self._nodes) == 2:
|
||||||
self._project.controller.notification.emit("link.created", self.__json__())
|
self._project.controller.notification.emit("link.created", self.__json__())
|
||||||
|
|
||||||
@ -53,6 +58,7 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
Create the link
|
Create the link
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -60,6 +66,7 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
Delete the link
|
Delete the link
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -69,6 +76,7 @@ class Link:
|
|||||||
|
|
||||||
:returns: Capture object
|
:returns: Capture object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._capturing = True
|
self._capturing = True
|
||||||
self._capture_file_name = capture_file_name
|
self._capture_file_name = capture_file_name
|
||||||
self._streaming_pcap = asyncio.async(self._start_streaming_pcap())
|
self._streaming_pcap = asyncio.async(self._start_streaming_pcap())
|
||||||
@ -79,6 +87,7 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
Dump a pcap file on disk
|
Dump a pcap file on disk
|
||||||
"""
|
"""
|
||||||
|
|
||||||
stream = yield from self.read_pcap_from_source()
|
stream = yield from self.read_pcap_from_source()
|
||||||
with open(self.capture_file_path, "wb+") as f:
|
with open(self.capture_file_path, "wb+") as f:
|
||||||
while self._capturing:
|
while self._capturing:
|
||||||
@ -96,20 +105,23 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
Stop capture on the link
|
Stop capture on the link
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._capturing = False
|
self._capturing = False
|
||||||
self._project.controller.notification.emit("link.updated", self.__json__())
|
self._project.controller.notification.emit("link.updated", self.__json__())
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def read_pcap_from_source(self):
|
def _read_pcap_from_source(self):
|
||||||
"""
|
"""
|
||||||
Return a FileStream of the Pcap from the compute server
|
Return a FileStream of the Pcap from the compute server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def default_capture_file_name(self):
|
def default_capture_file_name(self):
|
||||||
"""
|
"""
|
||||||
:returns: File name for a capture on this link
|
:returns: File name for a capture on this link
|
||||||
"""
|
"""
|
||||||
|
|
||||||
capture_file_name = "{}_{}-{}_to_{}_{}-{}".format(self._nodes[0]["node"].name,
|
capture_file_name = "{}_{}-{}_to_{}_{}-{}".format(self._nodes[0]["node"].name,
|
||||||
self._nodes[0]["adapter_number"],
|
self._nodes[0]["adapter_number"],
|
||||||
self._nodes[0]["port_number"],
|
self._nodes[0]["port_number"],
|
||||||
@ -131,6 +143,7 @@ class Link:
|
|||||||
"""
|
"""
|
||||||
Get the path of the capture
|
Get the path of the capture
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._capture_file_name:
|
if self._capture_file_name:
|
||||||
return os.path.join(self._project.captures_directory, self._capture_file_name)
|
return os.path.join(self._project.captures_directory, self._capture_file_name)
|
||||||
else:
|
else:
|
||||||
@ -145,7 +158,8 @@ class Link:
|
|||||||
"port_number": side["port_number"]
|
"port_number": side["port_number"]
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
"nodes": res, "link_id": self._id,
|
"nodes": res,
|
||||||
|
"link_id": self._id,
|
||||||
"project_id": self._project.id,
|
"project_id": self._project.id,
|
||||||
"capturing": self._capturing,
|
"capturing": self._capturing,
|
||||||
"capture_file_name": self._capture_file_name,
|
"capture_file_name": self._capture_file_name,
|
||||||
|
@ -153,7 +153,6 @@ class LinkHandler:
|
|||||||
raise aiohttp.web.HTTPNotFound(text="pcap file not found")
|
raise aiohttp.web.HTTPNotFound(text="pcap file not found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print(link.capture_file_path)
|
|
||||||
with open(link.capture_file_path, "rb") as f:
|
with open(link.capture_file_path, "rb") as f:
|
||||||
|
|
||||||
response.content_type = "application/vnd.tcpdump.pcap"
|
response.content_type = "application/vnd.tcpdump.pcap"
|
||||||
|
Loading…
Reference in New Issue
Block a user