Add options to explicitly set database uris during install
authorPatrick Uiterwijk <puiterwijk@redhat.com>
Mon, 30 Mar 2015 14:38:10 +0000 (16:38 +0200)
committerRob Crittenden <rcritten@redhat.com>
Mon, 30 Mar 2015 18:20:11 +0000 (14:20 -0400)
Also offer the option to set the OpenID database URI during install

https://fedorahosted.org/ipsilon/ticket/17

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
ipsilon/install/ipsilon-server-install
ipsilon/providers/openidp.py
ipsilon/util/data.py
tests/helpers/common.py
tests/pgdb.py

index 8f915f3..56b0dd1 100755 (executable)
@@ -109,15 +109,14 @@ def install(plugins, args):
                 'sysuser': args['system_user'],
                 'ipsilondir': BINDIR,
                 'staticdir': STATICDIR,
-                'admindb': args['database_url'] % {
+                'admindb': args['admin_dburi'] or args['database_url'] % {
                     'datadir': args['data_dir'], 'dbname': 'adminconfig'},
-                'usersdb': args['database_url'] % {
+                'usersdb': args['users_dburi'] or args['database_url'] % {
                     'datadir': args['data_dir'], 'dbname': 'userprefs'},
-                'transdb': args['database_url'] % {
-                    'datadir': args['data_dir'], 'dbname': 'transactions'},
+                'transdb': args['transaction_dburi'] or args['database_url'] %
+                {'datadir': args['data_dir'], 'dbname': 'transactions'},
                 'secure': "False" if args['secure'] == "no" else "True",
-                'debugging': "True" if args['server_debugging'] else "False",
-               }
+                'debugging': "True" if args['server_debugging'] else "False"}
     # Testing database sessions
     if 'session_type' in args:
         confopts['sesstype'] = args['session_type']
@@ -129,7 +128,7 @@ def install(plugins, args):
     else:
         confopts['sessopt'] = 'path'
         confopts['sessval'] = os.path.join(args['data_dir'], 'sessions')
-    # Whetehr to disable security (for testing)
+    # Whether to disable security (for testing)
     if args['secure'] == 'no':
         confopts['secure'] = "False"
         confopts['sslrequiressl'] = ""
@@ -326,6 +325,13 @@ def parse_args(plugins):
                         help="Uninstall the server and all data")
     parser.add_argument('--yes', action='store_true',
                         help="Always answer yes")
+    parser.add_argument('--admin-dburi',
+                        help='Configuration database URI (override template)')
+    parser.add_argument('--users-dburi',
+                        help='User configuration database URI (override '
+                             'template)')
+    parser.add_argument('--transaction-dburi',
+                        help='Transaction database URI (override template)')
 
     lms = []
 
index f79435f..4e47d3e 100644 (file)
@@ -141,6 +141,8 @@ class Installer(ProviderInstaller):
     def install_args(self, group):
         group.add_argument('--openid', choices=['yes', 'no'], default='yes',
                            help='Configure OpenID Provider')
+        group.add_argument('--openid-dburi',
+                           help='OpenID database URI')
 
     def configure(self, opts):
         if opts['openid'] != 'yes':
@@ -158,7 +160,10 @@ class Installer(ProviderInstaller):
         po.wipe_data()
         po.wipe_config_values()
         config = {'endpoint url': url,
-                  'identity_url_template': '%sid/%%(username)s' % url}
+                  'identity_url_template': '%sid/%%(username)s' % url,
+                  'database url': opts['openid_dburi'] or
+                  opts['database_url'] % {
+                      'datadir': opts['data_dir'], 'dbname': 'openid'}}
         po.save_plugin_config(config)
 
         # Update global config to add login plugin
index 94d402b..72e7f96 100644 (file)
@@ -398,6 +398,7 @@ class Store(Log):
             self.error("Failed to delete data from %s: [%s]" % (table, e))
 
     def _reset_data(self, table):
+        q = None
         try:
             q = self._query(self._db, table, UNIQUE_DATA_COLUMNS)
             q.drop()
index f3799c4..4cf27f9 100755 (executable)
@@ -143,7 +143,7 @@ class IpsilonTestBase(object):
                              env=env, preexec_fn=os.setsid)
         self.processes.append(p)
         p.wait()
-        for d in ['adminconfig', 'userprefs', 'transactions', 'sessions']:
+        for d in ['adminconfig', 'users', 'transactions', 'sessions']:
             cmd = ['/usr/bin/createdb', '-h', addr, '-p', port, d]
             subprocess.check_call(cmd, env=env)
 
index 14ffd36..a738052 100755 (executable)
@@ -36,6 +36,7 @@ idp_g = {'TEMPLATES': '${TESTDIR}/templates/install',
 
 
 idp_a = {'hostname': '${ADDRESS}:${PORT}',
+         'users_dburi': 'postgresql://@127.0.0.10:45432/users',
          'database_url': 'postgresql://@127.0.0.10:45432/%(dbname)s',
          'session_type': 'sql',
          'session_dburi': 'postgresql://@127.0.0.10:45432/sessions',