diff options
Diffstat (limited to 'ipsilon/info')
-rwxr-xr-x | ipsilon/info/common.py | 52 | ||||
-rwxr-xr-x | ipsilon/info/infoldap.py | 26 | ||||
-rwxr-xr-x | ipsilon/info/nss.py | 24 |
3 files changed, 31 insertions, 71 deletions
diff --git a/ipsilon/info/common.py b/ipsilon/info/common.py index 586b9e5..a3a297f 100755 --- a/ipsilon/info/common.py +++ b/ipsilon/info/common.py @@ -11,40 +11,13 @@ from ipsilon.util.plugin import PluginObject, PluginConfig class InfoProviderBase(PluginConfig, PluginObject): - def __init__(self): + def __init__(self, *pargs): PluginConfig.__init__(self) - PluginObject.__init__(self) - self._site = None - self.is_enabled = False + PluginObject.__init__(self, *pargs) def get_user_attrs(self, user): raise NotImplementedError - def enable(self, site): - if self.is_enabled: - return - - if not self._site: - self._site = site - plugins = self._site[FACILITY] - - # configure self - if self.name in plugins['config']: - self.import_config(plugins['config'][self.name]) - - plugins['enabled'].append(self) - self.is_enabled = True - self.debug('Info plugin enabled: %s' % self.name) - - def disable(self, site): - if not self.is_enabled: - return - - plugins = self._site[FACILITY] - plugins['enabled'].remove(self) - self.is_enabled = False - self.debug('Info plugin disabled: %s' % self.name) - class InfoMapping(Log): @@ -96,23 +69,22 @@ class Info(Log): def __init__(self, site): self._site = site - loader = PluginLoader(Info, FACILITY, 'InfoProvider') - self._site[FACILITY] = loader.get_plugin_data() - plugins = self._site[FACILITY] + plugins = PluginLoader(Info, FACILITY, 'InfoProvider') + plugins.get_plugin_data() + self._site[FACILITY] = plugins - available = plugins['available'].keys() + available = plugins.available.keys() self.debug('Available info providers: %s' % str(available)) - plugins['root'] = self - for item in plugins['whitelist']: - self.debug('Login plugin in whitelist: %s' % item) - if item not in plugins['available']: + for item in plugins.enabled: + self.debug('Login plugin in enabled list: %s' % item) + if item not in plugins.available: self.debug('Info Plugin %s not found' % item) continue - plugins['available'][item].enable(self._site) + plugins.available[item].enable() def get_user_attrs(self, user, requested=None): - plugins = self._site[FACILITY]['available'] + plugins = self._site[FACILITY].available result = dict() for _, p in plugins.items(): @@ -146,5 +118,5 @@ class InfoProviderInstaller(object): class InfoProviderInstall(object): def __init__(self): - pi = PluginInstaller(InfoProviderInstall) + pi = PluginInstaller(InfoProviderInstall, FACILITY) self.plugins = pi.get_plugins() 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() diff --git a/ipsilon/info/nss.py b/ipsilon/info/nss.py index 3dfd885..50c84a8 100755 --- a/ipsilon/info/nss.py +++ b/ipsilon/info/nss.py @@ -20,8 +20,8 @@ posix_map = { 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(posix_map) self.name = 'nss' @@ -75,9 +75,10 @@ class InfoProvider(InfoProviderBase): class Installer(InfoProviderInstaller): - def __init__(self): + def __init__(self, *pargs): super(Installer, self).__init__() self.name = 'nss' + self.pargs = pargs def install_args(self, group): group.add_argument('--info-nss', choices=['yes', 'no'], default='no', @@ -88,18 +89,11 @@ class Installer(InfoProviderInstaller): return # Add configuration data to database - po = PluginObject() + po = PluginObject(*self.pargs) po.name = 'nss' po.wipe_data() - po.wipe_config_values(self.facility) + po.wipe_config_values() - # 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('nss') - 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() |