Added better support for domain account migration

This commit is contained in:
Marc 2014-10-24 12:12:20 +00:00
parent 1b9007a1f1
commit 739fab2887
5 changed files with 22 additions and 1 deletions

View file

@ -1,9 +1,15 @@
import pkgutil
import textwrap
from .. import settings
class WebAppServiceMixin(object):
model = 'webapps.WebApp'
directive = None
def valid_directive(self, webapp):
return settings.WEBAPPS_TYPES[webapp.type]['directive'][0] == self.directive
def create_webapp_dir(self, context):
self.append(textwrap.dedent("""

View file

@ -12,8 +12,11 @@ from .. import settings
class PHPFcgidBackend(WebAppServiceMixin, ServiceController):
""" Per-webapp fcgid application """
verbose_name = _("PHP-Fcgid")
directive = 'fcgi'
def save(self, webapp):
if not self.valid_directive(webapp):
return
context = self.get_context(webapp)
self.create_webapp_dir(context)
self.append("mkdir -p %(wrapper_dir)s" % context)
@ -27,6 +30,8 @@ class PHPFcgidBackend(WebAppServiceMixin, ServiceController):
self.append("chown -R %(user)s.%(group)s %(wrapper_dir)s" % context)
def delete(self, webapp):
if not self.valid_directive(webapp):
return
context = self.get_context(webapp)
self.append("rm '%(wrapper_path)s'" % context)
self.delete_webapp_dir(context)

View file

@ -13,8 +13,11 @@ from .. import settings
class PHPFPMBackend(WebAppServiceMixin, ServiceController):
""" Per-webapp php application """
verbose_name = _("PHP-FPM")
directive = 'fpm'
def save(self, webapp):
if not self.valid_directive(webapp)
return
context = self.get_context(webapp)
self.create_webapp_dir(context)
self.append(textwrap.dedent("""\
@ -39,6 +42,8 @@ class PHPFPMBackend(WebAppServiceMixin, ServiceController):
}"""))
def get_context(self, webapp):
if not self.valid_directive(webapp):
return
context = super(PHPFPMBackend, self).get_context(webapp)
context.update({
'init_vars': self.get_php_init_vars(webapp),

View file

@ -7,11 +7,16 @@ from . import WebAppServiceMixin
class StaticBackend(WebAppServiceMixin, ServiceController):
verbose_name = _("Static")
directive = 'static'
def save(self, webapp):
if not self.valid_directive(webapp):
return
context = self.get_context(webapp)
self.create_webapp_dir(context)
def delete(self, webapp):
if not self.valid_directive(webapp):
return
context = self.get_context(webapp)
self.delete_webapp_dir(context)

View file

@ -42,7 +42,7 @@ class WebApp(models.Model):
def get_path(self):
context = {
'home': webapp.get_user().get_home(),
'home': self.get_user().get_home(),
'app_name': self.name,
}
return settings.WEBAPPS_BASE_ROOT % context