From bbdc690a1f69c9e7f286a5fbd0cb64403d51c721 Mon Sep 17 00:00:00 2001 From: Marian Sigler Date: Fri, 28 Sep 2012 01:41:09 +0200 Subject: move ldap settings from account.py to config --- account.py | 4 ---- app.py | 4 ++-- contrib/munin/accounts.py | 16 +++++++++++----- default_settings.py | 5 +++++ 4 files changed, 18 insertions(+), 11 deletions(-) mode change 100644 => 100755 contrib/munin/accounts.py diff --git a/account.py b/account.py index f25e170..bd837d9 100644 --- a/account.py +++ b/account.py @@ -4,10 +4,6 @@ from utils import Service from uuid import uuid4 -LDAP_HOST = 'ldap://localhost:5678' -LDAP_BASE_DN = [('dc','account'),('dc','spline'),('dc','inf'),('dc','fu-berlin'),('dc','de')] -LDAP_ADMIN_USER = 'admin' -LDAP_ADMIN_PASS = 'admin' SERVICES = [ Service('foren', 'Foren', 'http://foren.spline.de/'), Service('jabber', 'Jabber', 'http://jabber.spline.de/'), diff --git a/app.py b/app.py index 4a3a962..4c93ccf 100644 --- a/app.py +++ b/app.py @@ -20,8 +20,8 @@ app.all_services = account.SERVICES #TODO: take that from our json file or so @app.before_request def ldap_connect(): - g.ldap = account.AccountService(account.LDAP_HOST, account.LDAP_BASE_DN, - account.LDAP_ADMIN_USER, account.LDAP_ADMIN_PASS, app.all_services) + g.ldap = account.AccountService(app.config['LDAP_HOST'], app.config['LDAP_BASE_DN'], + app.config['LDAP_ADMIN_USER'], app.config['LDAP_ADMIN_PASS'], app.all_services) g.user = None diff --git a/contrib/munin/accounts.py b/contrib/munin/accounts.py old mode 100644 new mode 100755 index 947989b..684f278 --- a/contrib/munin/accounts.py +++ b/contrib/munin/accounts.py @@ -1,17 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- import sys from os.path import dirname, abspath sys.path.append(dirname(dirname(dirname(abspath(__file__))))) -from account import * +from account import AccountService +from app import app if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == 'config': - print('graph_title Splinux') - print('graph_vlabel Amount') + print('graph_title Spline Accounts') + print('graph_vlabel Number') print('accounts.label Accounts') else: - service = AccountService(LDAP_HOST, LDAP_BASE_DN, SERVICES, LDAP_ADMIN_USER, LDAP_ADMIN_PASS) + service = AccountService(app.config['LDAP_HOST'], app.config['LDAP_BASE_DN'], + app.config['LDAP_ADMIN_USER'], app.config['LDAP_ADMIN_PASS'], + app.all_services) + accounts = service.find() - print('accounts.value %s' % len(accounts)) + print('accounts.value %d' % len(accounts)) diff --git a/default_settings.py b/default_settings.py index 6fc80c3..002cc0c 100644 --- a/default_settings.py +++ b/default_settings.py @@ -7,3 +7,8 @@ MAIL_DEFAULT_SENDER = 'help-me-help-me-please@spline.de' MAIL_CONFIRM_SENDER = 'spline accounts ' SENDMAIL_COMMAND = '/usr/sbin/sendmail' + +LDAP_HOST = 'ldap://localhost:5678' +LDAP_BASE_DN = [('dc','account'),('dc','spline'),('dc','inf'),('dc','fu-berlin'),('dc','de')] +LDAP_ADMIN_USER = 'admin' +LDAP_ADMIN_PASS = 'admin' -- cgit v1.2.3-1-g7c22