From bad740d32a289801a2df57bdad425225c532db41 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 28 Apr 2015 15:31:00 +0200 Subject: [PATCH 1/7] Fix test on Linux --- tests/modules/test_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/test_manager.py b/tests/modules/test_manager.py index 9adbc888..b75927dd 100644 --- a/tests/modules/test_manager.py +++ b/tests/modules/test_manager.py @@ -109,7 +109,7 @@ def test_get_abs_image_path(qemu, tmpdir): def test_get_relative_image_path(qemu, tmpdir): - os.makedirs(str(tmpdir / "Qemu")) + os.makedirs(str(tmpdir / "QEMU")) path1 = str(tmpdir / "test1.bin") open(path1, 'w+').close() From cc03017739f1baa070ea070b3c47f871a357afc9 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 28 Apr 2015 12:02:21 -0600 Subject: [PATCH 2/7] Cleanup the VirtualBox Media Manager after closing a project. Fixes #145. --- gns3server/modules/virtualbox/__init__.py | 39 +++++++++++++++++++ .../modules/virtualbox/virtualbox_vm.py | 8 ---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/gns3server/modules/virtualbox/__init__.py b/gns3server/modules/virtualbox/__init__.py index 24f2f684..8e7754fb 100644 --- a/gns3server/modules/virtualbox/__init__.py +++ b/gns3server/modules/virtualbox/__init__.py @@ -115,6 +115,45 @@ class VirtualBox(BaseManager): return stdout_data.decode("utf-8", errors="ignore").splitlines() + @asyncio.coroutine + def _find_inaccessible_hdd_files(self): + """ + Finds inaccessible disk files (to clean up the VirtualBox media manager) + """ + + hdds = [] + properties = yield from self.execute("list", ["hdds"]) + flag_inaccessible = False + for prop in properties: + try: + name, value = prop.split(':', 1) + except ValueError: + continue + if name.strip() == "State" and value.strip() == "inaccessible": + flag_inaccessible = True + if flag_inaccessible and name.strip() == "Location": + hdds.append(value.strip()) + flag_inaccessible = False + return reversed(hdds) + + @asyncio.coroutine + def project_closed(self, project): + """ + Called when a project is closed. + + :param project: Project instance + """ + + yield from super().project_closed(project) + hdd_files_to_close = yield from self._find_inaccessible_hdd_files() + for hdd_file in hdd_files_to_close: + log.info("Closing VirtualBox VM disk file {}".format(os.path.basename(hdd_file))) + try: + yield from self.execute("closemedium", ["disk", hdd_file]) + except VirtualBoxError as e: + log.warning("Could not close VirtualBox VM disk file {}: {error}".format(os.path.basename(hdd_file), e)) + continue + @asyncio.coroutine def get_list(self): """ diff --git a/gns3server/modules/virtualbox/virtualbox_vm.py b/gns3server/modules/virtualbox/virtualbox_vm.py index e0a181be..ed1580ab 100644 --- a/gns3server/modules/virtualbox/virtualbox_vm.py +++ b/gns3server/modules/virtualbox/virtualbox_vm.py @@ -321,7 +321,6 @@ class VirtualBoxVM(BaseVM): if self._linked_clone: hdd_table = [] - hdd_files_to_close = [] if os.path.exists(self.working_dir): hdd_files = yield from self._get_all_hdd_files() vm_info = yield from self._get_vm_info() @@ -332,7 +331,6 @@ class VirtualBoxVM(BaseVM): port = match.group(2) device = match.group(3) if value in hdd_files: - hdd_files_to_close.append(value) log.info("VirtualBox VM '{name}' [{id}] detaching HDD {controller} {port} {device}".format(name=self.name, id=self.id, controller=controller, @@ -353,12 +351,6 @@ class VirtualBoxVM(BaseVM): log.info("VirtualBox VM '{name}' [{id}] unregistering".format(name=self.name, id=self.id)) yield from self.manager.execute("unregistervm", [self._name]) - for hdd_file in hdd_files_to_close: - log.info("VirtualBox VM '{name}' [{id}] closing disk {disk}".format(name=self.name, - id=self.id, - disk=os.path.basename(hdd_file))) - yield from self.manager.execute("closemedium", ["disk", hdd_file]) - if hdd_table: try: hdd_info_file = os.path.join(self.working_dir, self._vmname, "hdd_info.json") From 1b4613fbaffe7f7880ab5b9ded7cfb669f776576 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 28 Apr 2015 21:05:08 +0200 Subject: [PATCH 3/7] Version 1.3.2 --- CHANGELOG | 32 ++++++++++++++++++++++++++++++++ gns3server/version.py | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 63391c35..de9e5d3d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,37 @@ # Change Log +## 1.3.2 28/04/2015 + +* Cleanup the VirtualBox Media Manager after closing a project. +* Avoid Cygwin warning with VPCS on Windows. +* Close VirtualBox VM linked clone disks after the VM is unregistered. +* TAP interface support for QEMU VMs. +* Return an explicit error when a NIO type is not supported by a VM. +* Do not erase the IOU config +* Explicit utf-8 decoding. +* Check NIO exists when stopping an IOU capture. +* Fixes c7200 NPE setting. +* Fixes VPCS process termination. +* Catch FileNotFoundError exception in os.getcwd() +* Explicit utf-8 encoding where necessary to avoid Unicode errors on Windows (we require/set an utf-8 locale on other systems). +* Fixes #270. Relative paths management with empty ones. +* New crash report key and doesn't send report for developers +* Catch COM errors when connecting to WMI. +* Don't assume the PATH environment variable exists. +* Use UUIDs instead of the VM names for VirtualBox pipe paths. +* Add --log options for daemon support +* Basic upstart script +* Add qemu-kvm to the list of binary +* Fix IOU licence check flag +* Config paths are not used when updating Dynamips or IOU VM settings. +* Fixes initial-configs that were not restored when opening a project containing IOU VMs. +* Prevent parallel execution of VBox commands +* Fix a crash when in some cases you can't access to VBOX state +* Fix crash if VirtualBox doesn't return API version +* Fix a crash in VirtualBox vm creation +* Allocate random names for Dynamips NIOs. +* Explicitly delete Dynamips NIOs and unmap VCs for ATM and Frame-Relay switches. + ## 1.3.1 11/04/2015 * Release diff --git a/gns3server/version.py b/gns3server/version.py index 136f51bb..4cb4b35d 100644 --- a/gns3server/version.py +++ b/gns3server/version.py @@ -23,5 +23,5 @@ # or negative for a release candidate or beta (after the base version # number has been incremented) -__version__ = "1.3.2.dev1" -__version_info__ = (1, 3, 2, -99) +__version__ = "1.3.2" +__version_info__ = (1, 3, 2, 0) From 461e3ce53f4c020bdcd980127cb0e9d62dbabe83 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 28 Apr 2015 21:49:48 +0200 Subject: [PATCH 4/7] 1.3.3dev1 --- gns3server/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gns3server/version.py b/gns3server/version.py index 4cb4b35d..8214d8ac 100644 --- a/gns3server/version.py +++ b/gns3server/version.py @@ -23,5 +23,5 @@ # or negative for a release candidate or beta (after the base version # number has been incremented) -__version__ = "1.3.2" -__version_info__ = (1, 3, 2, 0) +__version__ = "1.3.3dev1" +__version_info__ = (1, 3, 3, -99) From 0311a0086ef664dde3c23696cfa6d8c7deef0716 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 28 Apr 2015 22:16:15 -0600 Subject: [PATCH 5/7] Fixes typo. --- gns3server/modules/virtualbox/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/modules/virtualbox/__init__.py b/gns3server/modules/virtualbox/__init__.py index 8e7754fb..ce1faece 100644 --- a/gns3server/modules/virtualbox/__init__.py +++ b/gns3server/modules/virtualbox/__init__.py @@ -151,7 +151,7 @@ class VirtualBox(BaseManager): try: yield from self.execute("closemedium", ["disk", hdd_file]) except VirtualBoxError as e: - log.warning("Could not close VirtualBox VM disk file {}: {error}".format(os.path.basename(hdd_file), e)) + log.warning("Could not close VirtualBox VM disk file {}: {}".format(os.path.basename(hdd_file), e)) continue @asyncio.coroutine From e75fbc9d735d68bf42f2ec41c2cd0fab7cb26f78 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 29 Apr 2015 11:15:06 +0200 Subject: [PATCH 6/7] Catch connection reset errors Fix #162 --- gns3server/web/route.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gns3server/web/route.py b/gns3server/web/route.py index 875298f5..f376b820 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -161,6 +161,11 @@ class Route(object): response = Response(request=request, route=route) response.set_status(408) response.json({"message": "Client disconnected", "status": 408}) + except ConnectionResetError: + log.error("Client connection reset") + response = Response(request=request, route=route) + response.set_status(408) + response.json({"message": "Connection reset", "status": 408}) except Exception as e: log.error("Uncaught exception detected: {type}".format(type=type(e)), exc_info=1) response = Response(request=request, route=route) From b9bc73fd0109a6195c714c0e910bcfd0805b2192 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 29 Apr 2015 14:21:02 +0200 Subject: [PATCH 7/7] Do not crash when closing a project if VirtualBox is not accessible Fix #164 --- gns3server/modules/virtualbox/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/virtualbox/__init__.py b/gns3server/modules/virtualbox/__init__.py index ce1faece..94c62435 100644 --- a/gns3server/modules/virtualbox/__init__.py +++ b/gns3server/modules/virtualbox/__init__.py @@ -122,7 +122,12 @@ class VirtualBox(BaseManager): """ hdds = [] - properties = yield from self.execute("list", ["hdds"]) + try: + properties = yield from self.execute("list", ["hdds"]) + # If VirtualBox is not available we have no inaccessible hdd + except VirtualBoxError: + return hdds + flag_inaccessible = False for prop in properties: try: