1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

VirtualBox packet capture.

This commit is contained in:
grossmj 2015-02-08 14:44:56 -07:00
parent d499402491
commit 2a3b37a3bd
5 changed files with 15 additions and 10 deletions

View File

@ -35,7 +35,7 @@ class Config(object):
""" """
Configuration file management using configparser. Configuration file management using configparser.
:params files: Array of configuration files (optionnal) :params files: Array of configuration files (optional)
""" """
def __init__(self, files=None): def __init__(self, files=None):
@ -45,7 +45,7 @@ class Config(object):
# Monitor configuration files for changes # Monitor configuration files for changes
self._watched_files = {} 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 = {} self._override_config = {}
if sys.platform.startswith("win"): if sys.platform.startswith("win"):

View File

@ -297,7 +297,7 @@ class VirtualBoxHandler:
response.set_status(204) response.set_status(204)
@Route.post( @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={ parameters={
"project_id": "UUID for the project", "project_id": "UUID for the project",
"vm_id": "UUID for the instance", "vm_id": "UUID for the instance",
@ -315,12 +315,12 @@ class VirtualBoxHandler:
vbox_manager = VirtualBox.instance() vbox_manager = VirtualBox.instance()
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"]) 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"]) 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) vm.start_capture(adapter_id, pcap_file_path)
response.json({"pcap_file_path": pcap_file_path}) response.json({"pcap_file_path": pcap_file_path})
@Route.post( @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={ parameters={
"project_id": "UUID for the project", "project_id": "UUID for the project",
"vm_id": "UUID for the instance", "vm_id": "UUID for the instance",

View File

@ -156,7 +156,12 @@ class BaseManager:
project = ProjectManager.instance().get_project(project_id) 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: if not vm_id:
vm_id = str(uuid4()) vm_id = str(uuid4())

View File

@ -104,7 +104,7 @@ class Project:
def location(self, location): def location(self, location):
if location != self._location and self._config().get("local", False) is False: 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 self._location = location
@ -118,7 +118,7 @@ class Project:
if hasattr(self, "_path"): if hasattr(self, "_path"):
if path != self._path and self._config().get("local", False) is False: 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._path = path
self._update_temporary_file() self._update_temporary_file()

View File

@ -169,14 +169,14 @@ VBOX_CAPTURE_SCHEMA = {
"description": "Request validation to start a packet capture on a VirtualBox VM instance port", "description": "Request validation to start a packet capture on a VirtualBox VM instance port",
"type": "object", "type": "object",
"properties": { "properties": {
"capture_filename": { "capture_file_name": {
"description": "Capture file name", "description": "Capture file name",
"type": "string", "type": "string",
"minLength": 1, "minLength": 1,
}, },
}, },
"additionalProperties": False, "additionalProperties": False,
"required": ["capture_filename"] "required": ["capture_file_name"]
} }
VBOX_OBJECT_SCHEMA = { VBOX_OBJECT_SCHEMA = {