aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2008-03-06 06:57:08 +0000
committerRob Austein <sra@hactrn.net>2008-03-06 06:57:08 +0000
commit9c59fe2457635cecb44665e5d6dc0dc24e3aa721 (patch)
tree872edba313758aab09cec99a84e87060176378b1
parent018f9aead380c5c81f150124e2ede343c31e83e0 (diff)
Nasty kludge to pacify MySQL 5.0
svn path=/rpkid/testbed.py; revision=1553
-rw-r--r--rpkid/testbed.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/rpkid/testbed.py b/rpkid/testbed.py
index c61707a2..fc3de1b5 100644
--- a/rpkid/testbed.py
+++ b/rpkid/testbed.py
@@ -111,9 +111,6 @@ rcynic_stats = cfg.get("rcynic_stats", "xsltproc --param refresh 0 ../../rcy
rpki_sql_file = cfg.get("rpki_sql_file", "../docs/rpki-db-schema.sql")
irdb_sql_file = cfg.get("irdb_sql_file", "../docs/sample-irdb.sql")
-rpki_sql = open(rpki_sql_file).read()
-irdb_sql = open(irdb_sql_file).read()
-
testbed_key = None
testbed_certs = None
rootd_ta = None
@@ -131,6 +128,9 @@ def main():
rootd_process = None
rsyncd_process = None
+ rpki_sql = mangle_sql(rpki_sql_file)
+ irdb_sql = mangle_sql(irdb_sql_file)
+
try:
os.chdir(testbed_dir)
except:
@@ -467,12 +467,12 @@ class allocation(object):
rpki.log.info("Setting up MySQL for %s" % self.name)
db = MySQLdb.connect(user = "rpki", db = self.rpki_db_name, passwd = rpki_db_pass)
cur = db.cursor()
- for sql in rpki_sql.split(";"):
+ for sql in rpki_sql:
cur.execute(sql)
db.close()
db = MySQLdb.connect(user = "irdb", db = self.irdb_db_name, passwd = irdb_db_pass)
cur = db.cursor()
- for sql in irdb_sql.split(";"):
+ for sql in irdb_sql:
cur.execute(sql)
for kid in self.kids:
cur.execute("INSERT registrant (IRBE_mapped_id, subject_name, valid_until) VALUES (%s, %s, %s)", (kid.name, kid.name, kid.resources.valid_until))
@@ -708,6 +708,18 @@ def run_rcynic():
subprocess.check_call((prog_rcynic, "-c", rcynic_name + ".conf"), env = env)
subprocess.call(rcynic_stats, shell = True, env = env)
+def mangle_sql(filename):
+ """Mangle an SQL file into a sequence of SQL statements."""
+ #
+ # There is no pretty way to do this. Just shut your eyes, it'll be over soon.
+ #
+ f = open(filename)
+ statements = " ".join(" ".join(word for word in line.expandtabs().split(" ") if word)
+ for line in [line.strip(" \t\n") for line in f.readlines()]
+ if line and not line.startswith("--")).rstrip(";").split(";")
+ f.close()
+ return [stmt.strip() for stmt in statements]
+
biz_cert_fmt_1 = '''\
[ req ]
distinguished_name = req_dn