-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
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.
@wagner-intevation if you had a second to have a look, it would be great |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
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