mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Stream pcap from compute to controller to client
This commit is contained in:
15 files changed
+172
-124
No files matched your search
@@ -125,6 +125,22 @@ class Compute:
|
||||
"connected": self._connected
|
||||
}
|
||||
|
||||
@asyncio.coroutine
|
||||
def streamFile(self, project, path):
|
||||
"""
|
||||
Read file of a project and stream it
|
||||
|
||||
:param project: A project object
|
||||
:param path: The path of the file in the project
|
||||
:returns: A file stream
|
||||
"""
|
||||
|
||||
url = self._getUrl("/projects/{}/stream/{}".format(project.id, path))
|
||||
response = yield from self._session.request("GET", url, auth=self._auth)
|
||||
if response.status == 404:
|
||||
raise aiohttp.web.HTTPNotFound(text="{} not found on compute".format(path))
|
||||
return response.content
|
||||
|
||||
@asyncio.coroutine
|
||||
def httpQuery(self, method, path, data=None):
|
||||
if not self._connected:
|
||||
|
||||
@@ -70,6 +70,13 @@ class Link:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@asyncio.coroutine
|
||||
def read_pcap(self):
|
||||
"""
|
||||
Return a FileStream of the Pcap from the compute node
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def capture_file_name(self):
|
||||
"""
|
||||
:returns: File name for a capture on this link
|
||||
|
||||
@@ -122,3 +122,12 @@ class UDPLink(Link):
|
||||
return vm
|
||||
|
||||
raise aiohttp.web.HTTPConflict(text="Capture is not supported for this link")
|
||||
|
||||
@asyncio.coroutine
|
||||
def read_pcap(self):
|
||||
"""
|
||||
Return a FileStream of the Pcap from the compute node
|
||||
"""
|
||||
if self._capture_vm:
|
||||
compute = self._capture_vm["vm"].compute
|
||||
return compute.streamFile(self._project, "tmp/captures/" + self.capture_file_name())
|
||||
Reference in new issue
Block a user