Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally import RIPE routes #23

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kamil-certat
Copy link

This PR propose merging an old change to optionally import RIPE routes, used in case of Tuency support. In addition, the query was updated to use bulk execution[1] to improve the overall performance.

It requires psycopg2 >= 2.7, which is already available even in distro packages [2].

[1] https://www.psycopg.org/docs/extras.html#psycopg2.extras.execute_values
[2] https://pkgs.org/search/?q=psycopg2

bernhard-herzog and others added 7 commits May 10, 2021 10:54
The ripe importer can now optionally import RIPE route data. In the
context of IntelMQ, this information is useful to e.g. map IP addresses
to ASNs which in turn can be mapped to contact information for
notifications.

This commit contains the changes for main part of this:

 * The download script also downloads the ripe.db.route.gz
   and ripe.db.route6.gz files

 * The database schema has a new table and index for the route
   information

 * The import code optionally loads these files and saves it into the
   database

Notably missing is the database upgrade.

Related to Intevation#15
This adds an update script for the new route_automatic table. The name
script file does not include a version number like the other update
scripts because it's not clear yet which version this file will be
included in.

Related to Intevation#15
The RIPE importer has a new command line option,
--before-commit-command, whose argument is an SQL statement that is
executed by the importer before the transaction that updates the RIPE
data is committed. This command can be used to e.g. cleanup data that
depends on the RIPE data, but which cannot be automatically updated with
'ON DELETE CASCADE' for foreign keys or similar mechanisms.
@kamil-certat
Copy link
Author

@wagner-intevation if you had a second to have a look, it would be great

Copy link
Member

@wagner-intevation wagner-intevation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this enhancement!



def remove_old_entries(cur, verbose):
def remove_old_entries(cur, verbose, delete_route_data=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this new parameter used?

Comment on lines -129 to +134
def insert_new_asn_org_entries(cur, asn_list, mapping):
# many-to-many table organisation <-> as number
def _generate_asn_entries(asn_list, mapping):
insert_time = datetime.now(tz=timezone.utc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just refactoring or required for something else?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to give all bulk inserted entries the same import time

@@ -0,0 +1,18 @@
-- Update script for the route_automatic table.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention this in UPDATE.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants