summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-09-23 15:14:53 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-09-23 15:14:53 (GMT)
commit1cd487981b53d3e453132393faa2742aac083deb (patch)
tree25a4ccf16ab7083d3bcab025868b7a3f94d1ad05
parent10065c30df1fe22d111ea5ddd8648c9af06bd24a (diff)
downloadpykolab-1cd487981b53d3e453132393faa2742aac083deb.tar.gz
Update dynamicquota plugin to obey LDAP changes to quota
-rw-r--r--pykolab/plugins/dynamicquota/__init__.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/pykolab/plugins/dynamicquota/__init__.py b/pykolab/plugins/dynamicquota/__init__.py
index c55b899..2343ce2 100644
--- a/pykolab/plugins/dynamicquota/__init__.py
+++ b/pykolab/plugins/dynamicquota/__init__.py
@@ -48,6 +48,12 @@ class KolabDynamicquota(object):
if not kw.has_key(keyword):
log.warning(_("No keyword %s passed to set_user_folder_quota") %(keyword))
return 0
+ else:
+ try:
+ kw[keyword] = (int)(kw[keyword])
+ except:
+ log.error(_("Quota '%s' not an integer!") %(keyword))
+ return 0
# Escape the user without quota
if kw['new_quota'] == 0:
@@ -56,7 +62,6 @@ class KolabDynamicquota(object):
log.info(_("The new quota was set to 0, but default quota > 0, returning default quota"))
return kw['default_quota']
- #print "new quota is 0, and default quota is no larger then 0, returning 0"
return 0
# Make your adjustments here, for example:
@@ -65,16 +70,20 @@ class KolabDynamicquota(object):
# is over 90%
if kw['new_quota'] < int(float(kw['used']) * 1.1):
- #print "new quota is smaller then 110%% of what is currently used, returning 110%% of used"
- new_quota = int(float(kw['used']) * 1.1)
+ _new_quota = int(float(kw['used']) * 1.1)
elif kw['new_quota'] > int(float(kw['used']) * 1.1):
# TODO: If the current quota in IMAP had been set to 0, but we want to apply quota, and
# 0 is current_quota, 90% of that is still 0...
- #print "new quota is larger then 110%% of what is currently used, returning 90%% of current quota"
- new_quota = int(float(kw['current_quota']) * 0.9)
+ _new_quota = int(float(kw['current_quota']) * 0.9)
- if kw['default_quota'] > new_quota:
- log.info(_("The default quota is larger then the calculated new quota, using the default quota"))
- return kw['default_quota']
+ if kw['new_quota'] == 0:
+ if kw['default_quota'] > _new_quota:
+ log.info(_("The default quota is larger then the calculated new quota, using the default quota"))
+ return kw['default_quota']
+
+ else:
+ new_quota = _new_quota
+ else:
+ new_quota = kw['new_quota']
return new_quota