public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [Autotest]frontend: Replaces mod_python by mod_wsgi apache module and repair autoinstall script
@ 2012-06-07 12:54 Jiří Župka
  2012-06-07 12:54 ` [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module Jiří Župka
  2012-06-07 12:54 ` [PATCH 2/2] contrib: Repairg bug in autotest install script Jiří Župka
  0 siblings, 2 replies; 4+ messages in thread
From: Jiří Župka @ 2012-06-07 12:54 UTC (permalink / raw)
  To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka

Pull-request: https://github.com/autotest/autotest/pull/384

[Autotest][PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module
[Autotest][PATCH 2/2] contrib: Repairg bug in autotest install script.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module
  2012-06-07 12:54 [Autotest]frontend: Replaces mod_python by mod_wsgi apache module and repair autoinstall script Jiří Župka
@ 2012-06-07 12:54 ` Jiří Župka
  2012-06-08 23:18   ` Lucas Meneghel Rodrigues
  2012-06-07 12:54 ` [PATCH 2/2] contrib: Repairg bug in autotest install script Jiří Župka
  1 sibling, 1 reply; 4+ messages in thread
From: Jiří Župka @ 2012-06-07 12:54 UTC (permalink / raw)
  To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka

This patch also repairs bug with readonly_connection to
mysql database.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
 apache/conf/django-directives    |   49 +++++++++++++++++++++++++++++--------
 frontend/db/backends/afe/base.py |   11 ++++++++
 frontend/frontend.wsgi           |   32 ++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 11 deletions(-)
 create mode 100644 frontend/frontend.wsgi

diff --git a/apache/conf/django-directives b/apache/conf/django-directives
index ce6c5c7..79914a0 100644
--- a/apache/conf/django-directives
+++ b/apache/conf/django-directives
@@ -13,6 +13,10 @@ RewriteEngine On
 RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d
 RewriteRule /media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/media/$1/$2
 
+# Django 1.4 does change location of the admin css files
+RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
+RewriteRule /media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$1/$2
+
 RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d
 RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/media/$1/$2
 
@@ -25,14 +29,37 @@ RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/cont
 RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d
 RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/media/$1/$2
 
-<Location ~ "/(afe|new_tko)/server">
-    SetHandler python-program
-    PythonHandler django.core.handlers.modpython
-    SetEnv DJANGO_SETTINGS_MODULE frontend.settings
-    PythonDebug On
-    # Force our own site-packages to be loaded by mod_python prior
-    # to mod_python's system python site-packages directory.
-    # This way our code can depend on library versions other than
-    # those available as packages on various OS distributions.
-    PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path"
-</Location>
+# Django 1.4 does change location of the admin css files
+RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d
+RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
+
+#Old configuration for mod_python.
+
+#<Location ~ "/(afe|new_tko)/server">
+#    SetHandler python-program
+#    PythonHandler django.core.handlers.modpython
+#    SetEnv DJANGO_SETTINGS_MODULE frontend.settings
+#    PythonDebug On
+#    # Force our own site-packages to be loaded by mod_python prior
+#    # to mod_python's system python site-packages directory.
+#    # This way our code can depend on library versions other than
+#    # those available as packages on various OS distributions.
+#    PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path"
+#</Location>
+
+
+#New configuration for mod_swgi
+
+RewriteRule ^/(afe|new_tko)/server(.*)$ /$1/server$2 [QSA,PT,L]
+
+WSGISocketPrefix run/wsgi
+#Thread have to be only one because there could be problem with readonly_connection.
+WSGIDaemonProcess apache processes=10 threads=1
+WSGIProcessGroup apache
+
+WSGIScriptAliasMatch /(afe|new_tko)/server.* /usr/local/autotest/frontend/frontend.wsgi
+
+<Directory /usr/local/autotest/frontend/>
+    Order allow,deny
+    Allow from all
+</Directory>
diff --git a/frontend/db/backends/afe/base.py b/frontend/db/backends/afe/base.py
index 067abac..64114b8 100644
--- a/frontend/db/backends/afe/base.py
+++ b/frontend/db/backends/afe/base.py
@@ -20,3 +20,14 @@ class DatabaseWrapper(MySQLDatabaseWrapper):
         self.creation = MySQLCreation(self)
         self.ops = DatabaseOperations()
         self.introspection = MySQLIntrospection(self)
+
+    def _valid_connection(self):
+        if self.connection is not None:
+            if self.connection.open:
+                try:
+                    self.connection.ping()
+                    return True
+                except DatabaseError:
+                    self.connection.close()
+                    self.connection = None
+        return False
diff --git a/frontend/frontend.wsgi b/frontend/frontend.wsgi
new file mode 100644
index 0000000..ff1e54b
--- /dev/null
+++ b/frontend/frontend.wsgi
@@ -0,0 +1,32 @@
+import os, sys
+
+try:
+   import autotest.common
+except ImportError:
+   frontend_dir = os.path.dirname(sys.modules[__name__].__file__)
+   sys.path.insert(0, frontend_dir)
+   import common
+   sys.path.pop(0)
+
+path_list = ['/usr/local/autotest/site-packages', '/usr/local/autotest',
+            '/usr/lib/python2.7/site-packages/autotest',
+            '/usr/lib/python2.6/site-packages/autotest',
+            '/usr/lib/python2.5/site-packages/autotest',
+            '/usr/lib/python2.4/site-packages/autotest']
+
+for p in path_list:
+   if os.path.isdir(p):
+       sys.path.append(p)
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'autotest.frontend.settings'
+#os.environ['DJANGO_USE_POST_REWRITE'] = "aaa"
+
+
+import django.core.handlers.wsgi
+
+_application = django.core.handlers.wsgi.WSGIHandler()
+
+def application(environ, start_response):
+    environ['DJANGO_USE_POST_REWRITE'] = "yes"
+    environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
+    return _application(environ, start_response)
-- 
1.7.7.6

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] contrib: Repairg bug in autotest install script.
  2012-06-07 12:54 [Autotest]frontend: Replaces mod_python by mod_wsgi apache module and repair autoinstall script Jiří Župka
  2012-06-07 12:54 ` [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module Jiří Župka
@ 2012-06-07 12:54 ` Jiří Župka
  1 sibling, 0 replies; 4+ messages in thread
From: Jiří Župka @ 2012-06-07 12:54 UTC (permalink / raw)
  To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka

The patch corrects creation of directory for autotest git.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
 contrib/install-autotest-server.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/install-autotest-server.sh b/contrib/install-autotest-server.sh
index ec0f5d9..317649c 100755
--- a/contrib/install-autotest-server.sh
+++ b/contrib/install-autotest-server.sh
@@ -173,7 +173,7 @@ fi
 
 install_packages() {
 PACKAGES_UTILITY=(unzip wget)
-PACAKGES_WEBSERVER=(httpd mod_python Django)
+PACAKGES_WEBSERVER=(httpd mod_wsgi Django)
 PACKAGES_MYSQL=(mysql-server MySQL-python)
 PACKAGES_DEVELOPMENT=(git java-1.6.0-openjdk-devel)
 PACKAGES_PYTHON_LIBS=(python-imaging python-crypto python-paramiko python-httplib2 numpy python-matplotlib python-atfork)
@@ -233,7 +233,7 @@ then
 $ATPASSWD" | passwd --stdin autotest >> $LOG
 fi
 
-mkdir -p /usr/local
+mkdir -p $ATHOME
 if [ ! -e $ATHOME/.git/config ]
 then
     print_log "INFO" "Cloning autotest repo in $ATHOME"
-- 
1.7.7.6

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module
  2012-06-07 12:54 ` [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module Jiří Župka
@ 2012-06-08 23:18   ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2012-06-08 23:18 UTC (permalink / raw)
  To: Jiří Župka; +Cc: autotest, kvm-autotest, kvm

On Thu, 2012-06-07 at 14:54 +0200, Jiří Župka wrote:
> This patch also repairs bug with readonly_connection to
> mysql database.

Awesome Jiri, I'm very happy that you took the task and delivered
this :) I have applied a slightly modified version to the next branch,
look at my comments:

> +
> +os.environ['DJANGO_SETTINGS_MODULE'] = 'autotest.frontend.settings'

^ I discovered that the module in the form x.y.z will cause problems
with the Django i18 system, so I modified this script, see the newest
version here:

https://github.com/autotest/autotest/commit/ee3cced1afb6bc45216c7038472827ad4033c3f5

In the modified version you'll also notice that I did remove the
comemnted area of django-directives. In any case, this looks great, and
will soon land on master. Thanks for your work!

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-08 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 12:54 [Autotest]frontend: Replaces mod_python by mod_wsgi apache module and repair autoinstall script Jiří Župka
2012-06-07 12:54 ` [PATCH 1/2] frontend: Replaces mod_python by mod_wsgi apache module Jiří Župka
2012-06-08 23:18   ` Lucas Meneghel Rodrigues
2012-06-07 12:54 ` [PATCH 2/2] contrib: Repairg bug in autotest install script Jiří Župka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox