Fixes bug with finding a free port.

This commit is contained in:
grossmj committed 2014-04-11 17:02:43 -06:00
1 parent e70ea26639
commit 862448ada1
2 files changed
+8 -6

No files matched your search

@@ -351,8 +351,6 @@ class DynamipsHypervisor(object):
socket_type = socket.SOCK_STREAM
for port in range(start_port, end_port):
if port + 1 == end_port:
raise DynamipsError("Could not find a free port between {0} and {1}".format(start_port, end_port))
try:
if ":" in host:
# IPv6 address support
@@ -364,7 +362,10 @@ class DynamipsHypervisor(object):
return port
except OSError as e:
if e.errno == errno.EADDRINUSE: # socket already in use
continue
if port + 1 == end_port:
raise DynamipsError("Could not find a free port between {0} and {1}".format(start_port, end_port))
else:
continue
else:
raise DynamipsError("Could not find an unused port: {}".format(e))