diff --git a/nova/tests/fake_libvirt_utils.py b/nova/tests/fake_libvirt_utils.py index 2cd5bb75efac..1467a26de4c1 100644 --- a/nova/tests/fake_libvirt_utils.py +++ b/nova/tests/fake_libvirt_utils.py @@ -118,11 +118,6 @@ def file_delete(path): return True -def get_open_port(start_port, end_port): - # Return the port in the middle - return int((start_port + end_port) / 2) - - def get_fs_info(path): return {'total': 128 * (1024 ** 3), 'used': 44 * (1024 ** 3), diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index 363c692aa025..1ea81e1dcb6e 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -330,24 +330,6 @@ def file_delete(path): return os.unlink(path) -def get_open_port(start_port, end_port): - """Find an available port - - :param start_port: Start of acceptable port range - :param end_port: End of acceptable port range - """ - for i in xrange(0, 100): # don't loop forever - port = random.randint(start_port, end_port) - # netcat will exit with 0 only if the port is in use, - # so a nonzero return value implies it is unused - cmd = 'netcat', '0.0.0.0', port, '-w', '1' - try: - stdout, stderr = execute(*cmd, process_input='') - except exception.ProcessExecutionError: - return port - raise Exception(_('Unable to find an open port')) - - def get_fs_info(path): """Get free/used/total space info for a filesystem