[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Better error messages when getaddrinfo returns only IPv...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv12792/lib/mixminion
Modified Files:
NetUtils.py test.py
Log Message:
Better error messages when getaddrinfo returns only IPv6 addresses, but
we don't support IPv6.
Better log messages on DNS in general.
Index: NetUtils.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/NetUtils.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NetUtils.py 18 Dec 2003 22:55:27 -0000 1.7
+++ NetUtils.py 8 Jan 2004 18:09:49 -0000 1.8
@@ -63,7 +63,17 @@
def getIP(name, preferIP4=PREFER_INET4):
"""Resolve the hostname 'name' and return the 'best' answer. An
answer is either a 3-tuple as returned by getIPs, or a 3-tuple of
- ('NOENT', reason, Time) if no answers were found."""
+ ('NOENT', reason, Time) if no answers were found.
+
+ If both IPv4 and IPv6 addresses are found, return an IPv4 address
+ iff preferIPv4 is true.
+
+ If this host does not support IPv6, never return an IPv6 address;
+ return a ('NOENT', reason, Time) tuple if only ipv6 addresses are
+ found.
+ """
+ _,haveIP6 = getProtocolSupport()
+ if not haveIP6: haveIP4 = 1
try:
r = getIPs(name)
inet4 = [ addr for addr in r if addr[0] == AF_INET ]
@@ -71,6 +81,10 @@
if not (inet4 or inet6):
LOG.warn("getIP returned no inet addresses for %r",name)
return ("NOENT", "No inet addresses returned", time.time())
+ if inet6 and not inet4 and not haveIP6:
+ return ("NOENT",
+ "All addresses were IPv6, and this host has no IPv6 support",
+ time.time())
best4=best6=None
if inet4: best4=inet4[0]
if inet6: best6=inet6[0]
@@ -209,7 +223,7 @@
s.close()
_PROTOCOL_SUPPORT = tuple(res)
- return res
+ return _PROTOCOL_SUPPORT
#----------------------------------------------------------------------
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- test.py 7 Jan 2004 02:50:08 -0000 1.174
+++ test.py 8 Jan 2004 18:09:49 -0000 1.175
@@ -6047,6 +6047,10 @@
'bar' : '18:0FFF::4:1',
'baz.com': '10.99.22.8'},
delay=DELAY)
+ # Override getProtocolSupport so we don't convert IPv6 addrs to
+ # an error if we're running on a host with no IPv6 support.
+ mixminion.NetUtils._PROTOCOL_SUPPORT = (1,1)
+
self.assertEquals(None, cache.getNonblocking("foo"))
start = time.time()
cache.lookup('foo',callback)
@@ -6098,6 +6102,7 @@
self.assertEquals(5, len(receiveDict))
finally:
undoReplacedAttributes()
+ mixminion.NetUtils._PROTOCOL_SUPPORT = None
#----------------------------------------------------------------------