diff options
author | Simo Sorce <simo@redhat.com> | 2014-10-23 11:45:32 -0400 |
---|---|---|
committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2014-11-12 23:47:15 +0100 |
commit | 83da2bf3963db3e4427bced3b4c0681e751e54da (patch) | |
tree | 53f03ce8e60d2c68453cdb5fe6be9aad7ce2c362 /ipsilon/info/infoldap.py | |
parent | 0c14f7600de70baf5b3ee609288207dcdb65e1ae (diff) | |
download | ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.tar.gz ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.tar.xz ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.zip |
Refactor plugin configuration
Fork a PluginConfig class out of PluginObject, the base object now supports
a simple dictionary config, while using PluginConfig provide access to
structured util.config based configuration.
Change UI code that deal with plugins configuration to properly use the new
structured config objects in order to represent data in appropriate format
based on the data type.
Use the new util.config objects to represent plugins configuration.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'ipsilon/info/infoldap.py')
-rwxr-xr-x | ipsilon/info/infoldap.py | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/ipsilon/info/infoldap.py b/ipsilon/info/infoldap.py index 70d36d5..369d3f1 100755 --- a/ipsilon/info/infoldap.py +++ b/ipsilon/info/infoldap.py @@ -8,7 +8,7 @@ from ipsilon.info.common import InfoProviderBase from ipsilon.info.common import InfoProviderInstaller from ipsilon.info.common import InfoMapping from ipsilon.util.plugin import PluginObject -from ipsilon.util.log import Log +from ipsilon.util import config as pconfig import ldap @@ -27,7 +27,7 @@ ldap_mapping = { } -class InfoProvider(InfoProviderBase, Log): +class InfoProvider(InfoProviderBase): def __init__(self): super(InfoProvider, self).__init__() @@ -36,34 +36,29 @@ class InfoProvider(InfoProviderBase, Log): self.name = 'ldap' self.description = """ Info plugin that uses LDAP to retrieve user data. """ - self._options = { - 'server url': [ - """ The LDAP server url """, - 'string', - 'ldap://example.com' - ], - 'tls': [ - " What TLS level show be required " + - "(Demand, Allow, Try, Never, NoTLS) ", - 'string', - 'Demand' - ], - 'bind dn': [ - """ User DN to bind as, if empty uses anonymous bind. """, - 'string', - 'uid=ipsilon,ou=People,dc=example,dc=com' - ], - 'bind password': [ - """ Password to use for bind operation """, - 'string', - 'Password' - ], - 'user dn template': [ - """ Template to turn username into DN. """, - 'string', - 'uid=%(username)s,ou=People,dc=example,dc=com' - ], - } + self.new_config( + self.name, + pconfig.String( + 'server url', + 'The LDAP server url.', + 'ldap://example.com'), + pconfig.Template( + 'user dn template', + 'Template to turn username into DN.', + 'uid=%(username)s,ou=People,dc=example,dc=com'), + pconfig.Pick( + 'tls', + 'What TLS level show be required', + ['Demand', 'Allow', 'Try', 'Never', 'NoTLS'], + 'Demand'), + pconfig.String( + 'bind dn', + 'DN to bind as, if empty uses anonymous bind.', + 'uid=ipsilon,ou=People,dc=example,dc=com'), + pconfig.String( + 'bind password', + 'Password to use for bind operation'), + ) @property def server_url(self): |