diff options
Diffstat (limited to 'scripts/generate-ripe-root-cert.py')
-rw-r--r-- | scripts/generate-ripe-root-cert.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/generate-ripe-root-cert.py b/scripts/generate-ripe-root-cert.py index 19b6dcf8..3d88c396 100644 --- a/scripts/generate-ripe-root-cert.py +++ b/scripts/generate-ripe-root-cert.py @@ -4,7 +4,7 @@ cert for Pseudo-RIPE. $Id$ -Copyright (C) 2010 Internet Systems Consortium ("ISC") +Copyright (C) 2010-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -19,37 +19,37 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import sys, lxml.etree, rpki.myrpki +import sys +import lxml.etree +from rpki.csv_utils import csv_writer + +def iterate_xml(filename, tag): + return lxml.etree.parse(filename).getroot().getiterator(tag) def ns(tag): return "{http://www.iana.org/assignments}" + tag -tag_registry = ns("registry") tag_description = ns("description") tag_designation = ns("designation") tag_record = ns("record") tag_number = ns("number") tag_prefix = ns("prefix") -asn_xml = lxml.etree.parse("as-numbers.xml").getroot() -ipv4_xml = lxml.etree.parse("ipv4-address-space.xml").getroot() -ipv6_xml = lxml.etree.parse("ipv6-unicast-address-assignments.xml").getroot() - -asns = rpki.myrpki.csv_writer("asns.csv") -prefixes = rpki.myrpki.csv_writer("prefixes.csv") +asns = csv_writer("asns.csv") +prefixes = csv_writer("prefixes.csv") -for record in asn_xml.getiterator(tag_record): +for record in iterate_xml("as-numbers.xml", tag_record): if record.findtext(tag_description) == "Assigned by RIPE NCC": asns.writerow(("RIPE", record.findtext(tag_number))) -for record in ipv4_xml.getiterator(tag_record): +for record in iterate_xml("ipv4-address-space.xml", tag_record): if record.findtext(tag_designation) in ("RIPE NCC", "Administered by RIPE NCC"): prefix = record.findtext(tag_prefix) p, l = prefix.split("/") assert l == "8", "Violated /8 assumption: %r" % prefix prefixes.writerow(("RIPE", "%d.0.0.0/8" % int(p))) -for record in ipv6_xml.getiterator(tag_record): +for record in iterate_xml("ipv6-unicast-address-assignments.xml", tag_record): if record.findtext(tag_description) == "RIPE NCC": prefixes.writerow(("RIPE", record.findtext(tag_prefix))) |