diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index ac5aef26..a1deb920 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -32,7 +32,7 @@ import glob log = logging.getLogger(__name__) -from gns3server.utils.interfaces import get_windows_interfaces, is_interface_up +from gns3server.utils.interfaces import interfaces, is_interface_up from gns3server.utils.asyncio import wait_run_in_executor from pkg_resources import parse_version from uuid import UUID, uuid4 @@ -439,9 +439,9 @@ class Dynamips(BaseManager): ethernet_device = nio_settings["ethernet_device"] if sys.platform.startswith("win"): # replace the interface name by the GUID on Windows - interfaces = get_windows_interfaces() + windows_interfaces = interfaces() npf_interface = None - for interface in interfaces: + for interface in windows_interfaces: if interface["name"] == ethernet_device: npf_interface = interface["id"] if not npf_interface: diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index 879ca934..6ba89b0b 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -26,7 +26,7 @@ import asyncio import tempfile from gns3server.utils.telnet_server import TelnetServer -from gns3server.utils.interfaces import interfaces, get_windows_interfaces +from gns3server.utils.interfaces import interfaces from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation from collections import OrderedDict from .vmware_error import VMwareError @@ -320,7 +320,7 @@ class VMwareVM(BaseVM): yield from self._ubridge_hypervisor.send('bridge add_nio_linux_raw {name} "{interface}"'.format(name=vnet, interface=vmnet_interface)) elif sys.platform.startswith("win"): - windows_interfaces = get_windows_interfaces() + windows_interfaces = interfaces() npf = None source_mac = None for interface in windows_interfaces: diff --git a/gns3server/utils/interfaces.py b/gns3server/utils/interfaces.py index 2ff5cc0a..1f53e2c0 100644 --- a/gns3server/utils/interfaces.py +++ b/gns3server/utils/interfaces.py @@ -163,6 +163,19 @@ def interfaces(): "mac_address": mac_address}) else: try: + import pywintypes + import win32service + import win32serviceutil + + try: + if win32serviceutil.QueryServiceStatus("npf", None)[1] != win32service.SERVICE_RUNNING: + raise aiohttp.web.HTTPInternalServerError(text="The NPF service is not running") + except pywintypes.error as e: + if e[0] == 1060: + raise aiohttp.web.HTTPInternalServerError(text="The NPF service is not installed") + else: + raise aiohttp.web.HTTPInternalServerError(text="Could not check if the NPF service is running: {}".format(e[2])) + results = get_windows_interfaces() except ImportError: message = "pywin32 module is not installed, please install it on the server to get the available interface names"