Renamed backends to controllers

This commit is contained in:
Marc Aymerich 2016-03-08 10:16:49 +00:00
parent 5e2ec5797f
commit 1bb6b9f849
34 changed files with 73 additions and 76 deletions

View File

@ -306,7 +306,7 @@ method(
arg, arg, arg) arg, arg, arg)
Bash/Python/PHPBackend Bash/Python/PHPController
# services.handler as generator in order to save memory? not swell like a balloon # services.handler as generator in order to save memory? not swell like a balloon
@ -431,6 +431,3 @@ mkhomedir_helper or create ssh homes with bash.rc and such
# Automatically re-run backends until success? only timedout executions? # Automatically re-run backends until success? only timedout executions?
# TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects # TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects
# Rename Backend -> COntroller

View File

@ -8,7 +8,7 @@ from orchestra.contrib.resources import ServiceMonitor
from . import settings from . import settings
class MySQLBackend(ServiceController): class MySQLController(ServiceController):
""" """
Simple backend for creating MySQL databases using <tt>CREATE DATABASE</tt> statement. Simple backend for creating MySQL databases using <tt>CREATE DATABASE</tt> statement.
""" """
@ -58,7 +58,7 @@ class MySQLBackend(ServiceController):
mysql -e 'FLUSH PRIVILEGES;'\ mysql -e 'FLUSH PRIVILEGES;'\
""") """)
) )
super(MySQLBackend, self).commit() super(MySQLController, self).commit()
def get_context(self, database): def get_context(self, database):
context = { context = {
@ -68,7 +68,7 @@ class MySQLBackend(ServiceController):
return replace(replace(context, "'", '"'), ';', '') return replace(replace(context, "'", '"'), ';', '')
class MySQLUserBackend(ServiceController): class MySQLUserController(ServiceController):
""" """
Simple backend for creating MySQL users using <tt>CREATE USER</tt> statement. Simple backend for creating MySQL users using <tt>CREATE USER</tt> statement.
""" """

View File

@ -135,11 +135,11 @@ class DatabaseTestMixin(object):
self.validate_create_table(dbname, username2, password2) self.validate_create_table(dbname, username2, password2)
class MySQLBackendMixin(object): class MySQLControllerMixin(object):
db_type = 'mysql' db_type = 'mysql'
def setUp(self): def setUp(self):
super(MySQLBackendMixin, self).setUp() super(MySQLControllerMixin, self).setUp()
# Get local ip address used to reach self.MASTER_SERVER # Get local ip address used to reach self.MASTER_SERVER
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((self.MASTER_SERVER, 22)) s.connect((self.MASTER_SERVER, 22))
@ -148,11 +148,11 @@ class MySQLBackendMixin(object):
def add_route(self): def add_route(self):
server = Server.objects.create(name=self.MASTER_SERVER) server = Server.objects.create(name=self.MASTER_SERVER)
backend = backends.MySQLBackend.get_name() backend = backends.MySQLController.get_name()
match = "database.type == '%s'" % self.db_type match = "database.type == '%s'" % self.db_type
Route.objects.create(backend=backend, match=match, host=server) Route.objects.create(backend=backend, match=match, host=server)
match = "databaseuser.type == '%s'" % self.db_type match = "databaseuser.type == '%s'" % self.db_type
backend = backends.MySQLUserBackend.get_name() backend = backends.MySQLUserController.get_name()
Route.objects.create(backend=backend, match=match, host=server) Route.objects.create(backend=backend, match=match, host=server)
def validate_create_table(self, name, username, password): def validate_create_table(self, name, username, password):
@ -337,9 +337,9 @@ class AdminDatabaseMixin(DatabaseTestMixin):
self.admin_delete(user) self.admin_delete(user)
class RESTMysqlDatabaseTest(MySQLBackendMixin, RESTDatabaseMixin, BaseLiveServerTestCase): class RESTMysqlDatabaseTest(MySQLControllerMixin, RESTDatabaseMixin, BaseLiveServerTestCase):
pass pass
class AdminMysqlDatabaseTest(MySQLBackendMixin, AdminDatabaseMixin, BaseLiveServerTestCase): class AdminMysqlDatabaseTest(MySQLControllerMixin, AdminDatabaseMixin, BaseLiveServerTestCase):
pass pass

View File

@ -12,7 +12,7 @@ from . import settings
from .models import Record, Domain from .models import Record, Domain
class Bind9MasterDomainBackend(ServiceController): class Bind9MasterDomainController(ServiceController):
""" """
Bind9 zone and config generation. Bind9 zone and config generation.
It auto-discovers slave Bind9 servers based on your routing configuration and NS servers. It auto-discovers slave Bind9 servers based on your routing configuration and NS servers.
@ -33,7 +33,7 @@ class Bind9MasterDomainBackend(ServiceController):
@classmethod @classmethod
def is_main(cls, obj): def is_main(cls, obj):
""" work around Domain.top self relationship """ """ work around Domain.top self relationship """
if super(Bind9MasterDomainBackend, cls).is_main(obj): if super(Bind9MasterDomainController, cls).is_main(obj):
return not obj.top return not obj.top
def save(self, domain): def save(self, domain):
@ -118,7 +118,7 @@ class Bind9MasterDomainBackend(ServiceController):
def get_masters_ips(self, domain): def get_masters_ips(self, domain):
ips = list(settings.DOMAINS_MASTERS) ips = list(settings.DOMAINS_MASTERS)
if not ips: if not ips:
ips += self.get_servers(domain, Bind9MasterDomainBackend) ips += self.get_servers(domain, Bind9MasterDomainController)
return OrderedSet(sorted(ips)) return OrderedSet(sorted(ips))
def get_slaves(self, domain): def get_slaves(self, domain):
@ -144,7 +144,7 @@ class Bind9MasterDomainBackend(ServiceController):
ips.append(addr) ips.append(addr)
# Slaves from internal networks # Slaves from internal networks
if not settings.DOMAINS_MASTERS: if not settings.DOMAINS_MASTERS:
for server in self.get_servers(domain, Bind9SlaveDomainBackend): for server in self.get_servers(domain, Bind9SlaveDomainController):
ips.append(server) ips.append(server)
return OrderedSet(sorted(ips)) return OrderedSet(sorted(ips))
@ -171,7 +171,7 @@ class Bind9MasterDomainBackend(ServiceController):
return context return context
class Bind9SlaveDomainBackend(Bind9MasterDomainBackend): class Bind9SlaveDomainController(Bind9MasterDomainController):
""" """
Generate the configuartion for slave servers Generate the configuartion for slave servers
It auto-discover the master server based on your routing configuration or you can use It auto-discover the master server based on your routing configuration or you can use

View File

@ -310,10 +310,10 @@ class Bind9BackendMixin(object):
def add_route(self): def add_route(self):
master = Server.objects.create(name=self.MASTER_SERVER, address=self.MASTER_SERVER_ADDR) master = Server.objects.create(name=self.MASTER_SERVER, address=self.MASTER_SERVER_ADDR)
backend = backends.Bind9MasterDomainBackend.get_name() backend = backends.Bind9MasterDomainController.get_name()
Route.objects.create(backend=backend, match=True, host=master) Route.objects.create(backend=backend, match=True, host=master)
slave = Server.objects.create(name=self.SLAVE_SERVER, address=self.SLAVE_SERVER_ADDR) slave = Server.objects.create(name=self.SLAVE_SERVER, address=self.SLAVE_SERVER_ADDR)
backend = backends.Bind9SlaveDomainBackend.get_name() backend = backends.Bind9SlaveDomainController.get_name()
Route.objects.create(backend=backend, match=True, host=slave) Route.objects.create(backend=backend, match=True, host=slave)

View File

@ -9,7 +9,7 @@ from . import settings
from .models import List from .models import List
class MailmanVirtualDomainBackend(ServiceController): class MailmanVirtualDomainController(ServiceController):
""" """
Only syncs virtualdomains used on mailman addresses Only syncs virtualdomains used on mailman addresses
""" """
@ -62,7 +62,7 @@ class MailmanVirtualDomainBackend(ServiceController):
service postfix reload service postfix reload
fi""") % context fi""") % context
) )
super(MailmanVirtualDomainBackend, self).commit() super(MailmanVirtualDomainController, self).commit()
def get_context_files(self): def get_context_files(self):
return { return {
@ -77,10 +77,10 @@ class MailmanVirtualDomainBackend(ServiceController):
return replace(context, "'", '"') return replace(context, "'", '"')
class MailmanBackend(MailmanVirtualDomainBackend): class MailmanController(MailmanVirtualDomainController):
""" """
Mailman 2 backend based on <tt>newlist</tt>, it handles custom domains. Mailman 2 backend based on <tt>newlist</tt>, it handles custom domains.
Includes <tt>MailmanVirtualDomainBackend</tt> Includes <tt>MailmanVirtualDomainController</tt>
""" """
verbose_name = "Mailman" verbose_name = "Mailman"
address_suffixes = [ address_suffixes = [
@ -202,7 +202,7 @@ class MailmanBackend(MailmanVirtualDomainBackend):
} }
def get_banner(self, mail_list): def get_banner(self, mail_list):
banner = super(MailmanBackend, self).get_banner() banner = super(MailmanController, self).get_banner()
return '%s %s' % (banner, mail_list.name) return '%s %s' % (banner, mail_list.name)
def get_context(self, mail_list): def get_context(self, mail_list):

View File

@ -79,7 +79,7 @@ class ListMixin(object):
def add_route(self): def add_route(self):
server = Server.objects.create(name=self.MASTER_SERVER) server = Server.objects.create(name=self.MASTER_SERVER)
backend = backends.MailmanBackend.get_name() backend = backends.MailmanController.get_name()
Route.objects.create(backend=backend, match=True, host=server) Route.objects.create(backend=backend, match=True, host=server)
def test_add(self): def test_add(self):

View File

@ -53,7 +53,7 @@ class SieveFilteringMixin:
self.append('chown %(user)s:%(group)s %(filtering_path)s' % context) self.append('chown %(user)s:%(group)s %(filtering_path)s' % context)
class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController): class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
""" """
Assumes that all system users on this servers all mail accounts. Assumes that all system users on this servers all mail accounts.
If you want to have system users AND mailboxes on the same server you should consider using virtual mailboxes. If you want to have system users AND mailboxes on the same server you should consider using virtual mailboxes.
@ -149,7 +149,7 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
return context return context
#class DovecotPostfixPasswdVirtualUserBackend(SieveFilteringMixin, ServiceController): #class DovecotPostfixPasswdVirtualUserController(SieveFilteringMixin, ServiceController):
# """ # """
# WARNING: This backends is not fully implemented # WARNING: This backends is not fully implemented
# """ # """
@ -242,7 +242,7 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
# return context # return context
class PostfixAddressVirtualDomainBackend(ServiceController): class PostfixAddressVirtualDomainController(ServiceController):
""" """
Secondary SMTP server without mailboxes in it, only syncs virtual domains. Secondary SMTP server without mailboxes in it, only syncs virtual domains.
""" """
@ -326,9 +326,9 @@ class PostfixAddressVirtualDomainBackend(ServiceController):
return context return context
class PostfixAddressBackend(PostfixAddressVirtualDomainBackend): class PostfixAddressController(PostfixAddressVirtualDomainController):
""" """
Addresses based on Postfix virtual alias domains, includes <tt>PostfixAddressVirtualDomainBackend</tt>. Addresses based on Postfix virtual alias domains, includes <tt>PostfixAddressVirtualDomainController</tt>.
""" """
verbose_name = _("Postfix address") verbose_name = _("Postfix address")
doc_settings = (settings, ( doc_settings = (settings, (
@ -413,7 +413,7 @@ class PostfixAddressBackend(PostfixAddressVirtualDomainBackend):
) )
class AutoresponseBackend(ServiceController): class AutoresponseController(ServiceController):
""" """
WARNING: not implemented WARNING: not implemented
""" """

View File

@ -41,7 +41,7 @@ class MailboxMixin(object):
server = Server.objects.create(name=self.MASTER_SERVER) server = Server.objects.create(name=self.MASTER_SERVER)
backend = backends.PasswdVirtualUserBackend.get_name() backend = backends.PasswdVirtualUserBackend.get_name()
Route.objects.create(backend=backend, match=True, host=server) Route.objects.create(backend=backend, match=True, host=server)
backend = backends.PostfixAddressBackend.get_name() backend = backends.PostfixAddressController.get_name()
Route.objects.create(backend=backend, match=True, host=server) Route.objects.create(backend=backend, match=True, host=server)
def add_quota_resource(self): def add_quota_resource(self):

View File

@ -50,7 +50,7 @@ class Migration(migrations.Migration):
name='Route', name='Route',
fields=[ fields=[
('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)),
('backend', models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('Apache2Backend', '[S] Apache 2'), ('BSCWBackend', '[S] BSCW SaaS'), ('Bind9MasterDomainBackend', '[S] Bind9 master domain'), ('Bind9SlaveDomainBackend', '[S] Bind9 slave domain'), ('DokuWikiMuBackend', '[S] DokuWiki multisite'), ('DovecotPostfixPasswdVirtualUserBackend', '[S] Dovecot-Postfix virtualuser'), ('DrupalMuBackend', '[S] Drupal multisite'), ('GitLabSaaSBackend', '[S] GitLab SaaS'), ('AutoresponseBackend', '[S] Mail autoresponse'), ('MailmanBackend', '[S] Mailman'), ('MySQLBackend', '[S] MySQL database'), ('MySQLUserBackend', '[S] MySQL user'), ('PHPBackend', '[S] PHP FPM/FCGID'), ('PostfixAddressBackend', '[S] Postfix address'), ('uWSGIPythonBackend', '[S] Python uWSGI'), ('StaticBackend', '[S] Static'), ('SymbolicLinkBackend', '[S] Symbolic link webapp'), ('UNIXUserMaildirBackend', '[S] UNIX maildir user'), ('UNIXUserBackend', '[S] UNIX user'), ('WebalizerAppBackend', '[S] Webalizer App'), ('WebalizerBackend', '[S] Webalizer Content'), ('WordPressBackend', '[S] Wordpress'), ('WordpressMuBackend', '[S] Wordpress multisite'), ('PhpListSaaSBackend', '[S] phpList SaaS')], max_length=256, verbose_name='backend')), ('backend', models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('Apache2Controller', '[S] Apache 2'), ('BSCWController', '[S] BSCW SaaS'), ('Bind9MasterDomainController', '[S] Bind9 master domain'), ('Bind9SlaveDomainController', '[S] Bind9 slave domain'), ('DokuWikiMuController', '[S] DokuWiki multisite'), ('DovecotPostfixPasswdVirtualUserController', '[S] Dovecot-Postfix virtualuser'), ('DrupalMuController', '[S] Drupal multisite'), ('GitLabSaaSController', '[S] GitLab SaaS'), ('AutoresponseController', '[S] Mail autoresponse'), ('MailmanController', '[S] Mailman'), ('MySQLController', '[S] MySQL database'), ('MySQLUserController', '[S] MySQL user'), ('PHPController', '[S] PHP FPM/FCGID'), ('PostfixAddressController', '[S] Postfix address'), ('uWSGIPythonController', '[S] Python uWSGI'), ('StaticController', '[S] Static'), ('SymbolicLinkController', '[S] Symbolic link webapp'), ('UNIXUserMaildirController', '[S] UNIX maildir user'), ('UNIXUserController', '[S] UNIX user'), ('WebalizerAppController', '[S] Webalizer App'), ('WebalizerController', '[S] Webalizer Content'), ('WordPressController', '[S] Wordpress'), ('WordpressMuController', '[S] Wordpress multisite'), ('PhpListSaaSController', '[S] phpList SaaS')], max_length=256, verbose_name='backend')),
('match', models.CharField(help_text='Python expression used for selecting the targe host, <em>instance</em> referes to the current object.', default='True', blank=True, max_length=256, verbose_name='match')), ('match', models.CharField(help_text='Python expression used for selecting the targe host, <em>instance</em> referes to the current object.', default='True', blank=True, max_length=256, verbose_name='match')),
('is_active', models.BooleanField(default=True, verbose_name='active')), ('is_active', models.BooleanField(default=True, verbose_name='active')),
], ],

