diff options
author | Rob Austein <sra@hactrn.net> | 2014-04-10 22:56:47 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-04-10 22:56:47 +0000 |
commit | 45b95aaadc861b0e682373164fe18fa0c5ed2b2e (patch) | |
tree | 6e415c4dd6b78e84a58ae0038ab9847fb69feafc /potpourri/upgrade-add-ghostbusters.py | |
parent | 5e0d1807ca7b049bde262a529443924adfd903e6 (diff) | |
parent | b7459d825cfadb9db265ed1b3bd0c10682464767 (diff) |
Merge tk685 branch back to trunk. This completes the move of the rpki
libraries and rpki.POW module from the rpki-ca package to the rpki-rp
package. Closes #685, closes #633.
svn path=/trunk/; revision=5784
Diffstat (limited to 'potpourri/upgrade-add-ghostbusters.py')
-rw-r--r-- | potpourri/upgrade-add-ghostbusters.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/potpourri/upgrade-add-ghostbusters.py b/potpourri/upgrade-add-ghostbusters.py new file mode 100644 index 00000000..a8c8a92b --- /dev/null +++ b/potpourri/upgrade-add-ghostbusters.py @@ -0,0 +1,73 @@ +# $Id$ +# +# Copyright (C) 2009--2011 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 +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +""" +Add SQL tables needed for Ghostbusters support. +Most of the code here lifted from rpki-sql-setup.py +""" + +import getopt, sys, rpki.config, warnings + +from rpki.mysql_import import MySQLdb + +def fix(name, *statements): + db = MySQLdb.connect(db = cfg.get("sql-database", section = name), + user = cfg.get("sql-username", section = name), + passwd = cfg.get("sql-password", section = name)) + cur = db.cursor() + for statement in statements: + cur.execute(statement) + db.commit() + db.close() + +cfg_file = None + +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +for o, a in opts: + if o in ("-h", "--help", "-?"): + print __doc__ + sys.exit(0) + if o in ("-c", "--config"): + cfg_file = a + +cfg = rpki.config.parser(cfg_file, "myrpki") + +fix("irdbd", """ + CREATE TABLE ghostbuster_request ( + ghostbuster_request_id SERIAL NOT NULL, + self_handle VARCHAR(40) NOT NULL, + parent_handle VARCHAR(40), + vcard LONGBLOB NOT NULL, + PRIMARY KEY (ghostbuster_request_id) + ) ENGINE=InnoDB; +""") + +fix("rpkid", """ + CREATE TABLE ghostbuster ( + ghostbuster_id SERIAL NOT NULL, + vcard LONGBLOB NOT NULL, + cert LONGBLOB NOT NULL, + ghostbuster LONGBLOB NOT NULL, + published DATETIME, + self_id BIGINT UNSIGNED NOT NULL, + ca_detail_id BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (ghostbuster_id), + CONSTRAINT ghostbuster_self_id + FOREIGN KEY (self_id) REFERENCES self (self_id) ON DELETE CASCADE, + CONSTRAINT ghostbuster_ca_detail_id + FOREIGN KEY (ca_detail_id) REFERENCES ca_detail (ca_detail_id) ON DELETE CASCADE + ) ENGINE=InnoDB; +""") |