How to use the orchestra.apps.webapps.settings function in orchestra

To help you get started, we’ve selected a few orchestra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glic3rinu / django-orchestra / orchestra / apps / webapps / types.py View on Github external
per_account=True merges all (account, webapp.type) options
        """
        init_vars = {}
        options = webapp.options.all()
        if per_account:
            options = webapp.account.webapps.filter(webapp_type=webapp.type)
        php_options = [option.name for option in type(self).get_php_options()]
        for opt in options:
            if opt.name in php_options:
                init_vars[opt.name] = opt.value
        enabled_functions = []
        for value in options.filter(name='enabled_functions').values_list('value', flat=True):
            enabled_functions += enabled_functions.get().value.split(',')
        if enabled_functions:
            disabled_functions = []
            for function in settings.WEBAPPS_PHP_DISABLED_FUNCTIONS:
                if function not in enabled_functions:
                    disabled_functions.append(function)
            init_vars['dissabled_functions'] = ','.join(disabled_functions)
        if settings.WEBAPPS_PHP_ERROR_LOG_PATH and 'error_log' not in init_vars:
            context = self.get_context(webapp)
            error_log_path = os.path.normpath(settings.WEBAPPS_PHP_ERROR_LOG_PATH % context)
            init_vars['error_log'] = error_log_path
        return init_vars
github glic3rinu / django-orchestra / orchestra / apps / webapps / types.py View on Github external
def get_directive(self, webapp):
        context = self.get_directive_context(webapp)
        wrapper_path = os.path.normpath(settings.WEBAPPS_FCGID_PATH % context)
        return ('fcgid', webapp.get_path(), wrapper_path)
github glic3rinu / django-orchestra / orchestra / apps / webapps / backends / phpfpm.py View on Github external
def get_context(self, webapp):
        context = super(PHPFPMBackend, self).get_context(webapp)
        context.update({
            'fpm_config': self.get_fpm_config(webapp, context),
            'fpm_path': settings.WEBAPPS_PHPFPM_POOL_PATH % context,
        })
        return context
github glic3rinu / django-orchestra / orchestra / apps / webapps / types.py View on Github external
pass
    
    def get_related_objects(self, instance):
        pass
    
    def get_directive_context(self, webapp):
        return {
            'app_id': webapp.id,
            'app_name': webapp.name,
            'user': webapp.account.username,
        }


class PHPAppType(AppType):
    php_version = 5.4
    fpm_listen = settings.WEBAPPS_FPM_LISTEN
    
    def get_directive(self, webapp):
        context = self.get_directive_context(webapp)
        socket_type = 'unix'
        if ':' in self.fpm_listen:
            socket_type = 'tcp'
        socket = self.fpm_listen % context
        return ('fpm', socket_type, socket, webapp.get_path())
    
    def get_context(self, webapp):
        """ context used to format settings """
        return {
            'home': webapp.account.main_systemuser.get_home(),
            'account': webapp.account.username,
            'user': webapp.account.username,
            'app_name': webapp.name,
github glic3rinu / django-orchestra / orchestra / apps / webapps / backends / phpfpm.py View on Github external
def get_fpm_config(self, webapp, context):
        context.update({
            'init_vars': webapp.type_instance.get_php_init_vars(),
            'fpm_port': webapp.get_fpm_port(),
            'max_children': webapp.get_options().get('processes', False),
            'request_terminate_timeout': webapp.get_options().get('timeout', False),
        })
        context['fpm_listen'] = settings.WEBAPPS_FPM_LISTEN % context
        fpm_config = Template(textwrap.dedent("""\
            ;; {{ banner }}
            [{{ user }}]
            user = {{ user }}
            group = {{ group }}
            
            listen = {{ fpm_listen | safe }}
            listen.owner = {{ user }}
            listen.group = {{ group }}
            pm = ondemand
            {% if max_children %}pm.max_children = {{ max_children }}{% endif %}
            {% if request_terminate_timeout %}request_terminate_timeout = {{ request_terminate_timeout }}{% endif %}
            {% for name, value in init_vars.iteritems %}
            php_admin_value[{{ name | safe }}] = {{ value | safe }}{% endfor %}
            """
        ))
github glic3rinu / django-orchestra / orchestra / apps / webapps / types / __init__.py View on Github external
def get_plugins(cls):
        plugins = []
        for cls in settings.WEBAPPS_TYPES:
            plugins.append(import_class(cls))
        return plugins
github glic3rinu / django-orchestra / orchestra / apps / webapps / types.py View on Github external
option_groups = ()
    fpm_listen = settings.WEBAPPS_MOODLEMU_LISTEN


class DrupalMuApp(PHPAppType):
    name = 'drupal-mu'
    verbose_name = "Drupdal (SaaS)"
    directive = ('fpm', 'fcgi://127.0.0.1:8991/home/httpd/drupal-mu/')
    help_text = _("This creates a Drupal site into a multi-tenant Drupal server.<br>"
                  "The installation will be completed after visiting "
                  "http://&lt;app_name&gt;.drupal.orchestra.lan/install.php?profile=standard<br>"
                  "By default this site will be accessible via &lt;app_name&gt;.drupal.orchestra.lan")
    icon = 'orchestra/icons/apps/DrupalMu.png'
    unique_name = True
    option_groups = ()
    fpm_listen = settings.WEBAPPS_DRUPALMU_LISTEN


from rest_framework import serializers
from orchestra.forms import widgets
class SymbolicLinkForm(PluginDataForm):
    path = forms.CharField(label=_("Path"), widget=forms.TextInput(attrs={'size':'100'}),
            help_text=_("Path for the origin of the symbolic link."))


class SymbolicLinkSerializer(serializers.Serializer):
    path = serializers.CharField(label=_("Path"))


class SymbolicLinkApp(PHPAppType):
    name = 'symbolic-link'
    verbose_name = "Symbolic link"
github glic3rinu / django-orchestra / orchestra / apps / webapps / backends / wordpressmu.py View on Github external
def get_base_url(self):
        base_url = settings.WEBSITES_WORDPRESSMU_BASE_URL
        return base_url.rstrip('/')
github glic3rinu / django-orchestra / orchestra / apps / webapps / types / php.py View on Github external
from .. import settings
from ..options import AppOption

from . import AppType


help_message = _("Version of PHP used to execute this webapp. <br>"
    "Changing the PHP version may result in application malfunction, "
    "make sure that everything continue to work as expected.")


class PHPAppForm(PluginDataForm):
    php_version = forms.ChoiceField(label=_("PHP version"),
            choices=settings.WEBAPPS_PHP_VERSIONS,
            initial=settings.WEBAPPS_DEFAULT_PHP_VERSION,
            help_text=help_message)


class PHPAppSerializer(serializers.Serializer):
    php_version = serializers.ChoiceField(label=_("PHP version"),
            choices=settings.WEBAPPS_PHP_VERSIONS,
            default=settings.WEBAPPS_DEFAULT_PHP_VERSION,
            help_text=help_message)


class PHPApp(AppType):
    name = 'php'
    verbose_name = "PHP"
    help_text = _("This creates a PHP application under ~/webapps/&lt;app_name&gt;<br>")
    form = PHPAppForm
    serializer = PHPAppSerializer
github glic3rinu / django-orchestra / orchestra / apps / webapps / backends / wordpress.py View on Github external
def get_context(self, webapp):
        context = super(WordPressBackend, self).get_context(webapp)
        context.update({
            'db_name': webapp.data['db_name'],
            'db_user': webapp.data['db_user'],
            'password': webapp.data['password'],
            'db_host': settings.WEBAPPS_DEFAULT_MYSQL_DATABASE_HOST,
            'title': "%s blog's" % webapp.account.get_full_name(),
            'email': webapp.account.email,
        })
        return context