mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
VirtualBox packet capture.
This commit is contained in:
parent
d499402491
commit
2a3b37a3bd
@ -35,7 +35,7 @@ class Config(object):
|
||||
"""
|
||||
Configuration file management using configparser.
|
||||
|
||||
:params files: Array of configuration files (optionnal)
|
||||
:params files: Array of configuration files (optional)
|
||||
"""
|
||||
|
||||
def __init__(self, files=None):
|
||||
@ -45,7 +45,7 @@ class Config(object):
|
||||
# Monitor configuration files for changes
|
||||
self._watched_files = {}
|
||||
|
||||
# Override config from commande even if modify the config file and live reload it.
|
||||
# Override config from command line even if we modify the config file and live reload it.
|
||||
self._override_config = {}
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
|
@ -297,7 +297,7 @@ class VirtualBoxHandler:
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/virtualbox/{vm_id}/capture/{adapter_id:\d+}/start",
|
||||
r"/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/start_capture",
|
||||
parameters={
|
||||
"project_id": "UUID for the project",
|
||||
"vm_id": "UUID for the instance",
|
||||
@ -315,12 +315,12 @@ class VirtualBoxHandler:
|
||||
vbox_manager = VirtualBox.instance()
|
||||
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
||||
adapter_id = int(request.match_info["adapter_id"])
|
||||
pcap_file_path = os.path.join(vm.project.capture_working_directory(), request.json["filename"])
|
||||
pcap_file_path = os.path.join(vm.project.capture_working_directory(), request.json["capture_file_name"])
|
||||
vm.start_capture(adapter_id, pcap_file_path)
|
||||
response.json({"pcap_file_path": pcap_file_path})
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/virtualbox/{vm_id}/capture/{adapter_id:\d+}/stop",
|
||||
r"/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/stop_capture",
|
||||
parameters={
|
||||
"project_id": "UUID for the project",
|
||||
"vm_id": "UUID for the instance",
|
||||
|
@ -156,7 +156,12 @@ class BaseManager:
|
||||
|
||||
project = ProjectManager.instance().get_project(project_id)
|
||||
|
||||
# TODO: support for old projects VM with normal IDs.
|
||||
try:
|
||||
if vm_id:
|
||||
legacy_id = int(vm_id)
|
||||
# TODO: support for old projects VM with normal IDs.
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if not vm_id:
|
||||
vm_id = str(uuid4())
|
||||
|
@ -104,7 +104,7 @@ class Project:
|
||||
def location(self, location):
|
||||
|
||||
if location != self._location and self._config().get("local", False) is False:
|
||||
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modifiy the project directory location")
|
||||
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location")
|
||||
|
||||
self._location = location
|
||||
|
||||
@ -118,7 +118,7 @@ class Project:
|
||||
|
||||
if hasattr(self, "_path"):
|
||||
if path != self._path and self._config().get("local", False) is False:
|
||||
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modifiy the project directory location")
|
||||
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location")
|
||||
|
||||
self._path = path
|
||||
self._update_temporary_file()
|
||||
|
@ -169,14 +169,14 @@ VBOX_CAPTURE_SCHEMA = {
|
||||
"description": "Request validation to start a packet capture on a VirtualBox VM instance port",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"capture_filename": {
|
||||
"capture_file_name": {
|
||||
"description": "Capture file name",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"required": ["capture_filename"]
|
||||
"required": ["capture_file_name"]
|
||||
}
|
||||
|
||||
VBOX_OBJECT_SCHEMA = {
|
||||
|
Loading…
Reference in New Issue
Block a user