mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #2251 from UtahDave/add_loopback_to_ip_addrs
Add loopback to ip addrs
This commit is contained in:
commit
a3dc8c925f
@ -311,28 +311,33 @@ def in_subnet(cidr):
|
||||
return False
|
||||
|
||||
|
||||
def ip_addrs():
|
||||
def ip_addrs(include_loopback=False):
|
||||
'''
|
||||
Returns a list of IPv4 addresses assigned to the host. (127.0.0.1 is
|
||||
ignored)
|
||||
ignored, unless 'include_loopback=True' is indicated)
|
||||
'''
|
||||
ret = []
|
||||
ifaces = interfaces()
|
||||
for ipv4_info in ifaces.values():
|
||||
for ipv4 in ipv4_info.get('inet',[]):
|
||||
if ipv4['address'] != '127.0.0.1': ret.append(ipv4['address'])
|
||||
else:
|
||||
if include_loopback: ret.append(ipv4['address'])
|
||||
return ret
|
||||
|
||||
|
||||
def ip_addrs6():
|
||||
def ip_addrs6(include_loopback=False):
|
||||
'''
|
||||
Returns a list of IPv6 addresses assigned to the host. (::1 is ignored)
|
||||
Returns a list of IPv6 addresses assigned to the host. (::1 is ignored,
|
||||
unless 'include_loopback=True' is indicated)
|
||||
'''
|
||||
ret = []
|
||||
ifaces = interfaces()
|
||||
for ipv6_info in ifaces.values():
|
||||
for ipv6 in ipv6_info.get('inet6',[]):
|
||||
if ipv6['address'] != '::1': ret.append(ipv6['address'])
|
||||
else:
|
||||
if include_loopback: ret.append(ipv6['address'])
|
||||
return ret
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user