summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Uiterwijk <puiterwijk@redhat.com>2015-03-30 16:38:10 +0200
committerRob Crittenden <rcritten@redhat.com>2015-03-30 14:20:11 -0400
commit3fd51fe0d4593cdc39c28f11deafe27845f25584 (patch)
treeba17bf07693aa8fd3c09863ce21b2445f7e6400d
parentdb41f6ea5ac2b4648350900791e32a83d0974e14 (diff)
downloadipsilon-3fd51fe0d4593cdc39c28f11deafe27845f25584.zip
ipsilon-3fd51fe0d4593cdc39c28f11deafe27845f25584.tar.gz
ipsilon-3fd51fe0d4593cdc39c28f11deafe27845f25584.tar.xz
Add options to explicitly set database uris during install
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>
-rwxr-xr-xipsilon/install/ipsilon-server-install20
-rw-r--r--ipsilon/providers/openidp.py7
-rw-r--r--ipsilon/util/data.py1
-rwxr-xr-xtests/helpers/common.py2
-rwxr-xr-xtests/pgdb.py1
5 files changed, 22 insertions, 9 deletions
diff --git a/ipsilon/install/ipsilon-server-install b/ipsilon/install/ipsilon-server-install
index 8f915f3..56b0dd1 100755
--- a/ipsilon/install/ipsilon-server-install
+++ b/ipsilon/install/ipsilon-server-install
@@ -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 = []
diff --git a/ipsilon/providers/openidp.py b/ipsilon/providers/openidp.py
index f79435f..4e47d3e 100644
--- a/ipsilon/providers/openidp.py
+++ b/ipsilon/providers/openidp.py
@@ -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
diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py
index 94d402b..72e7f96 100644
--- a/ipsilon/util/data.py
+++ b/ipsilon/util/data.py
@@ -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()
diff --git a/tests/helpers/common.py b/tests/helpers/common.py
index f3799c4..4cf27f9 100755
--- a/tests/helpers/common.py
+++ b/tests/helpers/common.py
@@ -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)
diff --git a/tests/pgdb.py b/tests/pgdb.py
index 14ffd36..a738052 100755
--- a/tests/pgdb.py
+++ b/tests/pgdb.py
@@ -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',