← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-longpoll-prod into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-longpoll-prod into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-longpoll-prod/+merge/97869

Enable longpoll in prod.
-- 
https://code.launchpad.net/~rvb/maas/maas-longpoll-prod/+merge/97869
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-longpoll-prod into lp:maas.
=== modified file 'contrib/maas-http.conf'
--- contrib/maas-http.conf	2012-03-15 13:58:32 +0000
+++ contrib/maas-http.conf	2012-03-16 15:00:29 +0000
@@ -13,6 +13,12 @@
     </Location>
 </IfModule>
 
+# Proxy to txlongpoll server.
+<IfModule mod_proxy.c>
+    ProxyPreserveHost on
+    ProxyPass /MAAS/longpoll/ http://localhost:5242/ retry=1
+</IfModule>
+
 # This can be safely removed once Django 1.4 is used: admin media
 # will be served using staticfiles.
 Alias /MAAS/static/admin/ /usr/share/pyshared/django/contrib/admin/media/

=== modified file 'src/maas/demo.py'
--- src/maas/demo.py	2012-03-15 22:43:55 +0000
+++ src/maas/demo.py	2012-03-16 15:00:29 +0000
@@ -35,14 +35,13 @@
 # In dev mode: Django should act as a proxy to txlongpoll.
 LONGPOLL_SERVER_URL = "http://localhost:5242/";
 
-# Disable longpoll by default for now. Set it back to 'longpoll/' to
+# Disable longpoll by default for now. Set it back to '/longpoll/' to
 # enable it.
 LONGPOLL_PATH = None
 
 # This should match the setting in /etc/pserv.yaml.
 PSERV_URL = "http://localhost:5241/api";
 
-RABBITMQ_PUBLISH = True
 
 LOGGING = {
     'version': 1,

=== modified file 'src/maas/settings.py'
--- src/maas/settings.py	2012-03-15 17:30:53 +0000
+++ src/maas/settings.py	2012-03-16 15:00:29 +0000
@@ -53,14 +53,13 @@
 
 # The relative path where a proxy to the Longpoll server can be
 # reached.  Longpolling will be disabled in the UI if this is None.
-LONGPOLL_PATH = 'longpoll/'
+LONGPOLL_PATH = '/longpoll/'
 
 # Default URL specifying protocol, host, and (if necessary) port where
 # this MAAS can be found.  Configuration can, and probably should,
 # override this.
 DEFAULT_MAAS_URL = "http://%s/"; % gethostname()
 
-
 if FORCE_SCRIPT_NAME is not None:
     LOGOUT_URL = FORCE_SCRIPT_NAME + LOGOUT_URL
     LOGIN_REDIRECT_URL = FORCE_SCRIPT_NAME + LOGIN_REDIRECT_URL
@@ -96,7 +95,7 @@
 RABBITMQ_PASSWORD = 'guest'
 RABBITMQ_VIRTUAL_HOST = '/'
 
-RABBITMQ_PUBLISH = False
+RABBITMQ_PUBLISH = True
 
 
 DATABASES = {

=== modified file 'src/maasserver/templates/maasserver/index.html'
--- src/maasserver/templates/maasserver/index.html	2012-03-15 13:59:16 +0000
+++ src/maasserver/templates/maasserver/index.html	2012-03-16 15:00:29 +0000
@@ -53,7 +53,7 @@
       {% if longpoll_queue and LONGPOLL_PATH %}
         Y.later(0, Y.maas.longpoll, function() {
           var longpollmanager = Y.maas.longpoll.setupLongPollManager(
-            '{{ longpoll_queue }}', '/{{ LONGPOLL_PATH }}');
+            '{{ longpoll_queue }}', '{{ LONGPOLL_PATH }}');
         });
       {% endif %}
     });

=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py	2012-03-15 18:38:12 +0000
+++ src/maasserver/tests/test_views.py	2012-03-16 15:00:29 +0000
@@ -34,7 +34,10 @@
     LoggedInTestCase,
     TestCase,
     )
-from maasserver.urls import get_proxy_longpoll_enabled
+from maasserver.urls import (
+    get_proxy_longpoll_enabled,
+    remove_prefix,
+    )
 from maasserver.views import (
     get_longpoll_context,
     get_yui_location,
@@ -244,6 +247,15 @@
             ['LONGPOLL_PATH', 'longpoll_queue'], list(context))
         self.assertEqual(longpoll, context['LONGPOLL_PATH'])
 
+    def test_remove_prefix_if_prefix(self):
+        url_without_prefix = factory.getrandomstring()
+        url = '/%s' % url_without_prefix
+        self.assertequal(url_without_prefix, remove_prefix(url))
+
+    def test_remove_prefix_if_no_prefix(self):
+        url_without_prefix = factory.getrandomstring()
+        self.assertequal(url_without_prefix, remove_prefix(url_without_prefix))
+
 
 class UserPrefsViewTest(LoggedInTestCase):
 

=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py	2012-03-15 13:59:47 +0000
+++ src/maasserver/urls.py	2012-03-16 15:00:29 +0000
@@ -89,10 +89,17 @@
         django_settings.LONGPOLL_PATH is not None)
 
 
+def remove_prefix(url):
+    if url.startswith('/'):
+        return url[1:]
+    else:
+        return url
+
+
 if get_proxy_longpoll_enabled():
     urlpatterns += patterns('maasserver.views',
         url(
-            r'^%s$' % re.escape(django_settings.LONGPOLL_PATH),
+            r'^%s$' % re.escape(remove_prefix(django_settings.LONGPOLL_PATH)),
             proxy_to_longpoll, name='proxy-to-longpoll'),
         )
 


Follow ups