gva/gnuviechadmin/fileservertasks/tasks.py
Jan Dittberner d5bba7a22d asynchronous refactoring
- don't execute celery tasks directly
- introduce optional parameters to fileserver tasks to allow chaining
- handle user/group/key create and delete tasks in new osusers.signals
  class
- adapt unit tests
- change TaskResults model to store the task signatures
- generalize the local settings' logging configuration
2015-10-12 00:23:31 +02:00

135 lines
3.2 KiB
Python

"""
This module defines task stubs for the tasks implemented in the gvafile Celery
worker.
"""
from __future__ import absolute_import
from celery import shared_task
@shared_task
def setup_file_sftp_userdir(username, *args, **kwargs):
"""
This task creates the home directory for an SFTP user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_sftp_userdir(username, *args, **kwargs):
"""
This task recursively deletes the home directory of an SFTP user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def setup_file_mail_userdir(username, *args, **kwargs):
"""
This task creates the mail base directory for a user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the mail base directory for the user cannot be
created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_mail_userdir(username, *args, **kwargs):
"""
This task recursively deletes the mail base directory for a user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the mail base directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def create_file_mailbox(username, mailboxname):
"""
This task creates a new mailbox directory for the given user and mailbox
name.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises Exception: if the mailbox directory cannot be created
:return: the created mailbox directory name
:rtype: str
"""
@shared_task
def delete_file_mailbox(username, mailboxname):
"""
This task deletes the given mailbox of the given user.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises Exception: if the mailbox directory cannot be deleted
:return: the deleted mailbox directory name
:rtype: str
"""
@shared_task
def create_file_website_hierarchy(username, sitename):
"""
This task creates the directory hierarchy for a website.
:param str username: the user name
:param str sitename: name of the website
:return: the directory name
:rtype: str
"""
@shared_task
def delete_file_website_hierarchy(username, sitename):
"""
This task deletes the website hierarchy recursively.
:param str username: the user name
:param str sitename: name of the website
:return: the directory name
:rtype: str
"""
@shared_task
def set_file_ssh_authorized_keys(username, ssh_keys):
"""
This task sets the authorized keys for ssh logins.
:param str username: the user name
:param list ssh_key: an ssh_key
:raises Exception: if the update of the creation or update of ssh
authorized_keys failed
:return: the name of the authorized_keys file
:rtype: str
"""