Esempio n. 1
0
def mimetype_probelist(mimetype, session):
    log.debug("asking what probes handle %s", mimetype)
    probe_list = []
    for p in Probe.all(session):
        regexp = p.mimetype_regexp
        if regexp is None or \
           re.search(regexp, mimetype, re.IGNORECASE) is not None:
            probe_list.append(p.name)
    log.debug("probes: %s", "-".join(probe_list))
    return probe_list
Esempio n. 2
0
def refresh_probes(session):
    """ Put all probes offline and send them a register request
        Infos/Online state will be updated
    """
    probes = Probe.all(session)
    for probe in probes:
        probe.online = False
    for active_probe in active_probes():
        celery_probe.get_info(active_probe)
    return
Esempio n. 3
0
def mimetype_probelist(mimetype, session):
    log.debug("asking what probes handle %s", mimetype)
    probe_list = []
    for p in Probe.all(session):
        regexp = p.mimetype_regexp
        if regexp is None or \
           re.search(regexp, mimetype, re.IGNORECASE) is not None:
            probe_list.append(p.name)
    log.debug("probes: %s", "-".join(probe_list))
    return probe_list
Esempio n. 4
0
def refresh_probes(session):
    """ Put all probes offline and send them a register request
        Infos/Online state will be updated
    """
    probes = Probe.all(session)
    for probe in probes:
        probe.online = False
    for active_probe in active_probes():
        celery_probe.get_info(active_probe)
    return
Esempio n. 5
0
def get_list(session):
    """ Return a list of probe name (queues name)
        that a scan could use
    """
    active_probes_list = active_probes()
    probes = Probe.all(session)
    # Update Status
    for probe in probes:
        if probe.name not in active_probes_list:
            log.debug("probe list set %s offline", probe.name)
            probe.online = False
        elif probe.online is False:
            log.debug("probe list set %s online", probe.name)
            probe.online = True
    probes_list = [p.name for p in probes if p.online]
    log.info("probe list %s", "-".join(probes_list))
    return probes_list
Esempio n. 6
0
def get_list(session):
    """ Return a list of probe name (queues name)
        that a scan could use
    """
    active_probes_list = active_probes()
    probes = Probe.all(session)
    # Update Status
    for probe in probes:
        if probe.name not in active_probes_list:
            log.debug("probe list set %s offline", probe.name)
            probe.online = False
        elif probe.online is False:
            log.debug("probe list set %s online", probe.name)
            probe.online = True
    probes_list = [p.name for p in probes if p.online]
    log.info("probe list %s", "-".join(probes_list))
    return probes_list
Esempio n. 7
0
def refresh_probelist(session):
    global available_probes
    dbprobes = Probe.all(session)
    result_queue_name = config.brain_config['broker_probe'].queue
    queues = probe_app.control.inspect().active_queues() or {}
    queues = [q['name'] for ql in queues.values()
              for q in ql if q['name'] != result_queue_name]

    for probe in dbprobes:
        if probe.online and probe.name not in queues:
            log.debug("probelist set %s offline", probe.name)
            probe.online = False
            try:
                available_probes.remove(probe.name)
            except ValueError:
                pass
        elif (not probe.online or probe.name not in available_probes) \
                and probe.name in queues:
            log.debug("probelist set %s online", probe.name)
            probe.online = True
            available_probes.append(probe.name)
Esempio n. 8
0
def refresh_probelist(session):
    global available_probes
    dbprobes = Probe.all(session)
    result_queue_name = config.brain_config['broker_probe'].queue
    queues = probe_app.control.inspect().active_queues() or {}
    queues = [
        q['name'] for ql in queues.values() for q in ql
        if q['name'] != result_queue_name
    ]

    for probe in dbprobes:
        if probe.online and probe.name not in queues:
            log.debug("probelist set %s offline", probe.name)
            probe.online = False
            try:
                available_probes.remove(probe.name)
            except ValueError:
                pass
        elif (not probe.online or probe.name not in available_probes) \
                and probe.name in queues:
            log.debug("probelist set %s online", probe.name)
            probe.online = True
            available_probes.append(probe.name)
 def test005_all(self):
     Probe.all(self.session)
     self.session.query.assert_called_once_with(Probe)
     self.session.query().all.assert_called_once()