From 77c583ca39f73e00e45e313ccc5ad1a5211d9724 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 21 Aug 2014 18:13:41 -0600 Subject: [PATCH] Check if the VirtualBox COM service is installed on Windows. --- gns3server/modules/dynamips/nodes/c7200.py | 4 ---- gns3server/modules/virtualbox/__init__.py | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/c7200.py b/gns3server/modules/dynamips/nodes/c7200.py index e27a22d0..df942c71 100644 --- a/gns3server/modules/dynamips/nodes/c7200.py +++ b/gns3server/modules/dynamips/nodes/c7200.py @@ -55,10 +55,6 @@ class C7200(Router): if npe != "npe-400": self.npe = npe - if parse_version(hypervisor.version) <= parse_version('0.2.13'): - # work around a bug when rebooting a router with NPE-400 in Dynamips <= 0.2.13 - self.npe = "npe-200" - # 4 sensors with a default temperature of 22C: # sensor 1 = I/0 controller inlet # sensor 2 = I/0 controller outlet diff --git a/gns3server/modules/virtualbox/__init__.py b/gns3server/modules/virtualbox/__init__.py index f086ef5a..f441857a 100644 --- a/gns3server/modules/virtualbox/__init__.py +++ b/gns3server/modules/virtualbox/__init__.py @@ -107,13 +107,20 @@ class VirtualBox(IModule): if sys.platform.startswith("win"): import win32com.client + if win32com.client.gencache.is_readonly is True: # dynamically generate the cache # http://www.py2exe.org/index.cgi/IncludingTypelibs # http://www.py2exe.org/index.cgi/UsingEnsureDispatch win32com.client.gencache.is_readonly = False - win32com.client.gencache.Rebuild() + #win32com.client.gencache.Rebuild() win32com.client.gencache.GetGeneratePath() + + try: + win32com.client.gencache.EnsureDispatch("VirtualBox.VirtualBox") + except: + raise VirtualBoxError("VirtualBox is not installed.") + try: from .vboxapi_py3 import VirtualBoxManager self._vboxmanager = VirtualBoxManager(None, None) @@ -749,7 +756,11 @@ class VirtualBox(IModule): """ if not self._vboxwrapper and not self._vboxmanager: - self._start_vbox_service() + try: + self._start_vbox_service() + except VirtualBoxError as e: + self.send_custom_error(str(e)) + return if self._vboxwrapper: vms = self._vboxwrapper.get_vm_list()