aboutsummaryrefslogtreecommitdiff
path: root/rpki/rpkic.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-09-14 00:28:56 +0000
committerRob Austein <sra@hactrn.net>2014-09-14 00:28:56 +0000
commit1ca764a9456512a3dbdcbf83e4a337cdfc982dbe (patch)
tree41652de28b3bf53f4aba4dfac42ca9c7c305e4fb /rpki/rpkic.py
parent773d3c3d01f39b1cedb7506ee7c1c3ceed91a17d (diff)
Start backing out all the old settings.configure() calls, which were
indeed masking the new migration stuff. yamltest now runs migrations as part of setting up test CAs; still need to decide whether running migrations in production is something that should be handled explicitly via rpki-manage or should be bundled into rpki-sql-setup. Old settings.configure() code still present as a trail of breadcrumbs to follow when backing out the rest of the tortuous startup sequence required by the old way of doing things. svn path=/branches/tk713/; revision=5950
Diffstat (limited to 'rpki/rpkic.py')
-rw-r--r--rpki/rpkic.py44
1 files changed, 29 insertions, 15 deletions
diff --git a/rpki/rpkic.py b/rpki/rpkic.py
index 62921308..fdde6056 100644
--- a/rpki/rpkic.py
+++ b/rpki/rpkic.py
@@ -132,19 +132,29 @@ class main(Cmd):
self.histfile = cfg.get("history_file", os.path.expanduser("~/.rpkic_history"))
self.autosync = cfg.getboolean("autosync", True, section = "rpkic")
- from django.conf import settings
-
- settings.configure(
- DATABASES = { "default" : {
- "ENGINE" : "django.db.backends.mysql",
- "NAME" : cfg.get("sql-database", section = "irdbd"),
- "USER" : cfg.get("sql-username", section = "irdbd"),
- "PASSWORD" : cfg.get("sql-password", section = "irdbd"),
- "HOST" : "",
- "PORT" : "",
- "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}},
- INSTALLED_APPS = ("rpki.irdb",),
- )
+ # This should go away now that we have rpki.django_settings, but
+ # let's get a verbose log with it present first to see what
+ # changes.
+
+ use_south = True
+ setup_db = False
+
+ if use_south:
+ os.environ.update(DJANGO_SETTINGS_MODULE = "rpki.django_settings")
+
+ else:
+ from django.conf import settings
+ settings.configure(
+ DATABASES = { "default" : {
+ "ENGINE" : "django.db.backends.mysql",
+ "NAME" : cfg.get("sql-database", section = "irdbd"),
+ "USER" : cfg.get("sql-username", section = "irdbd"),
+ "PASSWORD" : cfg.get("sql-password", section = "irdbd"),
+ "HOST" : "",
+ "PORT" : "",
+ "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}},
+ INSTALLED_APPS = ["rpki.irdb"])
+
import rpki.irdb # pylint: disable=W0621
@@ -166,8 +176,12 @@ class main(Cmd):
except rpki.config.ConfigParser.Error:
pass
- import django.core.management
- django.core.management.call_command("syncdb", verbosity = 0, load_initial_data = False)
+ if setup_db:
+ import django.core.management
+ django.core.management.call_command("syncdb", verbosity = 3, load_initial_data = False)
+
+ if setup_db and use_south:
+ django.core.management.call_command("migrate", verbosity = 3)
self.zoo = rpki.irdb.Zookeeper(cfg = cfg, handle = self.handle, logstream = sys.stdout)