Merge branch 'release/0.2.0' into production

* release/0.2.0:
  set release version
  document new task in changelog
  implement new task osusers.tasks.delete_ldap_group
  define celery timezone, restrict celery content to json
  add missing django bootstrap for documentation building
  use celery routers from gvacommon
  initial version
This commit is contained in:
Jan Dittberner 2014-12-29 15:18:53 +01:00
commit 8891a33b7c
7 changed files with 62 additions and 25 deletions

View file

@ -1,6 +1,10 @@
Changelog Changelog
========= =========
* :release:`0.2.0 <2014-12-29>`
* :feature:`-` add task :py:func:`osusers.tasks.delete_ldap_group`
* :support:`-` use celery routers from gvacommon
* :release:`0.1.3 <2014-12-26>` * :release:`0.1.3 <2014-12-26>`
* :support:`-` add celery routing for file server tasks * :support:`-` add celery routing for file server tasks

View file

@ -14,6 +14,7 @@
import sys import sys
import os import os
import django
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
@ -23,6 +24,8 @@ sys.path.insert(0, os.path.abspath(os.path.join('..', 'gvaldap')))
os.environ['GVALDAP_ALLOWED_HOSTS'] = 'localhost' os.environ['GVALDAP_ALLOWED_HOSTS'] = 'localhost'
os.environ['GVALDAP_SERVER_EMAIL'] = 'root@localhost' os.environ['GVALDAP_SERVER_EMAIL'] = 'root@localhost'
django.setup()
# -- General configuration ----------------------------------------------------- # -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
@ -57,9 +60,9 @@ copyright = u'2014, Jan Dittberner'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1.3' version = '0.2'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1.3' release = '0.2.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

2
gvaldap/gvacommon/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.*.swp
*.pyc

View file

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
class LdapRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
if 'ldap' in task:
return {'exchange': 'ldap',
'exchange_type': 'direct',
'queue': 'ldap'}
return None
class FileRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
if 'file' in task:
return {'exchange': 'file',
'exchange_type': 'direct',
'queue': 'file'}
return None

View file

@ -291,10 +291,12 @@ CELERY_RESULT_BACKEND = 'amqp'
CELERY_RESULT_PERSISTENT = True CELERY_RESULT_PERSISTENT = True
CELERY_TASK_RESULT_EXPIRES = None CELERY_TASK_RESULT_EXPIRES = None
CELERY_ROUTES = ( CELERY_ROUTES = (
'osusers.tasks.LdapRouter', 'gvacommon.celeryrouters.LdapRouter',
'osusers.tasks.FileRouter', 'gvacommon.celeryrouters.FileRouter',
) )
CELERY_ACCEPT_CONTENT = ['pickle', 'yaml', 'json'] CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERAILIZER = 'json' CELERY_TASK_SERAILIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
########## END CELERY CONFIGURATION ########## END CELERY CONFIGURATION

View file

@ -21,26 +21,6 @@ from ldapentities.models import (
_logger = get_task_logger(__name__) _logger = get_task_logger(__name__)
class LdapRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
if 'ldap' in task:
return {'exchange': 'ldap',
'exchange_type': 'direct',
'queue': 'ldap'}
return None
class FileRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
if 'file' in task:
return {'exchange': 'file',
'exchange_type': 'direct',
'queue': 'file'}
return None
@shared_task @shared_task
def create_ldap_group(groupname, gid, descr): def create_ldap_group(groupname, gid, descr):
""" """
@ -237,3 +217,25 @@ def delete_ldap_group_if_empty(groupname):
ldapgroup.dn, len(ldapgroup.members)) ldapgroup.dn, len(ldapgroup.members))
) )
return False return False
@shared_task
def delete_ldap_group(groupname):
"""
This taks deletes the given group.
:param str groupname: the group name
:return: True if the user has been deleted, False otherwise
:rtype: boolean
"""
try:
ldapgroup = LdapGroup.objects.get(name=groupname)
except LdapGroup.DoesNotExist:
_logger.info('ldap group with name {0} does not exist'.format(
groupname)
)
else:
ldapgroup.delete()
return True
return False