Remove unused 'get_open_port' method from libvirt utils

As of the following commit:

  commit 71410724cd
  Author: Thierry Carrez <thierry@openstack.org>
  Date:   Tue Feb 7 16:37:34 2012 +0100

    Remove ajaxterm from Nova

The 'get_open_port' method in the libvirt utils.py module
is no longer used. Thus is can be deleted

Change-Id: I837d07f82d55c54b4abd82d9bb20498a1f489f84
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-06-29 16:22:13 +01:00
parent 74bd0b7515
commit 7ed3452d10
2 changed files with 0 additions and 23 deletions

View File

@ -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),

View File

@ -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