View File

@ -29,6 +29,6 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='route', model_name='route',
name='backend', name='backend',
field=models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('Apache2Backend', '[S] Apache 2'), ('BSCWBackend', '[S] BSCW SaaS'), ('Bind9MasterDomainBackend', '[S] Bind9 master domain'), ('Bind9SlaveDomainBackend', '[S] Bind9 slave domain'), ('DokuWikiMuBackend', '[S] DokuWiki multisite'), ('DovecotPostfixPasswdVirtualUserBackend', '[S] Dovecot-Postfix virtualuser'), ('DrupalMuBackend', '[S] Drupal multisite'), ('GitLabSaaSBackend', '[S] GitLab SaaS'), ('AutoresponseBackend', '[S] Mail autoresponse'), ('MailmanBackend', '[S] Mailman'), ('MailmanVirtualDomainBackend', '[S] Mailman virtdomain-only'), ('MySQLBackend', '[S] MySQL database'), ('MySQLUserBackend', '[S] MySQL user'), ('PHPBackend', '[S] PHP FPM/FCGID'), ('PostfixAddressBackend', '[S] Postfix address'), ('PostfixAddressVirtualDomainBackend', '[S] Postfix address virtdomain-only'), ('uWSGIPythonBackend', '[S] Python uWSGI'), ('StaticBackend', '[S] Static'), ('SymbolicLinkBackend', '[S] Symbolic link webapp'), ('SyncBind9MasterDomainBackend', '[S] Sync Bind9 master domain'), ('SyncBind9SlaveDomainBackend', '[S] Sync Bind9 slave domain'), ('UNIXUserMaildirBackend', '[S] UNIX maildir user'), ('UNIXUserBackend', '[S] UNIX user'), ('WebalizerAppBackend', '[S] Webalizer App'), ('WebalizerBackend', '[S] Webalizer Content'), ('WordPressBackend', '[S] Wordpress'), ('WordpressMuBackend', '[S] Wordpress multisite'), ('PhpListSaaSBackend', '[S] phpList SaaS')], verbose_name='backend', max_length=256), field=models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('Apache2Controller', '[S] Apache 2'), ('BSCWController', '[S] BSCW SaaS'), ('Bind9MasterDomainController', '[S] Bind9 master domain'), ('Bind9SlaveDomainController', '[S] Bind9 slave domain'), ('DokuWikiMuController', '[S] DokuWiki multisite'), ('DovecotPostfixPasswdVirtualUserController', '[S] Dovecot-Postfix virtualuser'), ('DrupalMuController', '[S] Drupal multisite'), ('GitLabSaaSController', '[S] GitLab SaaS'), ('AutoresponseController', '[S] Mail autoresponse'), ('MailmanController', '[S] Mailman'), ('MailmanVirtualDomainController', '[S] Mailman virtdomain-only'), ('MySQLController', '[S] MySQL database'), ('MySQLUserController', '[S] MySQL user'), ('PHPController', '[S] PHP FPM/FCGID'), ('PostfixAddressController', '[S] Postfix address'), ('PostfixAddressVirtualDomainController', '[S] Postfix address virtdomain-only'), ('uWSGIPythonController', '[S] Python uWSGI'), ('StaticController', '[S] Static'), ('SymbolicLinkController', '[S] Symbolic link webapp'), ('SyncBind9MasterDomainController', '[S] Sync Bind9 master domain'), ('SyncBind9SlaveDomainController', '[S] Sync Bind9 slave domain'), ('UNIXUserMaildirController', '[S] UNIX maildir user'), ('UNIXUserController', '[S] UNIX user'), ('WebalizerAppController', '[S] Webalizer App'), ('WebalizerController', '[S] Webalizer Content'), ('WordPressController', '[S] Wordpress'), ('WordpressMuController', '[S] Wordpress multisite'), ('PhpListSaaSController', '[S] phpList SaaS')], verbose_name='backend', max_length=256),
), ),
] ]

