dragonresearch / rpki.net

Dragon Research Labs rpki.net RPKI toolkit
54 stars 25 forks source link

gui can't deal with managing a handle with the root cert #332

Closed sraustein closed 11 years ago

sraustein commented 11 years ago

opening a new ticket for the gui related problem discussed in #315

Trac ticket #316 component gui priority critical, owner melkins, created by melkins on 2012-11-09T18:41:01Z, last modified 2012-11-12T03:13:18Z

sraustein commented 11 years ago

added new branch tk316 for work on this issue

Trac comment by melkins on 2012-11-09T18:42:48Z

sraustein commented 11 years ago

this is just to confuse me :)

Trac comment by randy on 2012-11-10T04:21:46Z

sraustein commented 11 years ago

I think I am ready to have you test my changes to allow managing the root handle. In order to do this, there will be some additional steps. Note that some of the command depend on whether your are upgrading your existing database, or starting a new installation from scratch.

[All users] First step is you will need to install Django South. For FreeBSD this is /usr/ports/databases/py-south.

The code is currently in the tk316 branch, so in order to play, you will need to check it out:

{{{

svn co https://subvert-rpki.hactrn.net/branches/tk316

cd tk316

./configure

make

make install

}}}

[Upgrading users] You will need to edit /usr/local/etc/rpki/settings.py and add 'south' to the INSTALLED_APPS list. See /usr/local/etc/rpki/settings.py.new for an example (we don't automatically overwrite settings.py).

[All users] Run syncdb: {{{

django-admin syncdb --pythonpath=/usr/local/etc --settings=settings

}}}

Verify that Django South is installed: {{{

django-admin migrate --list --pythonpath=/usr/local/etc --settings=settings

}}}

[Upgrading Users] Since you already have an existing db, you need to fake doing the initial migration step: {{{

django-admin migrate app 0001 --fake --pythonpath=/usr/local/etc --settings=settings

}}}

[All users] Perform the database migrations new to this release: {{{

django-admin migrate app --pythonpath=/usr/local/etc --settings=settings

}}}

[All users] Restart apache so that the web portal picks up the newly installed code: {{{

apachectl restart

}}}

Now head back to the gui. Click on the 'refresh' link when viewing the altCA dashboard, and it should now pick up the resources from the root cert.

Trac comment by melkins on 2012-11-10T04:26:25Z

sraustein commented 11 years ago

On Sat, Nov 10, 2012 at 04:21:46AM -0000, Trac Ticket System wrote:

this is just to confuse me :)

sorry, i was just moving the discussion in #315 about the gui to this ticket because #315 did not start out about the gui, it was about configuring rootd.

Trac comment by melkins on 2012-11-10T04:27:22Z

sraustein commented 11 years ago

[Upgrading users] You will need to edit /usr/local/etc/rpki/settings.py and add 'south' to the INSTALLED_APPS list. See /usr/local/etc/rpki/settings.py.new for an example (we don't automatically overwrite settings.py).

[All users] Run syncdb: {{{

django-admin syncdb --pythonpath=/usr/local/etc --settings=settings

}}}

Verify that Django South is installed: {{{

django-admin migrate --list --pythonpath=/usr/local/etc

--settings=settings }}}

ca0.rpki.net:/usr/local/src/net/tk316# cat rpkid/portal-gui/settings.py > /usr/local/etc/rpki/settings.py

ca0.rpki.net:/usr/local/src/net/tk316# cd /usr/local/etc/rpki

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc --settings=settings Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 5, in management.execute_from_command_line() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module import(name) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in from django.db import models File "/usr/local/lib/python2.7/site-packages/django/db/init.py", line 11, in if DEFAULT_DB_ALIAS not in settings.DATABASES: File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner self._setup() File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 95, in init raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc --settings=settings.py Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 5, in management.execute_from_command_line() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module import(name) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in from django.db import models File "/usr/local/lib/python2.7/site-packages/django/db/init.py", line 11, in if DEFAULT_DB_ALIAS not in settings.DATABASES: File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner self._setup() File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 95, in init raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named settings.py

Trac comment by randy on 2012-11-10T05:30:16Z

sraustein commented 11 years ago

django-admin syncdb --pythonpath=/usr/local/etc --settings=settings

crap, change all those to /usr/local/etc/rpki

Trac comment by melkins on 2012-11-10T05:39:56Z

sraustein commented 11 years ago

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=/usr/local/etc/rpki/settings.py Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 5, in management.execute_from_command_line() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module import(name) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in from django.db import models File "/usr/local/lib/python2.7/site-packages/django/db/init.py", line 11, in if DEFAULT_DB_ALIAS not in settings.DATABASES: File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner self._setup() File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 95, in init raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings '/usr/local/etc/rpki/settings.py' (Is it on sys.path?): Import by filename is not supported.

Trac comment by randy on 2012-11-10T05:50:34Z

sraustein commented 11 years ago

On Sat, Nov 10, 2012 at 05:50:34AM -0000, Trac Ticket System wrote:

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=/usr/local/etc/rpki/settings.py

settings is relative to pythonpath:

django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=settings

Trac comment by melkins on 2012-11-10T05:52:25Z

sraustein commented 11 years ago

sorry, i had tried that

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=settings.py Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 5, in management.execute_from_command_line() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module import(name) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in from django.db import models File "/usr/local/lib/python2.7/site-packages/django/db/init.py", line 11, in if DEFAULT_DB_ALIAS not in settings.DATABASES: File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner self._setup() File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 95, in init raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named py

Trac comment by randy on 2012-11-10T05:56:50Z

sraustein commented 11 years ago

On Sat, Nov 10, 2012 at 05:56:50AM -0000, Trac Ticket System wrote:

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=settings.py

no .py suffix

Trac comment by melkins on 2012-11-10T05:58:05Z

sraustein commented 11 years ago

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=settings Error: No module named south

Trac comment by randy on 2012-11-10T06:03:42Z

sraustein commented 11 years ago

you missed a step from the instructions:

{{{ [All users] First step is you will need to install Django South. For FreeBSD this is /usr/ports/databases/py-south. }}}

Trac comment by melkins on 2012-11-10T06:09:12Z

sraustein commented 11 years ago

aiiiiii

Trac comment by randy on 2012-11-10T06:10:21Z

sraustein commented 11 years ago

whew! ok, next step.

Trac comment by randy on 2012-11-10T06:16:53Z

sraustein commented 11 years ago

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py syncdb --pythonpath=/usr/local/etc/rpki --settings=settings Syncing... Creating tables ... Creating table south_migrationhistory Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)

