mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Do not attempt to get fqdn_ip{4,6} grains when ipv{4,6} grains are empty
This prevents DNS resolution issues from causing ``salt-call --local`` to hang. Resolves #32719.
This commit is contained in:
parent
67d8dd0fd0
commit
730a077041
@ -1466,58 +1466,30 @@ def append_domain():
|
||||
return grain
|
||||
|
||||
|
||||
def ip4():
|
||||
def ip_fqdn():
|
||||
'''
|
||||
Return a list of ipv4 addrs
|
||||
Return ip address and FQDN grains
|
||||
'''
|
||||
|
||||
if salt.utils.is_proxy():
|
||||
return {}
|
||||
|
||||
return {'ipv4': salt.utils.network.ip_addrs(include_loopback=True)}
|
||||
ret = {}
|
||||
ret['ipv4'] = salt.utils.network.ip_addrs(include_loopback=True)
|
||||
ret['ipv6'] = salt.utils.network.ip_addrs6(include_loopback=True)
|
||||
|
||||
_fqdn = hostname()['fqdn']
|
||||
for socket_type, ipv_num in ((socket.AF_INET, '4'), (socket.AF_INET6, '6')):
|
||||
key = 'fqdn_ip' + ipv_num
|
||||
if not ret['ipv' + ipv_num]:
|
||||
ret[key] = []
|
||||
else:
|
||||
try:
|
||||
info = socket.getaddrinfo(_fqdn, None, socket_type)
|
||||
ret[key] = list(set(item[4][0] for item in info))
|
||||
except socket.error:
|
||||
ret[key] = []
|
||||
|
||||
def fqdn_ip4():
|
||||
'''
|
||||
Return a list of ipv4 addrs of fqdn
|
||||
'''
|
||||
|
||||
if salt.utils.is_proxy():
|
||||
return {}
|
||||
|
||||
try:
|
||||
info = socket.getaddrinfo(hostname()['fqdn'], None, socket.AF_INET)
|
||||
addrs = list(set(item[4][0] for item in info))
|
||||
except socket.error:
|
||||
addrs = []
|
||||
return {'fqdn_ip4': addrs}
|
||||
|
||||
|
||||
def ip6():
|
||||
'''
|
||||
Return a list of ipv6 addrs
|
||||
'''
|
||||
|
||||
if salt.utils.is_proxy():
|
||||
return {}
|
||||
|
||||
return {'ipv6': salt.utils.network.ip_addrs6(include_loopback=True)}
|
||||
|
||||
|
||||
def fqdn_ip6():
|
||||
'''
|
||||
Return a list of ipv6 addrs of fqdn
|
||||
'''
|
||||
|
||||
if salt.utils.is_proxy():
|
||||
return {}
|
||||
|
||||
try:
|
||||
info = socket.getaddrinfo(hostname()['fqdn'], None, socket.AF_INET6)
|
||||
addrs = list(set(item[4][0] for item in info))
|
||||
except socket.error:
|
||||
addrs = []
|
||||
return {'fqdn_ip6': addrs}
|
||||
return ret
|
||||
|
||||
|
||||
def ip_interfaces():
|
||||
|
Loading…
Reference in New Issue
Block a user