Minimize DNS resolution queries on grains load
Minimize DNS resolution queries on grains load

When grains are loaded, hostname() is called multiple times. The
hostname() function ends up calling socket.getfqdn, which is an
expensive operation if the host is not on the domain (the function times
out). Optimize grains operation to only query getfqdn once. Also , optimize
fqdn_ip4 and fqdn_ipv6 grains to only call socket.getaddrinfo (expensive
operation) if there is a domain.

Signed-off-by: Alejandro del Castillo <c09cbcd73cd5840fe009d82a3ad13af11b4d7b46@ni.com>

saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt