Esempio n. 1
0
def delete_hosts(select_query,
                 event_producer,
                 chunk_size,
                 interrupt=lambda: False):
    while select_query.count():
        for host in select_query.limit(chunk_size):
            host_id = host.id
            with delete_host_processing_time.time():
                _delete_host(select_query.session, host)

            host_deleted = _deleted_by_this_query(host)
            if host_deleted:
                delete_host_count.inc()

                event = build_event(EventType.delete, host)
                insights_id = host.canonical_facts.get("insights_id")
                headers = message_headers(EventType.delete, insights_id)
                event_producer.write_event(event,
                                           str(host.id),
                                           headers,
                                           wait=True)

            yield host_id, host_deleted

            if interrupt():
                return
def delete_hosts(select_query):
    while select_query.count():
        for host in select_query.limit(CHUNK_SIZE):
            host_id = host.id
            with delete_host_processing_time.time():
                _delete_host(select_query.session, host)

            host_deleted = _deleted_by_this_query(host)
            if host_deleted:
                delete_host_count.inc()
                _emit_event(host)

            yield host_id, host_deleted
def delete_hosts(select_query, event_producer):
    while select_query.count():
        for host in select_query.limit(CHUNK_SIZE):
            host_id = host.id
            with delete_host_processing_time.time():
                _delete_host(select_query.session, host)

            host_deleted = _deleted_by_this_query(host)
            if host_deleted:
                delete_host_count.inc()
                event = build_event(EventType.delete, host)
                event_producer.write_event(event, str(host.id),
                                           message_headers(EventType.delete),
                                           Topic.events)

            yield host_id, host_deleted
Esempio n. 4
0
def delete_hosts(select_query,
                 event_producer,
                 chunk_size,
                 interrupt=lambda: False):
    with session_guard(select_query.session):
        while select_query.count():
            for host in select_query.limit(chunk_size):
                host_id = host.id
                with delete_host_processing_time.time():
                    host_deleted = _delete_host(select_query.session,
                                                event_producer, host)

                yield host_id, host_deleted

                if interrupt():
                    return