aboutsummaryrefslogtreecommitdiff
path: root/ca
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-10-19 03:36:42 +0000
committerRob Austein <sra@hactrn.net>2015-10-19 03:36:42 +0000
commit7f5e75188ad4527e3c3425a155dfed0847a389dd (patch)
tree400301cae01f51141e380664cf0b382b8204a00d /ca
parent7ab6040f7eb05a7ac4424e0294d228256e9a64dd (diff)
Amputate old SQL code out of rpkid with a fire axe, replacing it with
Django ORM. Duct tape and bailing wire everywhere, much clean-up left to do, but basic "make yamltest" suite runs. Much of the clean-up isn't worth doing until after revamping the I/O system, as it'll all change again at that point anyway. svn path=/branches/tk705/; revision=6127
Diffstat (limited to 'ca')
-rwxr-xr-xca/irbe_cli5
-rwxr-xr-xca/rpki-sql-setup18
-rwxr-xr-xca/rpkigui-query-routes16
-rw-r--r--ca/tests/sql-cleaner.py13
4 files changed, 16 insertions, 36 deletions
diff --git a/ca/irbe_cli b/ca/irbe_cli
index 2edde024..ebd5d2a5 100755
--- a/ca/irbe_cli
+++ b/ca/irbe_cli
@@ -37,6 +37,7 @@ Command line IR back-end control program for rpkid and pubd.
# Command line processing of this program is too complex and
# idiosyncratic to be worth trying to reimplement using argparse.
+import os
import sys
import getopt
import textwrap
@@ -206,7 +207,7 @@ class left_right_msg(cmd_msg_mixin, rpki.left_right.msg):
for x in (self_elt, bsc_elt, parent_elt, child_elt, repository_elt,
list_published_objects_elt, list_received_resources_elt, report_error_elt))
-class left_right_sax_handler(rpki.left_right.sax_handler):
+class left_right_sax_handler(rpki.left_right.sax_handler): # pylint: disable=W0232
pdu = left_right_msg
class left_right_cms_msg(rpki.left_right.cms_msg):
@@ -250,7 +251,7 @@ class publication_msg(cmd_msg_mixin, rpki.publication.msg):
manifest_elt, roa_elt, report_error_elt,
ghostbuster_elt))
-class publication_sax_handler(rpki.publication.sax_handler):
+class publication_sax_handler(rpki.publication.sax_handler): # pylint: disable=W0232
pdu = publication_msg
class publication_cms_msg(rpki.publication.cms_msg):
diff --git a/ca/rpki-sql-setup b/ca/rpki-sql-setup
index 848e3d0f..b209fec7 100755
--- a/ca/rpki-sql-setup
+++ b/ca/rpki-sql-setup
@@ -27,7 +27,11 @@ import datetime
import rpki.config
import rpki.version
import rpki.autoconf
-import rpki.sql_schemas
+
+# This program implements its own schema versioning system as a poor
+# substitute for schema migrations. Now that we're moving to Django
+# ORM, this is pretty much useless, and should be removed at some point.
+
from rpki.mysql_import import MySQLdb, _mysql_exceptions
@@ -142,14 +146,6 @@ class UserDB(object):
self.db.commit()
log("Updated %s to %s" % (self.name, v))
- @property
- def schema(self):
- lines = []
- for line in getattr(rpki.sql_schemas, self.name, "").splitlines():
- line = " ".join(line.split())
- if line and not line.startswith("--"):
- lines.append(line)
- return [statement.strip() for statement in " ".join(lines).rstrip(";").split(";") if statement.strip()]
class Version(object):
@@ -215,10 +211,6 @@ def do_create(name):
(db.password,))
root.db.commit()
db.open()
- for statement in db.schema:
- if not statement.upper().startswith("DROP TABLE"):
- log(statement)
- db.cur.execute(statement)
db.version = current_version
db.close()
diff --git a/ca/rpkigui-query-routes b/ca/rpkigui-query-routes
index 179f8c2c..dc2835a0 100755
--- a/ca/rpkigui-query-routes
+++ b/ca/rpkigui-query-routes
@@ -49,17 +49,17 @@ qs = rv.RouteOrigin.objects.filter(
prefix_max__gte=r.max
)
-def validity_marker(route, roa, roa_prefix):
- "Return + if the roa would cause the route to be accepted, or - if not"
- # we already know the ROA covers this route because they are returned
- # from RouteOrigin.roas, so just check the ASN and max prefix length
- return '-' if (roa.asid == 0 or route.asn != roa.asid or
- route.prefixlen > roa_prefix.max_length) else '+'
-
# xxx.xxx.xxx.xxx/xx-xx is 22 characters
+# we already know the ROA covers this route because they are returned
+# from RouteOrigin.roas, so just check the ASN and max prefix length
+
for route in qs:
print route.as_resource_range(), route.asn, route.status
for pfx in route.roa_prefixes:
for roa in pfx.roas.all():
- print validity_marker(route, roa, pfx), pfx.as_roa_prefix(), roa.asid, roa.repo.uri
+ if roa.asid == 0 or route.asn != roa.asid or route.prefixlen > pfx.max_length:
+ validity_marker = '-'
+ else:
+ validity_marker = '+'
+ print validity_marker, pfx.as_roa_prefix(), roa.asid, roa.repo.uri
print
diff --git a/ca/tests/sql-cleaner.py b/ca/tests/sql-cleaner.py
index 369a68ea..828100a4 100644
--- a/ca/tests/sql-cleaner.py
+++ b/ca/tests/sql-cleaner.py
@@ -19,7 +19,6 @@
"""
import rpki.config
-import rpki.sql_schemas
from rpki.mysql_import import MySQLdb
cfg = rpki.config.parser(section = "yamltest", allow_missing = True)
@@ -29,15 +28,6 @@ for name in ("rpkid", "irdbd", "pubd"):
username = cfg.get("%s_sql_username" % name, name[:4])
password = cfg.get("%s_sql_password" % name, "fnord")
- # All of this schema creation stuff will go away once we're on Django ORM.
- # For the moment, a quick kludge for testing.
- schema = []
- if name == "rpkid":
- for line in getattr(rpki.sql_schemas, name, "").splitlines():
- schema.extend(line.partition("--")[0].split())
- schema = " ".join(schema).strip(";").split(";")
- schema = [statement.strip() for statement in schema if statement and "DROP TABLE" not in statement]
-
db = MySQLdb.connect(user = username, passwd = password)
cur = db.cursor()
@@ -57,8 +47,5 @@ for name in ("rpkid", "irdbd", "pubd"):
cur.execute("DROP TABLE %s" % table)
cur.execute("SET foreign_key_checks = 1")
- for statement in schema:
- cur.execute(statement)
-
cur.close()
db.close()