1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-23 23:38:21 +00:00

Check for NPF service on Windows.

This commit is contained in:
grossmj 2016-03-25 19:53:36 -06:00
parent 58a360e535
commit fa58b1f81c
3 changed files with 18 additions and 5 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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"