From f7058b792570f9a2aaa83a55cdf51df8872de02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 11 Jul 2013 22:52:13 -0400 Subject: 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. --- src/lib/Bcfg2/Server/Plugins/NagiosGen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins/NagiosGen.py') 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) -- cgit v1.2.3-1-g7c22