From 2a3b37a3bd4d28e7ef669bf68ea397d56252b808 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 8 Feb 2015 14:44:56 -0700 Subject: [PATCH] VirtualBox packet capture. --- gns3server/config.py | 4 ++-- gns3server/handlers/virtualbox_handler.py | 6 +++--- gns3server/modules/base_manager.py | 7 ++++++- gns3server/modules/project.py | 4 ++-- gns3server/schemas/virtualbox.py | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gns3server/config.py b/gns3server/config.py index 848ab15d..21e1e5b9 100644 --- a/gns3server/config.py +++ b/gns3server/config.py @@ -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"): diff --git a/gns3server/handlers/virtualbox_handler.py b/gns3server/handlers/virtualbox_handler.py index bbe5661d..97997d3e 100644 --- a/gns3server/handlers/virtualbox_handler.py +++ b/gns3server/handlers/virtualbox_handler.py @@ -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", diff --git a/gns3server/modules/base_manager.py b/gns3server/modules/base_manager.py index 999c2bc3..1a5836bc 100644 --- a/gns3server/modules/base_manager.py +++ b/gns3server/modules/base_manager.py @@ -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()) diff --git a/gns3server/modules/project.py b/gns3server/modules/project.py index 64627805..b3ba2c99 100644 --- a/gns3server/modules/project.py +++ b/gns3server/modules/project.py @@ -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() diff --git a/gns3server/schemas/virtualbox.py b/gns3server/schemas/virtualbox.py index 05c0b5e0..adcfd6eb 100644 --- a/gns3server/schemas/virtualbox.py +++ b/gns3server/schemas/virtualbox.py @@ -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 = {