diff options
author | Luke Macken <lmacken@redhat.com> | 2008-01-17 22:34:40 -0500 |
---|---|---|
committer | Luke Macken <lmacken@redhat.com> | 2008-01-17 22:34:40 -0500 |
commit | 061db7282409b779290eddce8e969b8544642a58 (patch) | |
tree | d260ee8dac6d5690127a030482cede6ce82ea02d /func/minion/modules/networktest.py | |
parent | 2643cf6e852807489d9ad2b30803ea62fef28c01 (diff) | |
parent | cca8b7f4dc8af9ef5411ca299700132c9af5b9c8 (diff) | |
download | func-061db7282409b779290eddce8e969b8544642a58.tar.gz func-061db7282409b779290eddce8e969b8544642a58.tar.xz func-061db7282409b779290eddce8e969b8544642a58.zip |
Merge branch 'master' of ssh+git://git.fedorahosted.org/git/func
Diffstat (limited to 'func/minion/modules/networktest.py')
-rw-r--r-- | func/minion/modules/networktest.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/func/minion/modules/networktest.py b/func/minion/modules/networktest.py index 5f54c5e..0e6fbb2 100644 --- a/func/minion/modules/networktest.py +++ b/func/minion/modules/networktest.py @@ -38,12 +38,22 @@ class NetworkTest(func_module.FuncModule): self.__args_to_list(args)) def isportopen(self, host, port): + # FIXME: the return api here needs some work... -akl import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((host, int(port))) - data = sock.recv(2048) + timeout = 3.0 + sock.settimeout(timeout) + try: + sock.connect((host, int(port))) + except socket.error, e: + sock.close() + return [1, ("connection to %s:%s failed" % (host, port), "%s" % e)] + except socket.timeout: + sock.close() + return [2, ("connection to %s:%s timed out after %s seconds" % (host, port, timeout))] + sock.close() - return [line for line in data.split('\n')] + return [0, "connection to %s:%s succeeded" % (host, port)] def __args_to_list(self, args): return [arg for arg in args] |