summaryrefslogtreecommitdiffstats
path: root/ipsilon/info/infoldap.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-10-27 11:25:46 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2014-11-12 23:47:25 +0100
commitb7b80c5c0fc1895e85aae3acbfcbbc593a42697f (patch)
tree530512524a374059a9648ace99c56146af95bf4d /ipsilon/info/infoldap.py
parentc6b167fcf290c415b8d1903237fb5405b7213405 (diff)
downloadipsilon.git-b7b80c5c0fc1895e85aae3acbfcbbc593a42697f.tar.gz
ipsilon.git-b7b80c5c0fc1895e85aae3acbfcbbc593a42697f.tar.xz
ipsilon.git-b7b80c5c0fc1895e85aae3acbfcbbc593a42697f.zip
Refactor plugin initialization and enablement
Move most plugin enablement and initialization code in plugin.py to reduce code duplication and simplify and unifify plugin enablement for all base plugin types (login, info, providers). This patch breaks backwards compatibility as it changes how the list of enabled plugins is stored in the database tables. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'ipsilon/info/infoldap.py')
-rwxr-xr-xipsilon/info/infoldap.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/ipsilon/info/infoldap.py b/ipsilon/info/infoldap.py
index 369d3f1..da9819a 100755
--- a/ipsilon/info/infoldap.py
+++ b/ipsilon/info/infoldap.py
@@ -29,8 +29,8 @@ ldap_mapping = {
class InfoProvider(InfoProviderBase):
- def __init__(self):
- super(InfoProvider, self).__init__()
+ def __init__(self, *pargs):
+ super(InfoProvider, self).__init__(*pargs)
self.mapper = InfoMapping()
self.mapper.set_mapping(ldap_mapping)
self.name = 'ldap'
@@ -151,9 +151,10 @@ Info plugin that uses LDAP to retrieve user data. """
class Installer(InfoProviderInstaller):
- def __init__(self):
+ def __init__(self, *pargs):
super(Installer, self).__init__()
self.name = 'ldap'
+ self.pargs = pargs
def install_args(self, group):
group.add_argument('--info-ldap', choices=['yes', 'no'], default='no',
@@ -172,10 +173,10 @@ class Installer(InfoProviderInstaller):
return
# Add configuration data to database
- po = PluginObject()
+ po = PluginObject(*self.pargs)
po.name = 'ldap'
po.wipe_data()
- po.wipe_config_values(self.facility)
+ po.wipe_config_values()
config = dict()
if 'info_ldap_server_url' in opts:
config['server url'] = opts['info_ldap_server_url']
@@ -193,15 +194,8 @@ class Installer(InfoProviderInstaller):
elif 'ldap_bind_dn_template' in opts:
config['user dn template'] = opts['ldap_bind_dn_template']
config['tls'] = 'Demand'
- po.save_plugin_config(self.facility, config)
+ po.save_plugin_config(config)
- # Replace global config, only one plugin info can be used
- po.name = 'global'
- globalconf = po.get_plugin_config(self.facility)
- if 'order' in globalconf:
- order = globalconf['order'].split(',')
- else:
- order = []
- order.append('ldap')
- globalconf['order'] = ','.join(order)
- po.save_plugin_config(self.facility, globalconf)
+ # Update global config to add login plugin
+ po.is_enabled = True
+ po.save_enabled_state()