diff --git a/TODO.md b/TODO.md
index ddc5cd57..5d397729 100644
--- a/TODO.md
+++ b/TODO.md
@@ -425,3 +425,5 @@ mkhomedir_helper or create ssh homes with bash.rc and such
# wordpressmu custom_url: set blog.domain
+
+# validate_user on saas.wordpress to detect if username already exists before attempting to create a blog
diff --git a/orchestra/contrib/saas/backends/__init__.py b/orchestra/contrib/saas/backends/__init__.py
index 678c5b9b..e2cc4e81 100644
--- a/orchestra/contrib/saas/backends/__init__.py
+++ b/orchestra/contrib/saas/backends/__init__.py
@@ -13,12 +13,15 @@ class ApacheTrafficByHost(ServiceMonitor):
Compatible log format:
LogFormat "%h %l %u %t \"%r\" %>s %O %{Host}i" host
+ or if include_received_bytes:
+ LogFormat "%h %l %u %t \"%r\" %>s %I %O %{Host}i" host
CustomLog /home/pangea/logs/apache/host_blog.pangea.org.log host
"""
model = 'saas.SaaS'
script_executable = '/usr/bin/python'
monthly_sum_old_values = True
abstract = True
+ include_received_bytes = False
def prepare(self):
access_log = self.log_path
@@ -26,6 +29,7 @@ class ApacheTrafficByHost(ServiceMonitor):
'access_logs': str((access_log, access_log+'.1')),
'current_date': self.current_date.strftime("%Y-%m-%d %H:%M:%S %Z"),
'ignore_hosts': str(settings.SAAS_TRAFFIC_IGNORE_HOSTS),
+ 'include_received_bytes': str(self.include_received_bytes),
}
self.append(textwrap.dedent("""\
import sys
@@ -65,6 +69,7 @@ class ApacheTrafficByHost(ServiceMonitor):
sites[site_domain] = [ini_date, object_id, 0]
def monitor(sites, end_date, months, access_logs):
+ include_received = {include_received_bytes}
for access_log in access_logs:
try:
with open(access_log, 'r') as handler:
@@ -74,6 +79,9 @@ class ApacheTrafficByHost(ServiceMonitor):
if host in {ignore_hosts}:
continue
size, hostname = line[-2:]
+ size = int(size)
+ if include_received:
+ size += int(line[-3])
try:
site = sites[hostname]
except KeyError:
@@ -84,7 +92,7 @@ class ApacheTrafficByHost(ServiceMonitor):
year, hour, min, sec = date.split(':')
date = year + months[month] + day + hour + min + sec
if site[0] < int(date) < end_date:
- site[2] += int(size)
+ site[2] += size
except IOError as e:
sys.stderr.write(str(e)+'\\n')
for opts in sites.values():
diff --git a/orchestra/contrib/saas/services/gitlab.py b/orchestra/contrib/saas/services/gitlab.py
index 082df590..f62042ce 100644
--- a/orchestra/contrib/saas/services/gitlab.py
+++ b/orchestra/contrib/saas/services/gitlab.py
@@ -16,12 +16,12 @@ class GitLabForm(SaaSPasswordForm):
class GitLaChangeForm(GitLabForm):
user_id = forms.IntegerField(label=("User ID"), widget=widgets.SpanWidget,
- help_text=_("ID of this user on the GitLab server, the only attribute that not changes."))
+ help_text=_("ID of this user used by GitLab, the only attribute that doesn't change."))
class GitLabSerializer(serializers.Serializer):
email = serializers.EmailField(label=_("Email"))
- user_id = serializers.IntegerField(label=_("User ID"), required=False)
+ user_id = serializers.IntegerField(label=_("User ID"), allow_null=True, required=False)
class GitLabService(SoftwareService):
diff --git a/orchestra/contrib/saas/services/wordpress.py b/orchestra/contrib/saas/services/wordpress.py
index 0a14bff1..ff8ad933 100644
--- a/orchestra/contrib/saas/services/wordpress.py
+++ b/orchestra/contrib/saas/services/wordpress.py
@@ -11,11 +11,9 @@ from ..forms import SaaSBaseForm
class WordPressForm(SaaSBaseForm):
- email = forms.EmailField(label=_("Email"), widget=forms.TextInput(attrs={'size':'40'}),
+ email = forms.EmailField(label=_("Email"),
help_text=_("A new user will be created if the above email address is not in the database.
"
"The username and password will be mailed to this email address."))
- blog_id = forms.IntegerField(label=("Blog ID"), widget=widgets.SpanWidget, required=False,
- help_text=_("ID of this user on the GitLab server, the only attribute that not changes."))
def __init__(self, *args, **kwargs):
super(WordPressForm, self).__init__(*args, **kwargs)
@@ -25,15 +23,21 @@ class WordPressForm(SaaSBaseForm):
self.fields['site_url'].help_text = mark_safe(help_text)
+class WordPressChangeForm(WordPressForm):
+ blog_id = forms.IntegerField(label=("Blog ID"), widget=widgets.SpanWidget, required=False,
+ help_text=_("ID of this blog used by WordPress, the only attribute that doesn't change."))
+
+
class WordPressDataSerializer(serializers.Serializer):
email = serializers.EmailField(label=_("Email"))
- blog_id = serializers.IntegerField(label=_("Blog ID"), required=False)
+ blog_id = serializers.IntegerField(label=_("Blog ID"), allow_null=True, required=False)
class WordPressService(SoftwareService):
name = 'wordpress'
verbose_name = "WordPress"
form = WordPressForm
+ change_form = WordPressChangeForm
serializer = WordPressDataSerializer
icon = 'orchestra/icons/apps/WordPress.png'
change_readonly_fileds = ('email', 'blog_id')
diff --git a/orchestra/contrib/vps/backends.py b/orchestra/contrib/vps/backends.py
index ed8a1c2c..3d4948e6 100644
--- a/orchestra/contrib/vps/backends.py
+++ b/orchestra/contrib/vps/backends.py
@@ -72,7 +72,7 @@ class ProxmoxOVZ(ServiceController):
context['password'] = vps.password.replace('$', '\\$')
ssh_commands.append(textwrap.dedent("""\
echo 'root:%(password)s' \\
- | chroot /var/lib/vz/private/${info[0]} chpasswd -e""") % context
+ | chroot /var/lib/vz/private/${info[0]} chpasswd -e""") % context
)
self.run_ssh_commands(ssh_commands)
diff --git a/orchestra/plugins/forms.py b/orchestra/plugins/forms.py
index 4a915ad6..a657d748 100644
--- a/orchestra/plugins/forms.py
+++ b/orchestra/plugins/forms.py
@@ -28,7 +28,7 @@ class PluginDataForm(forms.ModelForm):
self.plugin_field: plugin_help_text or model_help_text
}
for field in self.plugin.get_change_readonly_fileds():
- value = getattr(self.instance, field, None) or self.instance.data[field]
+ value = getattr(self.instance, field, None) or self.instance.data.get(field)
display = value
foo_display = getattr(self.instance, 'get_%s_display' % field, None)
if foo_display: