From e7ae0054b5e83eb90d13e99ede1e5cdd77bc0a88 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 4 Jan 2015 18:06:44 +0100 Subject: [PATCH] add mysqltasks and pgsqltasks with placeholders for the real tasks --- gnuviechadmin/gnuviechadmin/settings/base.py | 2 + gnuviechadmin/mysqltasks/__init__.py | 4 ++ gnuviechadmin/mysqltasks/models.py | 4 ++ gnuviechadmin/mysqltasks/tasks.py | 72 ++++++++++++++++++++ gnuviechadmin/pgsqltasks/__init__.py | 4 ++ gnuviechadmin/pgsqltasks/models.py | 4 ++ gnuviechadmin/pgsqltasks/tasks.py | 72 ++++++++++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 gnuviechadmin/mysqltasks/__init__.py create mode 100644 gnuviechadmin/mysqltasks/models.py create mode 100644 gnuviechadmin/mysqltasks/tasks.py create mode 100644 gnuviechadmin/pgsqltasks/__init__.py create mode 100644 gnuviechadmin/pgsqltasks/models.py create mode 100644 gnuviechadmin/pgsqltasks/tasks.py diff --git a/gnuviechadmin/gnuviechadmin/settings/base.py b/gnuviechadmin/gnuviechadmin/settings/base.py index 8715186..cfd72f7 100644 --- a/gnuviechadmin/gnuviechadmin/settings/base.py +++ b/gnuviechadmin/gnuviechadmin/settings/base.py @@ -225,6 +225,8 @@ DJANGO_APPS = ( # Apps specific for this project go here. LOCAL_APPS = ( 'taskresults', + 'mysqltasks', + 'pgsqltasks', 'domains', 'osusers', 'managemails', diff --git a/gnuviechadmin/mysqltasks/__init__.py b/gnuviechadmin/mysqltasks/__init__.py new file mode 100644 index 0000000..9bc503f --- /dev/null +++ b/gnuviechadmin/mysqltasks/__init__.py @@ -0,0 +1,4 @@ +""" +This module contains :py:mod:`mysqltasks.tasks`. + +""" diff --git a/gnuviechadmin/mysqltasks/models.py b/gnuviechadmin/mysqltasks/models.py new file mode 100644 index 0000000..cf80bcf --- /dev/null +++ b/gnuviechadmin/mysqltasks/models.py @@ -0,0 +1,4 @@ +""" +Empty models to make Django accept mysqltasks as an app. + +""" diff --git a/gnuviechadmin/mysqltasks/tasks.py b/gnuviechadmin/mysqltasks/tasks.py new file mode 100644 index 0000000..cda59d4 --- /dev/null +++ b/gnuviechadmin/mysqltasks/tasks.py @@ -0,0 +1,72 @@ +""" +This module defines Celery_ tasks to manage MySQL users and databases. + +""" +from __future__ import absolute_import + +from celery import shared_task + + +@shared_task +def create_mysql_user(username, password): + """ + This task creates a new MySQL user. + + :param str username: the user name + :param str password: the password + :return: the created user's name + :rtype: str + + """ + + +@shared_task +def set_mysql_userpassword(username, password): + """ + Set a new password for an existing MySQL user. + + :param str username: the user name + :param str password: the password + :return: True if the password could be set, False otherwise + :rtype: boolean + + """ + + +@shared_task +def delete_mysql_user(username): + """ + This task deletes an existing MySQL user. + + :param str username: the user name + :return: True if the user has been deleted, False otherwise + :rtype: boolean + + """ + + +@shared_task +def create_mysql_database(dbname, username): + """ + This task creates a new MySQL database for the given MySQL user. + + :param str dbname: database name + :param str username: the user name of an existing MySQL user + :return: the database name + :rtype: str + + """ + + +@shared_task +def delete_mysql_database(dbname, username): + """ + This task deletes an existing MySQL database and revokes privileges of the + given user on that database. + + :param str dbname: database name + :param str username: the user name of an existing MySQL user + :return: True if the database has been deleted, False otherwise + :rtype: boolean + + """ diff --git a/gnuviechadmin/pgsqltasks/__init__.py b/gnuviechadmin/pgsqltasks/__init__.py new file mode 100644 index 0000000..c49a650 --- /dev/null +++ b/gnuviechadmin/pgsqltasks/__init__.py @@ -0,0 +1,4 @@ +""" +This module contains :py:mod:`pgsqltasks.tasks`. + +""" diff --git a/gnuviechadmin/pgsqltasks/models.py b/gnuviechadmin/pgsqltasks/models.py new file mode 100644 index 0000000..3a43087 --- /dev/null +++ b/gnuviechadmin/pgsqltasks/models.py @@ -0,0 +1,4 @@ +""" +Empty models to make Django accept pgsqltasks as an app. + +""" diff --git a/gnuviechadmin/pgsqltasks/tasks.py b/gnuviechadmin/pgsqltasks/tasks.py new file mode 100644 index 0000000..039b74a --- /dev/null +++ b/gnuviechadmin/pgsqltasks/tasks.py @@ -0,0 +1,72 @@ +""" +This module defines Celery_ tasks to manage PostgreSQL users and databases. + +""" +from __future__ import absolute_import + +from celery import shared_task + + +@shared_task +def create_pgsql_user(username, password): + """ + This task creates a new PostgreSQL user. + + :param str username: the user name + :param str password: the password + :return: the created user's name + :rtype: str + + """ + + +@shared_task +def set_pgsql_userpassword(username, password): + """ + Set a new password for an existing PostgreSQL user. + + :param str username: the user name + :param str password: the password + :return: True if the password could be set, False otherwise + :rtype: boolean + + """ + + +@shared_task +def delete_pgsql_user(username): + """ + This task deletes an existing PostgreSQL user. + + :param str username: the user name + :return: True if the user has been deleted, False otherwise + :rtype: boolean + + """ + + +@shared_task +def create_pgsql_database(dbname, username): + """ + This task creates a new PostgreSQL database for the given PostgreSQL user. + + :param str dbname: database name + :param str username: the user name of an existing PostgreSQL user + :return: the database name + :rtype: str + + """ + + +@shared_task +def delete_pgsql_database(dbname, username): + """ + This task deletes an existing PostgreSQL database and revokes privileges of + the given user on that database. + + :param str dbname: database name + :param str username: the user name of an existing PostgreSQL user + :return: True if the database has been deleted, False otherwise + :rtype: boolean + + """