launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12012
[Merge] lp:~rvb/maas/celery-credentials-bug-1050492 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/celery-credentials-bug-1050492 into lp:maas.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~rvb/maas/celery-credentials-bug-1050492/+merge/124443
This branch adds an explicit BROKER_URL setting in the celeryconfig file and use that value to send RabbitMQ credentials to approved cluster controllers.
= Pre-imp =
This was discussed with Jeroen.
= Notes =
You'll note that the content of this BROKER_URL still contains the "default" broker info. That's because we rely on that to work in the tests, in a dev instance *and* in production right now. More work needs to be done in that area.
--
https://code.launchpad.net/~rvb/maas/celery-credentials-bug-1050492/+merge/124443
Your team MAAS Maintainers is requested to review the proposed merge of lp:~rvb/maas/celery-credentials-bug-1050492 into lp:maas.
=== modified file 'etc/celeryconfig.py'
--- etc/celeryconfig.py 2012-09-12 07:06:24 +0000
+++ etc/celeryconfig.py 2012-09-14 14:55:24 +0000
@@ -40,6 +40,9 @@
# ISC dhcpd configuration file.
DHCP_CONFIG_FILE = '/etc/dhcp/dhcpd.conf'
+# Broken connection information.
+# Format: transport://userid:password@hostname:port/virtual_host
+BROKER_URL = 'amqp://guest:guest@localhost:5672//'
try:
import user_maasceleryconfig
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-09-14 10:10:43 +0000
+++ src/maasserver/api.py 2012-09-14 14:55:24 +0000
@@ -81,6 +81,7 @@
from textwrap import dedent
import types
+from celery.app import app_or_default
from django.conf import settings
from django.core.exceptions import (
PermissionDenied,
@@ -905,7 +906,8 @@
call:
- 200 (OK): the nodegroup has been accepted, the response will
- contrain the RabbitMQ credentials in JSON format.
+ contain the RabbitMQ credentials in JSON format: e.g.:
+ '{"BROKER_URL" = "amqp://guest:guest@localhost:5672//"}'
- 202 (Accepted): the registration of the nodegroup has been accepted,
it now needs to be validated by an administrator. Please issue
the same request later.
@@ -941,12 +943,9 @@
if existing_nodegroup.status == NODEGROUP_STATUS.ACCEPTED:
# The nodegroup exists and is validated, return the RabbitMQ
# credentials as JSON.
- # XXX: rvb 2012-09-13 bug=1050492: MAAS uses the 'guest'
- # account to communicate with RabbitMQ, hence none of the
- # connection information are defined.
+ celery_conf = app_or_default().conf
return {
- # TODO: send RabbiMQ credentials.
- 'test': 'test',
+ 'BROKER_URL': celery_conf.BROKER_URL,
}
elif existing_nodegroup.status == NODEGROUP_STATUS.REJECTED:
raise PermissionDenied('Rejected cluster.')
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-09-14 11:21:28 +0000
+++ src/maasserver/tests/test_api.py 2012-09-14 14:55:24 +0000
@@ -29,6 +29,7 @@
import shutil
from apiclient.maas_client import MAASClient
+from celery.app import app_or_default
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse
@@ -2484,6 +2485,9 @@
self.assertEqual(httplib.FORBIDDEN, response.status_code)
def test_register_accepted_cluster_gets_credentials(self):
+ fake_broker_url = factory.make_name('fake-broker_url')
+ celery_conf = app_or_default().conf
+ self.patch(celery_conf, 'BROKER_URL', fake_broker_url)
nodegroup = factory.make_node_group()
nodegroup.status = NODEGROUP_STATUS.ACCEPTED
nodegroup.save()
@@ -2497,10 +2501,7 @@
self.assertEqual(httplib.OK, response.status_code)
parsed_result = json.loads(response.content)
self.assertIn('application/json', response['Content-Type'])
- # XXX: rvb 2012-09-13 bug=1050492: MAAS uses the 'guest' account to
- # communicate with RabbitMQ, hence none of the connection information
- # are defined.
- self.assertEqual({'test': 'test'}, parsed_result)
+ self.assertEqual({'BROKER_URL': fake_broker_url}, parsed_result)
def explain_unexpected_response(expected_status, response):
Follow ups