Synced:

django.contrib.auth django.contrib.contenttypes django.contrib.sessions rpki.irdb rpki.gui.app rpki.gui.cacheview rpki.gui.routeview south

Not synced (use migrations):

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py migrate --list --pythonpath=/usr/local/etc/rpki --settings=settings

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py migrate app 0001 --fake --pythonpath=/usr/local/etc/rpki --settings=settings The app 'app' does not appear to use migrations. ./manage.py migrate [appname] [migrationname|zero] [--all] [--list] [--skip] [--merge] [--no-initial-data] [--fake] [--db-dry-run] [--database=dbalias]

Trac comment by randy on 2012-11-10T06:19:58Z

sraustein commented 11 years ago

svn up

make

make install

note that i added a new rpki-manage script which is a wrapper around django-admin so you don't need the --pythonpath= or --settings if you use that

Trac comment by melkins on 2012-11-10T06:27:12Z

sraustein commented 11 years ago

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py migrate app 0001 --fake --pythonpath=/usr/local/etc/rpki --settings=settings

ca0.rpki.net:/usr/local/etc/rpki# django-admin.py migrate app --pythonpath=/usr/local/etc/rpki --settings=settings Running migrations for app:

apachectl restart

logged into gui fresh

i haz resources!!!

i will do the doc page, cool?

randy

Trac comment by randy on 2012-11-10T06:33:56Z

sraustein commented 11 years ago

and will you merge, or sep tree for a while?

Trac comment by randy on 2012-11-10T06:34:24Z

sraustein commented 11 years ago

i haz resources!!!

huzzah!

i will do the doc page, cool?

yup.

Trac comment by melkins on 2012-11-10T06:35:36Z

sraustein commented 11 years ago

and will you merge, or sep tree for a while?

sep tree until i can get sra to review.

Trac comment by melkins on 2012-11-10T06:36:55Z

sraustein commented 11 years ago

i have updated https://trac.rpki.net/wiki/doc/RPKI/CA/UI/GUI

Trac comment by randy on 2012-11-10T06:44:11Z

sraustein commented 11 years ago

and will you merge, or sep tree for a while?

sep tree until i can get sra to review.

The parts I understand look reasonable :)

Not sure why you went with a new "conf" field instead of a foreign key to the resource holder, but your code, your call.

I made one stylistic tweak to your change to rpki.irdb.models (my mommy told me never to write "then if" when I could avoid it).

I'd say if you're confident that this code works, go for merge.

Trac comment by sra on 2012-11-10T14:43:21Z

sraustein commented 11 years ago

Not sure why you went with a new "conf" field instead of a foreign key to the resource holder, but your code, your call.

implementation detail: Conf is just a proxy model for ResourceHolderCA. All it does is add a few methods I need in my django app.

Trac comment by melkins on 2012-11-10T14:53:19Z

sraustein commented 11 years ago

I made one stylistic tweak to your change to rpki.irdb.models (my mommy told me never to write "then if" when I could avoid it).

  • if isinstance(kwargs.get("choices"), (tuple, list)) and isinstance(kwargs["choices"][0], str):
  • kwargs["choices"] = tuple(enumerate(kwargs["choices"], 1))

i think this is not going to work because if choices is not present, kwargs.get() is going to raise an exception. i sent you a separate email, but South will call the constructor with the 'choices' keyword argument stripped as part of the process of doing db migration. kwargs.get("choices", None) should workd though.

Trac comment by melkins on 2012-11-10T15:00:28Z

sraustein commented 11 years ago
  • if isinstance(kwargs.get("choices"), (tuple, list)) and isinstance(kwargs["choices"][0], str):
  • kwargs["choices"] = tuple(enumerate(kwargs["choices"], 1))

    i think this is not going to work because if choices is not present, kwargs.get() is going to raise an exception.

Assuming kwargs is a normal Python dict, kwargs.get("foo") returns None if foo is not present.

Trac comment by sra on 2012-11-10T15:14:45Z

sraustein commented 11 years ago

In [changeset:4846]: {{{

!CommitTicketReference repository="" revision="4846"

merge ^/branches/tk316

closes #316 closes #317 }}}

Trac comment by melkins on 2012-11-12T03:13:18Z

sraustein commented 11 years ago

Closed with resolution fixed