mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
parent
6e5e9e3df9
commit
ecfa89cba8
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user