mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
commit
aaebae48ea
@ -370,18 +370,34 @@ def win_interfaces():
|
||||
ifaces[iface.Description]['hwaddr'] = iface.MACAddress
|
||||
if iface.IPEnabled:
|
||||
ifaces[iface.Description]['up'] = True
|
||||
ifaces[iface.Description]['inet'] = []
|
||||
for ip in iface.IPAddress:
|
||||
item = {}
|
||||
item['broadcast'] = ''
|
||||
try:
|
||||
item['broadcast'] = iface.DefaultIPGateway[0]
|
||||
except Exception:
|
||||
pass
|
||||
item['netmask'] = iface.IPSubnet[0]
|
||||
item['label'] = iface.Description
|
||||
item['address'] = ip
|
||||
ifaces[iface.Description]['inet'].append(item)
|
||||
if '.' in ip:
|
||||
if 'inet' not in ifaces[iface.Description]:
|
||||
ifaces[iface.Description]['inet'] = []
|
||||
item = {'address': ip,
|
||||
'label': iface.Description}
|
||||
if iface.DefaultIPGateway:
|
||||
broadcast = next(( i for i in iface.DefaultIPGateway if '.' in i ), '')
|
||||
if broadcast:
|
||||
item['broadcast'] = broadcast
|
||||
if iface.IPSubnet:
|
||||
netmask = next(( i for i in iface.IPSubnet if '.' in i ), '')
|
||||
if netmask:
|
||||
item['netmask'] = netmask
|
||||
ifaces[iface.Description]['inet'].append(item)
|
||||
if ':' in ip:
|
||||
if 'inet6' not in ifaces[iface.Description]:
|
||||
ifaces[iface.Description]['inet6'] = []
|
||||
item = {'address': ip}
|
||||
if iface.DefaultIPGateway:
|
||||
broadcast = next(( i for i in iface.DefaultIPGateway if ':' in i ), '')
|
||||
if broadcast:
|
||||
item['broadcast'] = broadcast
|
||||
if iface.IPSubnet:
|
||||
netmask = next(( i for i in iface.IPSubnet if ':' in i ), '')
|
||||
if netmask:
|
||||
item['netmask'] = netmask
|
||||
ifaces[iface.Description]['inet6'].append(item)
|
||||
else:
|
||||
ifaces[iface.Description]['up'] = False
|
||||
return ifaces
|
||||
|
Loading…
Reference in New Issue
Block a user