def get_attach_port_index(session, vm_ref):
    ports = _get_vm_port_indices(session, vm_ref)
    # No ports are configured on the VM
    if not ports:
        return 0
    ports.sort()
    configured_ports_len = len(ports)
    # Find the first free port index
    for port_index in range(configured_ports_len):
        if port_index != ports[port_index]:
            return port_index
    return configured_ports_len
Initialize.
dataset/ETHPy150Open openstack/nova/nova/virt/vmwareapi/vm_util.py/get_attach_port_index--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/internet/posixbase.py/_SocketWaker.__init__