Added preliminar support for Docker containers

This commit is contained in:
Marc Aymerich 2015-09-30 16:26:44 +00:00
parent be8f830ebb
commit 5f17267ff7
8 changed files with 52 additions and 38 deletions

View File

@ -77,8 +77,6 @@
* prevent @pangea.org email addresses on contacts, enforce at least one email without @pangea.org
* forms autocomplete="off", doesn't work in chrome
ln -s /proc/self/fd /dev/fd
@ -388,3 +386,7 @@ Case
# Modsecurity rules template by cms (wordpress, joomla, dokuwiki (973337 973338 973347 958057), ...
# saas custom domains support (maybe a new form field with custom url? autoconfigure websites?)
custom_url form field and validate/create/delete related website
SAAS_PHPLIST_ALLOW_CUSTOM_URL = False

View File

@ -29,18 +29,6 @@ function print_help () {
${bold}install_requirements${normal}
Installs Orchestra requirements using apt-get and pip
${bold}install_postfix${normal}
Installs postfix packages including dovecot, amavis, spamassassin and clamav
${bold}uninstall_postfix${normal}
Uninstall postfix packages including dovecot, amavis, spamassassin and clamav
${bold}install_certificate${normal}
Installs a valid all-purpose self signed certificate that is valid for the next ten years
${bold}uninstall_certificate${normal}
Uninstall certificate
${bold}startproject${normal}
Creates a new Django-orchestra instance

View File

@ -19,8 +19,10 @@ def get_backends_help_text(backends):
'model': backend.model,
'related_models': str(backend.related_models),
'script_executable': backend.script_executable,
'script_method': '.'.join((backend.script_method.__module__, backend.script_method.__name__)),
'function_method': '.'.join((backend.function_method.__module__, backend.function_method.__name__)),
'script_method': '.'.join(
(backend.script_method.__module__, backend.script_method.__name__)),
'function_method': '.'.join(
(backend.function_method.__module__, backend.function_method.__name__)),
'actions': str(backend.actions),
}
help_text += textwrap.dedent("""
@ -61,7 +63,9 @@ def send_report(method, args, log):
backend = method.__self__.__class__.__name__
subject = '[Orchestra] %s execution %s on %s' % (backend, log.state, server)
separator = "\n%s\n\n" % ('~ '*40,)
operations = '\n'.join([' '.join((op.action, get_instance_url(op))) for op in log.operations.all()])
operations = '\n'.join(
[' '.join((op.action, get_instance_url(op))) for op in log.operations.all()]
)
log_url = reverse('admin:orchestration_backendlog_change', args=(log.pk,))
log_url = orchestra_settings.ORCHESTRA_SITE_URL + log_url
message = separator.join([
@ -143,7 +147,9 @@ def message_user(request, logs):
_('<a href="{url}">{total} backend</a> has been executed'),
_('<a href="{url}">{total} backends</a> have been executed'),
total)
msg = msg.format(total=total, url=url, async_url=async_url, async=async, successes=successes)
msg = msg.format(
total=total, url=url, async_url=async_url, async=async, successes=successes
)
messages.success(request, mark_safe(msg + '.'))
else:
msg = async_msg.format(url=url, async_url=async_url, async=async)

View File

@ -48,11 +48,12 @@ class SaaSPasswordForm(SaaSBaseForm):
help_text=_("Passwords are not stored, so there is no way to see this "
"service's password, but you can change the password using "
"<a href=\"password/\">this form</a>."))
password1 = forms.CharField(label=_("Password"), validators=[validators.validate_password],
widget=forms.PasswordInput(attrs={'autocomplete': 'off'}))
password1 = forms.CharField(label=_("Password"),
widget=forms.PasswordInput(attrs={'autocomplete': 'off'}),
validators=[validators.validate_password])
password2 = forms.CharField(label=_("Password confirmation"),
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."))
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."))
def __init__(self, *args, **kwargs):
super(SaaSPasswordForm, self).__init__(*args, **kwargs)

View File

@ -1,5 +1,6 @@
import ast
import copy
import json
import os
import re
@ -91,7 +92,11 @@ def serialize(obj, init=True):
def _format_setting(name, value):
if isinstance(value, Remove):
return ""
value = serialize(eval(value), get_eval_context())
value = eval(value, get_eval_context())
try:
value = json.dumps(value, indent=4)
except TypeError:
value = serialize(value)
return "{name} = {value}".format(name=name, value=value)

View File

@ -0,0 +1,4 @@
FROM debian:latest
RUN apt-get -y update && apt-get install -y git screen sudo python3 python3-pip wget curl dnsutils rsyslog nano ssh-client
RUN export TERM=xterm; curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/orchestra/bin/orchestra-admin | bash -s install_requirements
RUN apt-get clean

View File

@ -6,8 +6,22 @@
set -ue
bold=$(tput bold)
normal=$(tput sgr0)
function main () {
bold=$(tput -T ${TERM:-xterm} bold)
normal=$(tput -T ${TERM:-xterm} sgr0)
surun () {
echo " ${bold}\$ su $USER -c \"${@}\"${normal}"
su $USER -c "${@}"
}
run () {
echo " ${bold}\$ ${@}${normal}"
${@}
}
[ $(whoami) != 'root' ] && {
@ -25,17 +39,6 @@ PYTHON_BIN="python3"
CELERY=false
surun () {
echo " ${bold}\$ su $USER -c \"${@}\"${normal}"
su $USER -c "${@}"
}
run () {
echo " ${bold}\$ ${@}${normal}"
${@}
}
# Create a system user for running Orchestra
useradd $USER -s "/bin/bash" || true
echo "$USER:$PASSWORD" | chpasswd
@ -72,7 +75,7 @@ fi
run "apt-get -y install postgresql"
if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$') ]]; then
# orchestra database does not esists
# orchestra database does not exists
# Speeding up tests, don't do this in production!
. /usr/share/postgresql-common/init.d-functions
POSTGRES_VERSION=$(psql --version | head -n1 | sed -r "s/^.*\s([0-9]+\.[0-9]+).*/\1/")
@ -142,3 +145,8 @@ ${bold}
- password: $PASSWORD
${normal}
EOF
}
# Wrap it all on a function to avoid partial executions when running through wget/curl
main