From ba91cbaac0ac6654d6f4b1291814e3be02ab50e5 Mon Sep 17 00:00:00 2001
From: Jeremy <grossmj@gns3.net>
Date: Tue, 20 Jan 2015 19:10:08 -0700
Subject: [PATCH] Remove find_unused_port from the attic.

---
 gns3server/modules/attic.py | 44 -------------------------------------
 1 file changed, 44 deletions(-)

diff --git a/gns3server/modules/attic.py b/gns3server/modules/attic.py
index be09b57a..6331317b 100644
--- a/gns3server/modules/attic.py
+++ b/gns3server/modules/attic.py
@@ -30,50 +30,6 @@ import logging
 log = logging.getLogger(__name__)
 
 
-def find_unused_port(start_port, end_port, host='127.0.0.1', socket_type="TCP", ignore_ports=[]):
-    """
-    Finds an unused port in a range.
-
-    :param start_port: first port in the range
-    :param end_port: last port in the range
-    :param host: host/address for bind()
-    :param socket_type: TCP (default) or UDP
-    :param ignore_ports: list of port to ignore within the range
-    """
-
-    if end_port < start_port:
-        raise Exception("Invalid port range {}-{}".format(start_port, end_port))
-
-    if socket_type == "UDP":
-        socket_type = socket.SOCK_DGRAM
-    else:
-        socket_type = socket.SOCK_STREAM
-
-    last_exception = None
-    for port in range(start_port, end_port + 1):
-        if port in ignore_ports:
-            continue
-        try:
-            if ":" in host:
-                # IPv6 address support
-                with socket.socket(socket.AF_INET6, socket_type) as s:
-                    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-                    s.bind((host, port))  # the port is available if bind is a success
-            else:
-                with socket.socket(socket.AF_INET, socket_type) as s:
-                    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-                    s.bind((host, port))  # the port is available if bind is a success
-            return port
-        except OSError as e:
-            last_exception = e
-            if port + 1 == end_port:
-                break
-            else:
-                continue
-
-    raise Exception("Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port, end_port, host, last_exception))
-
-
 def wait_socket_is_ready(host, port, wait=2.0, socket_timeout=10):
     """
     Waits for a socket to be ready for wait time.