mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Adding two new grains, one to show only the ipv4 addresses for each interface and another to show only the ipv6 address for each interface.
This commit is contained in:
parent
09596813d9
commit
446c8c8286
@ -1270,6 +1270,54 @@ def ip_interfaces():
|
||||
return {'ip_interfaces': ret}
|
||||
|
||||
|
||||
def ip4_interfaces():
|
||||
'''
|
||||
Provide a dict of the connected interfaces and their ip4 addresses
|
||||
'''
|
||||
# Provides:
|
||||
# ip_interfaces
|
||||
|
||||
if 'proxyminion' in __opts__:
|
||||
return {}
|
||||
|
||||
ret = {}
|
||||
ifaces = salt.utils.network.interfaces()
|
||||
for face in ifaces:
|
||||
iface_ips = []
|
||||
for inet in ifaces[face].get('inet', []):
|
||||
if 'address' in inet:
|
||||
iface_ips.append(inet['address'])
|
||||
for secondary in ifaces[face].get('secondary', []):
|
||||
if 'address' in secondary:
|
||||
iface_ips.append(secondary['address'])
|
||||
ret[face] = iface_ips
|
||||
return {'ip4_interfaces': ret}
|
||||
|
||||
|
||||
def ip6_interfaces():
|
||||
'''
|
||||
Provide a dict of the connected interfaces and their ip6 addresses
|
||||
'''
|
||||
# Provides:
|
||||
# ip_interfaces
|
||||
|
||||
if 'proxyminion' in __opts__:
|
||||
return {}
|
||||
|
||||
ret = {}
|
||||
ifaces = salt.utils.network.interfaces()
|
||||
for face in ifaces:
|
||||
iface_ips = []
|
||||
for inet in ifaces[face].get('inet6', []):
|
||||
if 'address' in inet:
|
||||
iface_ips.append(inet['address'])
|
||||
for secondary in ifaces[face].get('secondary', []):
|
||||
if 'address' in secondary:
|
||||
iface_ips.append(secondary['address'])
|
||||
ret[face] = iface_ips
|
||||
return {'ip6_interfaces': ret}
|
||||
|
||||
|
||||
def hwaddr_interfaces():
|
||||
'''
|
||||
Provide a dict of the connected interfaces and their
|
||||
|
Loading…
Reference in New Issue
Block a user