Commit 25ba209e authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

TcpPing: Better error handling, logging



Log every attempt to reach a port on another node. Don't silently return
False if a target not recognized as an IP address is given (e.g. a
hostname).
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 965e0e6a
......@@ -281,10 +281,14 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None):
than C{EADDRNOTAVAIL} will be ignored
"""
logging.debug("Attempting to reach TCP port %s on target %s with a timeout"
" of %s seconds", port, target, timeout)
try:
family = IPAddress.GetAddressFamily(target)
except errors.GenericError:
return False
except errors.IPAddressError, err:
raise errors.ProgrammerError("Family of IP address given in parameter"
" 'target' can't be determined: %s" % err)
sock = socket.socket(family, socket.SOCK_STREAM)
success = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment