summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Graber <stgraber@ubuntu.com>2013-07-11 22:52:13 -0400
committerStéphane Graber <stgraber@ubuntu.com>2013-07-11 23:06:11 -0400
commitf7058b792570f9a2aaa83a55cdf51df8872de02e (patch)
tree8a59158b38c6daaeb0bcb5b693440222a1d3145d
parent4c3706627593e3d88604320d5c74c57ca4da1012 (diff)
downloadbcfg2-f7058b792570f9a2aaa83a55cdf51df8872de02e.tar.gz
bcfg2-f7058b792570f9a2aaa83a55cdf51df8872de02e.tar.bz2
bcfg2-f7058b792570f9a2aaa83a55cdf51df8872de02e.zip
Replace use of gethostbyname by getaddrinfo
This replaces the remaining gethostbyname() call by the equivalent getaddrinfo() call required to properly cope with hosts being only reachable over IPv6.
-rw-r--r--src/lib/Bcfg2/Server/Plugins/NagiosGen.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
index 9603cd518..dcd495d77 100644
--- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
+++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
@@ -39,8 +39,8 @@ class NagiosGen(Plugin, Generator):
def createhostconfig(self, entry, metadata):
"""Build host specific configuration file."""
try:
- host_address = socket.gethostbyname(metadata.hostname)
- except socket.gaierror:
+ host_address = socket.getaddrinfo(metadata.hostname, None)[0][4][0]
+ except socket.error:
self.logger.error()
raise PluginExecutionError("Failed to find IP address for %s" %
metadata.hostname)