

@utils.synchronized(SERIAL_LOCK)
def acquire_port(host):
    "Returns a free TCP port on host.\n\n    Find and returns a free TCP port on 'host' in the range\n    of 'CONF.serial_console.port_range'.\n    "
    (start, stop) = _get_port_range()
    for port in six.moves.range(start, stop):
        if ((host, port) in ALLOCATED_PORTS):
            continue
        try:
            _verify_port(host, port)
            ALLOCATED_PORTS.add((host, port))
            return port
        except exception.SocketPortInUseException as e:
            LOG.warning(e.format_message())
    raise exception.SocketPortRangeExhaustedException(host=host)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/console/serial.py acquire_port/original