blob: 6dbaf938422a73d739e30dc8d53f1f91728a1407 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/python
#
# Copyright (C) 2014 Ipsilon Project Contributors
#
# See the file named COPYING for the project license
from ipsilon.util.log import Log
from ipsilon.util.plugin import PluginLoader, PluginObject
from ipsilon.util.plugin import PluginInstaller
class InfoProviderBase(PluginObject):
def __init__(self):
super(InfoProviderBase, self).__init__()
def get_user_attrs(self, user):
raise NotImplementedError
FACILITY = 'info_config'
class Info(Log):
def __init__(self, *args, **kwargs):
self.providers = []
loader = PluginLoader(Info, FACILITY, 'InfoProvider')
plugins = loader.get_plugin_data()
available = plugins['available'].keys()
self.debug('Available info providers: %s' % str(available))
for item in plugins['whitelist']:
self.debug('Login plugin in whitelist: %s' % item)
if item not in plugins['available']:
self.debug('Info Plugin %s not found' % item)
continue
self.providers.append((item, plugins['available'][item]))
self.debug('Added Info plugin: %s' % item)
def get_user_attrs(self, user, provider=None):
if provider:
for p in self.providers:
if p[0] == provider:
return p[1].get_user_attrs(user)
else:
for p in self.providers:
ret = p[1].get_user_attrs(user)
if ret:
return ret
return None
class InfoProviderInstaller(object):
def __init__(self):
self.facility = FACILITY
self.ptype = 'info'
self.name = None
def install_args(self, group):
raise NotImplementedError
def configure(self, opts):
raise NotImplementedError
class InfoProviderInstall(object):
def __init__(self):
pi = PluginInstaller(InfoProviderInstall)
self.plugins = pi.get_plugins()
|