Filter ports attached to devices we don't care about

    Currently used to filter DHCP_RESERVED ports
493814
def filter_by_device_id(query):
    
    port_model = models_v2.Port
    unsupported_device_id_filter = [
        port_model.device_id.notilike('%s%%' % id)
        for id in utils.UNSUPPORTED_DEVICE_IDS]
    query = (query
             .filter(and_(*unsupported_device_id_filter)))
    return query
408970
def _check_listening_on_ports_list(ports):
    
    ports_open = [port_has_listener('0.0.0.0', p) for p in ports]
    return zip(ports, ports_open), ports_open
1044024
def find_device(vidpid):
    """"""
    for port in list_ports.comports():
        if re.search(vidpid, port[2], flags=re.IGNORECASE):
            return port[0]

    raise exceptions.RoasterLookupError
978738
def list_port_fwd(zone, permanent=True):
    '''
    
    '''
    ret = []

    cmd = '--zone={0} --list-forward-ports'.format(zone)

    if permanent:
        cmd += ' --permanent'

    for i in __firewall_cmd(cmd).splitlines():
        (src, proto, dest, addr) = i.split(':')

        ret.append(
            {'Source port': src.split('=')[1],
             'Protocol': proto.split('=')[1],
             'Destination port': dest.split('=')[1],
             'Destination address': addr.split('=')[1]}
        )

    return ret
996020
function (port, parent_port) {

	// check if the port wasn't reported
	if (l_ports.hasOwnProperty(port) === false) {
		
		LOG.warn('recording used port [' + port + ']...', 'SR.Monitor');	
		l_ports[port] = parent_port || port;
	}
}
896422
def find_free_port():
    """"""
    with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
        sock.bind(('', 0))
        return sock.getsockname()[1]
300945
def disable(gandi, resource, backend, port, probe):
    
    result = []
    if backend:
        backends = backend
        for backend in backends:
            if 'port' not in backend:
                if not port:
                    backend['port'] = click.prompt('Please set a port for '
                                                   'backends. If you want to '
                                                   ' different port for '
                                                   'each backend, use `-b '
                                                   'ip:port`', type=int)
                else:
                    backend['port'] = port
            result = gandi.webacc.backend_disable(backend)

    if probe:
        if not resource:
            gandi.echo('You need to indicate the Webaccelerator name')
            return
        result = gandi.webacc.probe_disable(resource)

    return result
1357630
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def trusted_shared_nets(app):
        return TrustedSharedNetwork(app, conf)
    return trusted_shared_nets
1344772
def list_ports(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-ports'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
356345
public static host_device[] get_filtered(nitro_service service, String filter) throws Exception
	{
		host_device obj = new host_device();
		options option = new options();
		option.set_filter(filter);
		host_device[] response = (host_device[]) obj.getfiltered(service, option);
		return response;
	}
211527
def clear_host_port(self):
        
        if self.host_port:
            self._adb.forward(['--remove', 'tcp:%d' % self.host_port])
            self.host_port = None
258243
def available_ports(low=1024, high=65535, exclude_ranges=None):
    
    if exclude_ranges is None:
        exclude_ranges = []
    available = utils.ranges_to_set(UNASSIGNED_RANGES)
    exclude = utils.ranges_to_set(
        ephemeral.port_ranges() + exclude_ranges +
        [
            SYSTEM_PORT_RANGE,
            (SYSTEM_PORT_RANGE[1], low),
            (high, 65536)
        ]
    )
    return available.difference(exclude)
47044
def get_ports(device_owners=None, vnic_type=None, port_id=None, active=True):
    """"""
    session = db.get_reader_session()
    with session.begin():
        port_model = models_v2.Port
        ports = (session
                 .query(port_model)
                 .filter_unnecessary_ports(device_owners, vnic_type, active))
        if port_id:
            ports = ports.filter(port_model.id == port_id)
    return ports.all()
953624
def unused_port(hostname):
    """"""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.bind((hostname, 0))
        return s.getsockname()[1]
256238
def remove_port(zone, port, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --remove-port={1}'.format(zone, port)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd)
1128068
def get_unused_port(port=None):
    """"""
    if port is None or port < 1024 or port > 65535:
        port = random.randint(1024, 65535)
    assert(1024 <= port <= 65535)
    while True:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.bind(('', port))  # Try to open port
        except socket.error as e:
            if e.errno in (98, 10048):  # 98, 10048 means address already bound
                return get_unused_port(None)
            raise e
        s.close()
        return port
1294677
def delete_port(self, port):
        '''
        
        '''
        port_id = self._find_port_id(port)
        ret = self.network_conn.delete_port(port=port_id)
        return ret if ret else True