diff options
author | Rob Austein <sra@hactrn.net> | 2014-09-14 00:28:56 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-09-14 00:28:56 +0000 |
commit | 1ca764a9456512a3dbdcbf83e4a337cdfc982dbe (patch) | |
tree | 41652de28b3bf53f4aba4dfac42ca9c7c305e4fb /rpki | |
parent | 773d3c3d01f39b1cedb7506ee7c1c3ceed91a17d (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')
-rw-r--r-- | rpki/gui/script_util.py | 44 | ||||
-rw-r--r-- | rpki/irdb/models.py | 5 | ||||
-rw-r--r-- | rpki/rpkic.py | 44 |
3 files changed, 60 insertions, 33 deletions
diff --git a/rpki/gui/script_util.py b/rpki/gui/script_util.py index c3a864fd..678ddae6 100644 --- a/rpki/gui/script_util.py +++ b/rpki/gui/script_util.py @@ -16,11 +16,6 @@ This module contains utility functions for use in standalone scripts. """ -from django.conf import settings - -from rpki import config -from rpki import autoconf - __version__ = '$Id$' @@ -28,16 +23,29 @@ def setup(): """ Configure Django enough to use the ORM. """ - cfg = config.parser(section='web_portal') - # INSTALLED_APPS doesn't seem necessary so long as you are only accessing - # existing tables. - settings.configure( - DATABASES={ - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': cfg.get('sql-database'), - 'USER': cfg.get('sql-username'), - 'PASSWORD': cfg.get('sql-password'), - } - }, - ) + + # In theory we no longer need to call settings.configure, which + # probably means this whole module can go away soon, but leave + # breadcrumbs for now. + + if True: + os.environ.update(DJANGO_SETTINGS_MODULE = "rpki.django_settings") + + else: + from rpki import config + from rpki import autoconf + from django.conf import settings + + cfg = config.parser(section='web_portal') + # INSTALLED_APPS doesn't seem necessary so long as you are only accessing + # existing tables. + settings.configure( + DATABASES={ + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': cfg.get('sql-database'), + 'USER': cfg.get('sql-username'), + 'PASSWORD': cfg.get('sql-password'), + } + }, + ) diff --git a/rpki/irdb/models.py b/rpki/irdb/models.py index 2db86ba8..f89cebd4 100644 --- a/rpki/irdb/models.py +++ b/rpki/irdb/models.py @@ -81,6 +81,11 @@ class SignedReferralField(DERField): description = "CMS signed object containing XML" rpki_type = rpki.x509.SignedReferral +# Alias to keep old rpki.gui migrations happy. Would generating a new +# schema migration for rpki.gui remove the need, or do we have to +# preserve every old field class we've ever used forever? Dunno. + +RSAKeyField = KeyField # Introspection rules for Django South 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) |