def prepare_bview_file():
    publisher.info('Start converting binary bview file in plain text...')

    # create the plain text dump from the binary dump
    output = open(os.path.join(bview_dir, 'bview'), 'wr')
    nul_f = open(os.devnull, 'w')
    bgpdump = os.path.join(root_dir, path_to_bgpdump_bin)
    p_bgp = Popen([bgpdump , filename], stdout=PIPE, stderr = nul_f)
    for line in p_bgp.stdout:
        output.write(line)
    nul_f.close()
    output.close()
    publisher.info('Convertion finished, start splitting...')

    # Split the plain text file
    fs = FilesSplitter(output.name, number_of_splits)
    splitted_files = fs.fplit()
    publisher.info('Splitting finished.')

    # Flush the old routing database and launch the population of
    # the new database
    routing_db.flushdb()

    publisher.info('Start pushing all routes...')
    pushing_process_service = os.path.join(services_dir, "pushing_process")
    run_splitted_processing(split_procs, pushing_process_service,
            splitted_files)
    publisher.info('All routes pushed.')

    # Remove the binary and the plain text files
    os.unlink(output.name)
    os.unlink(filename)
Example #2
0
def prepare_bview_file():
    publisher.info('Start converting binary bview file in plain text...')

    # create the plain text dump from the binary dump
    output = open(os.path.join(bview_dir, 'bview'), 'wr')
    nul_f = open(os.devnull, 'w')
    bgpdump = os.path.join(root_dir, path_to_bgpdump_bin)
    p_bgp = Popen([bgpdump, filename], stdout=PIPE, stderr=nul_f)
    for line in p_bgp.stdout:
        output.write(line)
    nul_f.close()
    output.close()
    publisher.info('Convertion finished, start splitting...')

    # Split the plain text file
    fs = FilesSplitter(output.name, number_of_splits)
    splitted_files = fs.fplit()
    publisher.info('Splitting finished.')

    # Flush the old routing database and launch the population of
    # the new database
    routing_db.flushdb()

    publisher.info('Start pushing all routes...')
    pushing_process_service = os.path.join(services_dir, "pushing_process")
    run_splitted_processing(split_procs, pushing_process_service,
                            splitted_files)
    publisher.info('All routes pushed.')

    # Remove the binary and the plain text files
    os.unlink(output.name)
    os.unlink(filename)
        if not os.path.exists(filename) or history_db.exists(config.get('redis','to_rank')):
            # wait for a new file
            time.sleep(sleep_timer)
            continue
        syslog.syslog(syslog.LOG_INFO, 'Start converting binary bview file in plain text...')
        # create the plain text dump from the binary dump
        output = open(dir + '/bview', 'wr')
        nul_f = open(os.devnull, 'w')
        p_bgp = Popen([bgpdump , filename], stdout=PIPE, stderr = nul_f)
        for line in p_bgp.stdout:
            output.write(line)
        nul_f.close()
        output.close()
        syslog.syslog(syslog.LOG_INFO, 'Convertion finished, start splitting...')
        # Split the plain text file
        fs = FilesSplitter(output.name, int(config.get('routing','number_of_splits')))
        splitted_files = fs.fplit()
        syslog.syslog(syslog.LOG_INFO, 'Splitting finished.')
        # Flush the old routing database and launch the population of the new database
        routing_db.flushdb()
        syslog.syslog(syslog.LOG_INFO, 'Start pushing all routes...')
        run_splitted_processing(int(config.get('processes','routing_push')), pushing_process_service, splitted_files)
        syslog.syslog(syslog.LOG_INFO, 'All routes pushed.')
        # Remove the binary and the plain text files
        os.unlink(output.name)
        os.unlink(filename)

        if compute_yesterday_ranking():
            # Clean the whole database and regenerate it (like this we do not keep data of the old rankings)
            report = ReportsGenerator()
            report.flush_temp_db()
            time.sleep(sleep_timer)
            continue
        syslog.syslog(syslog.LOG_INFO,
                      'Start converting binary bview file in plain text...')
        # create the plain text dump from the binary dump
        output = open(dir + '/bview', 'wr')
        nul_f = open(os.devnull, 'w')
        p_bgp = Popen([bgpdump, filename], stdout=PIPE, stderr=nul_f)
        for line in p_bgp.stdout:
            output.write(line)
        nul_f.close()
        output.close()
        syslog.syslog(syslog.LOG_INFO,
                      'Convertion finished, start splitting...')
        # Split the plain text file
        fs = FilesSplitter(output.name,
                           int(config.get('routing', 'number_of_splits')))
        splitted_files = fs.fplit()
        syslog.syslog(syslog.LOG_INFO, 'Splitting finished.')
        # Flush the old routing database and launch the population of the new database
        routing_db.flushdb()
        syslog.syslog(syslog.LOG_INFO, 'Start pushing all routes...')
        run_splitted_processing(int(config.get('processes', 'routing_push')),
                                pushing_process_service, splitted_files)
        syslog.syslog(syslog.LOG_INFO, 'All routes pushed.')
        # Remove the binary and the plain text files
        os.unlink(output.name)
        os.unlink(filename)

        if compute_yesterday_ranking():
            # Clean the whole database and regenerate it (like this we do not keep data of the old rankings)
            report = ReportsGenerator()