1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Speed up interfaces listening on Windows

Fix #788
This commit is contained in:
Julien Duponchelle 2016-11-16 12:28:02 +01:00
parent 6e5e9e3df9
commit ecfa89cba8
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -90,13 +90,14 @@ def get_windows_interfaces():
try: try:
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator") locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
service = locator.ConnectServer(".", "root\cimv2") service = locator.ConnectServer(".", "root\cimv2")
network_configs = service.InstancesOf("Win32_NetworkAdapterConfiguration")
# more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx # more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
for adapter in service.InstancesOf("Win32_NetworkAdapter"): for adapter in service.InstancesOf("Win32_NetworkAdapter"):
if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7: if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7:
# adapter is connected or media disconnected # adapter is connected or media disconnected
ip_address = "" ip_address = ""
netmask = "" netmask = ""
for network_config in service.InstancesOf("Win32_NetworkAdapterConfiguration"): for network_config in network_configs:
if network_config.InterfaceIndex == adapter.InterfaceIndex: if network_config.InterfaceIndex == adapter.InterfaceIndex:
if network_config.IPAddress: if network_config.IPAddress:
# get the first IPv4 address only # get the first IPv4 address only