View File

@ -16,7 +16,7 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='route', model_name='route',
name='backend', name='backend',
field=models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('ApacheTrafficByName', '[M] ApacheTrafficByName'), ('DokuWikiMuTraffic', '[M] DokuWiki MU Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('WordpressMuTraffic', '[M] Wordpress MU Traffic'), ('OwnCloudDiskQuota', '[M] ownCloud SaaS Disk Quota'), ('OwncloudTraffic', '[M] ownCloud SaaS Traffic'), ('PhpListTraffic', '[M] phpList SaaS Traffic'), ('Apache2Backend', '[S] Apache 2'), ('BSCWBackend', '[S] BSCW SaaS'), ('Bind9MasterDomainBackend', '[S] Bind9 master domain'), ('Bind9SlaveDomainBackend', '[S] Bind9 slave domain'), ('DokuWikiMuBackend', '[S] DokuWiki multisite'), ('DrupalMuBackend', '[S] Drupal multisite'), ('GitLabSaaSBackend', '[S] GitLab SaaS'), ('AutoresponseBackend', '[S] Mail autoresponse'), ('MailScannerSpamRuleBackend', '[S] MailScanner ruleset'), ('MailmanBackend', '[S] Mailman'), ('MailmanVirtualDomainBackend', '[S] Mailman virtdomain-only'), ('MoodleBackend', '[S] Moodle'), ('MoodleWWWRootBackend', '[S] Moodle WWWRoot (required)'), ('MoodleMuBackend', '[S] Moodle multisite'), ('MySQLBackend', '[S] MySQL database'), ('MySQLUserBackend', '[S] MySQL user'), ('PHPBackend', '[S] PHP FPM/FCGID'), ('PangeaProxmoxOVZ', '[S] PangeaProxmoxOVZ'), ('PostfixAddressBackend', '[S] Postfix address'), ('PostfixAddressVirtualDomainBackend', '[S] Postfix address virtdomain-only'), ('PostfixRecipientAccessBackend', '[S] Postfix recipient access'), ('ProxmoxOVZ', '[S] ProxmoxOVZ'), ('uWSGIPythonBackend', '[S] Python uWSGI'), ('StaticBackend', '[S] Static'), ('SymbolicLinkBackend', '[S] Symbolic link webapp'), ('SyncBind9MasterDomainBackend', '[S] Sync Bind9 master domain'), ('SyncBind9SlaveDomainBackend', '[S] Sync Bind9 slave domain'), ('UNIXUserMaildirBackend', '[S] UNIX maildir user'), ('UNIXUserBackend', '[S] UNIX user'), ('WebalizerAppBackend', '[S] Webalizer App'), ('WebalizerBackend', '[S] Webalizer Content'), ('WordPressURLBackend', '[S] WordPress URL'), ('WordPressBackend', '[S] Wordpress'), ('WordpressMuBackend', '[S] Wordpress multisite'), ('OwnCloudBackend', '[S] ownCloud SaaS'), ('PhpListSaaSBackend', '[S] phpList SaaS')], max_length=256, verbose_name='backend'), field=models.CharField(choices=[('Apache2Traffic', '[M] Apache 2 Traffic'), ('ApacheTrafficByName', '[M] ApacheTrafficByName'), ('DokuWikiMuTraffic', '[M] DokuWiki MU Traffic'), ('DovecotMaildirDisk', '[M] Dovecot Maildir size'), ('Exim4Traffic', '[M] Exim4 traffic'), ('MailmanSubscribers', '[M] Mailman subscribers'), ('MailmanTraffic', '[M] Mailman traffic'), ('MysqlDisk', '[M] MySQL disk'), ('OpenVZTraffic', '[M] OpenVZTraffic'), ('PostfixMailscannerTraffic', '[M] Postfix-Mailscanner traffic'), ('UNIXUserDisk', '[M] UNIX user disk'), ('VsFTPdTraffic', '[M] VsFTPd traffic'), ('WordpressMuTraffic', '[M] Wordpress MU Traffic'), ('OwnCloudDiskQuota', '[M] ownCloud SaaS Disk Quota'), ('OwncloudTraffic', '[M] ownCloud SaaS Traffic'), ('PhpListTraffic', '[M] phpList SaaS Traffic'), ('Apache2Controller', '[S] Apache 2'), ('BSCWController', '[S] BSCW SaaS'), ('Bind9MasterDomainController', '[S] Bind9 master domain'), ('Bind9SlaveDomainController', '[S] Bind9 slave domain'), ('DokuWikiMuController', '[S] DokuWiki multisite'), ('DrupalMuController', '[S] Drupal multisite'), ('GitLabSaaSController', '[S] GitLab SaaS'), ('AutoresponseController', '[S] Mail autoresponse'), ('MailScannerSpamRuleController', '[S] MailScanner ruleset'), ('MailmanController', '[S] Mailman'), ('MailmanVirtualDomainController', '[S] Mailman virtdomain-only'), ('MoodleController', '[S] Moodle'), ('MoodleWWWRootController', '[S] Moodle WWWRoot (required)'), ('MoodleMuController', '[S] Moodle multisite'), ('MySQLController', '[S] MySQL database'), ('MySQLUserController', '[S] MySQL user'), ('PHPController', '[S] PHP FPM/FCGID'), ('PangeaProxmoxOVZ', '[S] PangeaProxmoxOVZ'), ('PostfixAddressController', '[S] Postfix address'), ('PostfixAddressVirtualDomainController', '[S] Postfix address virtdomain-only'), ('PostfixRecipientAccessController', '[S] Postfix recipient access'), ('ProxmoxOVZ', '[S] ProxmoxOVZ'), ('uWSGIPythonController', '[S] Python uWSGI'), ('StaticController', '[S] Static'), ('SymbolicLinkController', '[S] Symbolic link webapp'), ('SyncBind9MasterDomainController', '[S] Sync Bind9 master domain'), ('SyncBind9SlaveDomainController', '[S] Sync Bind9 slave domain'), ('UNIXUserMaildirController', '[S] UNIX maildir user'), ('UNIXUserController', '[S] UNIX user'), ('WebalizerAppController', '[S] Webalizer App'), ('WebalizerController', '[S] Webalizer Content'), ('WordPressURLController', '[S] WordPress URL'), ('WordPressController', '[S] Wordpress'), ('WordpressMuController', '[S] Wordpress multisite'), ('OwnCloudController', '[S] ownCloud SaaS'), ('PhpListSaaSController', '[S] phpList SaaS')], max_length=256, verbose_name='backend'),
), ),
migrations.AlterField( migrations.AlterField(
model_name='server', model_name='server',

View File

@ -7,7 +7,7 @@ from orchestra.contrib.orchestration import ServiceController, replace
from .. import settings from .. import settings
class BSCWBackend(ServiceController): class BSCWController(ServiceController):
verbose_name = _("BSCW SaaS") verbose_name = _("BSCW SaaS")
model = 'saas.SaaS' model = 'saas.SaaS'
default_route_match = "saas.service == 'bscw'" default_route_match = "saas.service == 'bscw'"

View File

@ -12,7 +12,7 @@ from . import ApacheTrafficByHost
from .. import settings from .. import settings
class DokuWikiMuBackend(ServiceController): class DokuWikiMuController(ServiceController):
""" """
Creates a DokuWiki site on a DokuWiki multisite installation. Creates a DokuWiki site on a DokuWiki multisite installation.
""" """
@ -79,7 +79,7 @@ class DokuWikiMuBackend(ServiceController):
) )
def get_context(self, saas): def get_context(self, saas):
context = super(DokuWikiMuBackend, self).get_context(saas) context = super(DokuWikiMuController, self).get_context(saas)
domain = saas.get_site_domain() domain = saas.get_site_domain()
context.update({ context.update({
'template': settings.SAAS_DOKUWIKI_TEMPLATE_PATH, 'template': settings.SAAS_DOKUWIKI_TEMPLATE_PATH,

View File

@ -8,7 +8,7 @@ from orchestra.contrib.orchestration import ServiceController, replace
from .. import settings from .. import settings
class DrupalMuBackend(ServiceController): class DrupalMuController(ServiceController):
""" """
Creates a Drupal site on a Drupal multisite installation Creates a Drupal site on a Drupal multisite installation
""" """
@ -38,7 +38,7 @@ class DrupalMuBackend(ServiceController):
self.append("rm -fr %(app_path)s" % context) self.append("rm -fr %(app_path)s" % context)
def get_context(self, webapp): def get_context(self, webapp):
context = super(DrupalMuBackend, self).get_context(webapp) context = super(DrupalMuController, self).get_context(webapp)
context['drupal_path'] = settings.SAAS_DRUPAL_SITES_PATH % context context['drupal_path'] = settings.SAAS_DRUPAL_SITES_PATH % context
context['drupal_settings'] = os.path.join(context['drupal_path'], 'settings.php') context['drupal_settings'] = os.path.join(context['drupal_path'], 'settings.php')
return replace(context, "'", '"') return replace(context, "'", '"')

View File

@ -8,7 +8,7 @@ from orchestra.contrib.orchestration import ServiceController
from .. import settings from .. import settings
class GitLabSaaSBackend(ServiceController): class GitLabSaaSController(ServiceController):
verbose_name = _("GitLab SaaS") verbose_name = _("GitLab SaaS")
model = 'saas.SaaS' model = 'saas.SaaS'
default_route_match = "saas.service == 'gitlab'" default_route_match = "saas.service == 'gitlab'"

View File

@ -8,7 +8,7 @@ from orchestra.contrib.orchestration import ServiceController
from .. import settings from .. import settings
class MoodleMuBackend(ServiceController): class MoodleMuController(ServiceController):
""" """
Creates a Moodle site on a Moodle multisite installation Creates a Moodle site on a Moodle multisite installation

View File

@ -94,7 +94,7 @@ class OwnClouwAPIMixin(object):
return ret return ret
class OwnCloudBackend(OwnClouwAPIMixin, ServiceController): class OwnCloudController(OwnClouwAPIMixin, ServiceController):
""" """
Creates a wordpress site on a WordPress MultiSite installation. Creates a wordpress site on a WordPress MultiSite installation.

View File

@ -13,7 +13,7 @@ from orchestra.utils.sys import sshrun
from .. import settings from .. import settings
class PhpListSaaSBackend(ServiceController): class PhpListSaaSController(ServiceController):
""" """
Creates a new phplist instance on a phpList multisite installation. Creates a new phplist instance on a phpList multisite installation.
The site is created by means of creating a new database per phpList site, The site is created by means of creating a new database per phpList site,

View File

@ -12,7 +12,7 @@ from . import ApacheTrafficByHost
from .. import settings from .. import settings
class WordpressMuBackend(ServiceController): class WordpressMuController(ServiceController):
""" """
Creates a wordpress site on a WordPress MultiSite installation. Creates a wordpress site on a WordPress MultiSite installation.

View File

@ -10,7 +10,7 @@ from orchestra.contrib.resources import ServiceMonitor
from . import settings from . import settings
class UNIXUserBackend(ServiceController): class UNIXUserController(ServiceController):
""" """
Basic UNIX system user/group support based on <tt>useradd</tt>, <tt>usermod</tt>, <tt>userdel</tt> and <tt>groupdel</tt>. Basic UNIX system user/group support based on <tt>useradd</tt>, <tt>usermod</tt>, <tt>userdel</tt> and <tt>groupdel</tt>.
Autodetects and uses ACL if available, for better permission management. Autodetects and uses ACL if available, for better permission management.

View File

@ -10,7 +10,7 @@ from .. import settings
from . import WebAppServiceMixin from . import WebAppServiceMixin
class MoodleBackend(WebAppServiceMixin, ServiceController): class MoodleController(WebAppServiceMixin, ServiceController):
""" """
Installs the latest version of Moodle available on download.moodle.org Installs the latest version of Moodle available on download.moodle.org
""" """
@ -92,7 +92,7 @@ class MoodleBackend(WebAppServiceMixin, ServiceController):
) )
def get_context(self, webapp): def get_context(self, webapp):
context = super(MoodleBackend, self).get_context(webapp) context = super(MoodleController, self).get_context(webapp)
contents = webapp.content_set.all() contents = webapp.content_set.all()
context.update({ context.update({
'db_type': 'mysqli', 'db_type': 'mysqli',

View File

@ -11,7 +11,7 @@ from . import WebAppServiceMixin
from .. import settings, utils from .. import settings, utils
class PHPBackend(WebAppServiceMixin, ServiceController): class PHPController(WebAppServiceMixin, ServiceController):
""" """
PHP support for apache-mod-fcgid and php-fpm. PHP support for apache-mod-fcgid and php-fpm.
It handles switching between these two PHP process management systemes. It handles switching between these two PHP process management systemes.
@ -139,13 +139,13 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
self.append("rm -f %(cmd_options_path)s" % context_copy) self.append("rm -f %(cmd_options_path)s" % context_copy)
def prepare(self): def prepare(self):
super(PHPBackend, self).prepare() super(PHPController, self).prepare()
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
BACKEND="PHPBackend" BACKEND="PHPController"
echo "$BACKEND" >> /dev/shm/reload.apache2 echo "$BACKEND" >> /dev/shm/reload.apache2
function coordinate_apache_reload () { function coordinate_apache_reload () {
# Coordinate Apache reload with other concurrent backends (e.g. Apache2Backend) # Coordinate Apache reload with other concurrent backends (e.g. Apache2Controller)
is_last=0 is_last=0
counter=0 counter=0
while ! mv /dev/shm/reload.apache2 /dev/shm/reload.apache2.locked; do while ! mv /dev/shm/reload.apache2 /dev/shm/reload.apache2.locked; do
@ -193,7 +193,7 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
coordinate_apache_reload coordinate_apache_reload
""") % context """) % context
) )
super(PHPBackend, self).commit() super(PHPController, self).commit()
def get_fpm_config(self, webapp, context): def get_fpm_config(self, webapp, context):
options = webapp.type_instance.get_options() options = webapp.type_instance.get_options()

View File

@ -9,7 +9,7 @@ from . import WebAppServiceMixin
from .. import settings from .. import settings
class uWSGIPythonBackend(WebAppServiceMixin, ServiceController): class uWSGIPythonController(WebAppServiceMixin, ServiceController):
""" """
<a href="http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html">Emperor mode</a> <a href="http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html">Emperor mode</a>
""" """
@ -72,7 +72,7 @@ class uWSGIPythonBackend(WebAppServiceMixin, ServiceController):
return context return context
def get_context(self, webapp): def get_context(self, webapp):
context = super(PHPBackend, self).get_context(webapp) context = super(PHPController, self).get_context(webapp)
options = webapp.get_options() options = webapp.get_options()
context.update({ context.update({
'python_version': webapp.type_instance.get_python_version(), 'python_version': webapp.type_instance.get_python_version(),

View File

@ -5,7 +5,7 @@ from orchestra.contrib.orchestration import ServiceController
from . import WebAppServiceMixin from . import WebAppServiceMixin
class StaticBackend(WebAppServiceMixin, ServiceController): class StaticController(WebAppServiceMixin, ServiceController):
""" """
Static web pages. Static web pages.
Only creates the webapp dir and leaves the web server the decision to execute CGIs or not. Only creates the webapp dir and leaves the web server the decision to execute CGIs or not.

View File

@ -4,12 +4,12 @@ from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.orchestration import ServiceController, replace from orchestra.contrib.orchestration import ServiceController, replace
from .php import PHPBackend from .php import PHPController
class SymbolicLinkBackend(PHPBackend, ServiceController): class SymbolicLinkController(PHPController, ServiceController):
""" """
Same as PHPBackend but allows you to have the webapps on a directory diferent than the webapps dir. Same as PHPController but allows you to have the webapps on a directory diferent than the webapps dir.
""" """
verbose_name = _("Symbolic link webapp") verbose_name = _("Symbolic link webapp")
model = 'webapps.WebApp' model = 'webapps.WebApp'
@ -28,7 +28,7 @@ class SymbolicLinkBackend(PHPBackend, ServiceController):
pass pass
def get_context(self, webapp): def get_context(self, webapp):
context = super(SymbolicLinkBackend, self).get_context(webapp) context = super(SymbolicLinkController, self).get_context(webapp)
context.update({ context.update({
'link_path': webapp.data['path'], 'link_path': webapp.data['path'],
}) })

View File

@ -6,7 +6,7 @@ from . import WebAppServiceMixin
# TODO DEPRECATE # TODO DEPRECATE
class WebalizerAppBackend(WebAppServiceMixin, ServiceController): class WebalizerAppController(WebAppServiceMixin, ServiceController):
""" """
Needed for cleaning up webalizer main folder when webapp deleteion withou related contents Needed for cleaning up webalizer main folder when webapp deleteion withou related contents
""" """

View File

@ -11,7 +11,7 @@ from . import WebAppServiceMixin
# Based on https://github.com/mtomic/wordpress-install/blob/master/wpinstall.php # Based on https://github.com/mtomic/wordpress-install/blob/master/wpinstall.php
class WordPressBackend(WebAppServiceMixin, ServiceController): class WordPressController(WebAppServiceMixin, ServiceController):
""" """
Installs the latest version of WordPress available on www.wordpress.org Installs the latest version of WordPress available on www.wordpress.org
It fully configures the wp-config.php (keys included) and sets up the database with initial admin password. It fully configures the wp-config.php (keys included) and sets up the database with initial admin password.
@ -135,7 +135,7 @@ class WordPressBackend(WebAppServiceMixin, ServiceController):
self.append("exc('rm -rf %(app_path)s');" % context) self.append("exc('rm -rf %(app_path)s');" % context)
def get_context(self, webapp): def get_context(self, webapp):
context = super(WordPressBackend, self).get_context(webapp) context = super(WordPressController, self).get_context(webapp)
context.update({ context.update({
'db_name': webapp.data['db_name'], 'db_name': webapp.data['db_name'],
'db_user': webapp.data['db_user'], 'db_user': webapp.data['db_user'],

View File

@ -53,7 +53,7 @@ class WebAppMixin(object):
class StaticWebAppMixin(object): class StaticWebAppMixin(object):
backend = backends.static.StaticBackend backend = backends.static.StaticController
type_value = 'static' type_value = 'static'
token = random_ascii(100) token = random_ascii(100)
page = ( page = (

View File

@ -12,7 +12,7 @@ from .. import settings
from ..utils import normurlpath from ..utils import normurlpath
class Apache2Backend(ServiceController): class Apache2Controller(ServiceController):
""" """
Apache &ge;2.4 backend with support for the following directives: Apache &ge;2.4 backend with support for the following directives:
<tt>static</tt>, <tt>location</tt>, <tt>fpm</tt>, <tt>fcgid</tt>, <tt>uwsgi</tt>, \ <tt>static</tt>, <tt>location</tt>, <tt>fpm</tt>, <tt>fcgid</tt>, <tt>uwsgi</tt>, \
@ -142,14 +142,14 @@ class Apache2Backend(ServiceController):
) )
def prepare(self): def prepare(self):
super(Apache2Backend, self).prepare() super(Apache2Controller, self).prepare()
# Coordinate apache restart with php backend in order not to overdo it # Coordinate apache restart with php backend in order not to overdo it
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
BACKEND="Apache2Backend" BACKEND="Apache2Controller"
echo "$BACKEND" >> /dev/shm/restart.apache2 echo "$BACKEND" >> /dev/shm/restart.apache2
function coordinate_apache_reload () { function coordinate_apache_reload () {
# Coordinate Apache reload with other concurrent backends (e.g. PHPBackend) # Coordinate Apache reload with other concurrent backends (e.g. PHPController)
is_last=0 is_last=0
counter=0 counter=0
while ! mv /dev/shm/reload.apache2 /dev/shm/reload.apache2.locked; do while ! mv /dev/shm/reload.apache2 /dev/shm/reload.apache2.locked; do
@ -188,7 +188,7 @@ class Apache2Backend(ServiceController):
def commit(self): def commit(self):
""" reload Apache2 if necessary """ """ reload Apache2 if necessary """
self.append("coordinate_apache_reload") self.append("coordinate_apache_reload")
super(Apache2Backend, self).commit() super(Apache2Controller, self).commit()
def get_directives(self, directive, context): def get_directives(self, directive, context):
method, args = directive[0], directive[1:] method, args = directive[0], directive[1:]

View File

@ -3,7 +3,7 @@ import textwrap
from orchestra.contrib.orchestration import ServiceController from orchestra.contrib.orchestration import ServiceController
class MoodleWWWRootBackend(ServiceController): class MoodleWWWRootController(ServiceController):
""" """
Configures Moodle site WWWRoot, without it Moodle refuses to work. Configures Moodle site WWWRoot, without it Moodle refuses to work.
""" """

View File

@ -8,7 +8,7 @@ from orchestra.contrib.orchestration import ServiceController
from .. import settings from .. import settings
class WebalizerBackend(ServiceController): class WebalizerController(ServiceController):
""" """
Creates webalizer conf file for each time a webalizer webapp is mounted on a website. Creates webalizer conf file for each time a webalizer webapp is mounted on a website.
""" """

View File

@ -3,7 +3,7 @@ import textwrap
from orchestra.contrib.orchestration import ServiceController from orchestra.contrib.orchestration import ServiceController
class WordPressURLBackend(ServiceController): class WordPressURLController(ServiceController):
""" """
Configures WordPress site URL with associated website domain. Configures WordPress site URL with associated website domain.
""" """

View File

@ -4,7 +4,7 @@ import socket
import requests import requests
from orchestra.contrib.domains.models import Domain, Record from orchestra.contrib.domains.models import Domain, Record
from orchestra.contrib.domains.backends import Bind9MasterDomainBackend from orchestra.contrib.domains.backends import Bind9MasterDomainController
from orchestra.contrib.orchestration.models import Server, Route from orchestra.contrib.orchestration.models import Server, Route
from orchestra.contrib.webapps.tests.functional_tests.tests import StaticWebAppMixin, RESTWebAppMixin, WebAppMixin, PHPFcidWebAppMixin, PHPFPMWebAppMixin from orchestra.contrib.webapps.tests.functional_tests.tests import StaticWebAppMixin, RESTWebAppMixin, WebAppMixin, PHPFcidWebAppMixin, PHPFPMWebAppMixin
from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, save_response_on_error from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, save_response_on_error
@ -26,9 +26,9 @@ class WebsiteMixin(WebAppMixin):
def add_route(self): def add_route(self):
super(WebsiteMixin, self).add_route() super(WebsiteMixin, self).add_route()
server = Server.objects.get() server = Server.objects.get()
backend = backends.apache.Apache2Backend.get_name() backend = backends.apache.Apache2Controller.get_name()
Route.objects.get_or_create(backend=backend, match=True, host=server) Route.objects.get_or_create(backend=backend, match=True, host=server)
backend = Bind9MasterDomainBackend.get_name() backend = Bind9MasterDomainController.get_name()
Route.objects.get_or_create(backend=backend, match=True, host=server) Route.objects.get_or_create(backend=backend, match=True, host=server)
def validate_add_website(self, name, domain): def validate_add_website(self, name, domain):