launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14596
[Merge] lp:~rvb/maas/enlistment-user-data into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/enlistment-user-data into lp:maas.
Commit message:
Fix the enlistment user data: use the maas_url stored on the related nodegroup.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1081701 in MAAS: "The metadata address mentioned in the preseed is wrong."
https://bugs.launchpad.net/maas/+bug/1081701
For more details, see:
https://code.launchpad.net/~rvb/maas/enlistment-user-data/+merge/136670
--
https://code.launchpad.net/~rvb/maas/enlistment-user-data/+merge/136670
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/enlistment-user-data into lp:maas.
=== modified file 'src/metadataserver/api.py'
--- src/metadataserver/api.py 2012-11-27 10:26:19 +0000
+++ src/metadataserver/api.py 2012-11-28 14:12:20 +0000
@@ -377,7 +377,9 @@
def read(self, request, version):
check_version(version)
- return HttpResponse(get_enlist_userdata(), mimetype="text/plain")
+ nodegroup = find_nodegroup(request)
+ return HttpResponse(
+ get_enlist_userdata(nodegroup=nodegroup), mimetype="text/plain")
class EnlistVersionIndexHandler(OperationsHandler):
=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py 2012-11-26 08:52:01 +0000
+++ src/metadataserver/tests/test_api.py 2012-11-28 14:12:20 +0000
@@ -53,7 +53,11 @@
from mock import Mock
from netaddr import IPNetwork
from provisioningserver.enum import POWER_TYPE
-from testtools.matchers import Contains
+from testtools.matchers import (
+ Contains,
+ MatchesAll,
+ Not,
+ )
class TestHelpers(DjangoTestCase):
@@ -729,6 +733,20 @@
(response.status_code, response["Content-Type"], response.content),
response)
+ def test_get_userdata_detects_request_origin(self):
+ ng_url = 'http://%s' % factory.make_name('host')
+ maas_url = 'http://%s' % factory.make_hostname()
+ self.patch(settings, 'DEFAULT_MAAS_URL', maas_url)
+ network = IPNetwork("10.1.1/24")
+ ip = factory.getRandomIPInNetwork(network)
+ factory.make_node_group(maas_url=ng_url, network=network)
+ ud_url = reverse('enlist-metadata-user-data', args=['latest'])
+ response = self.client.get(ud_url, SERVER_NAME=ip)
+ self.assertThat(response.content, Contains(ng_url))
+ self.assertThat(
+ response.content,
+ MatchesAll(*[Contains(ng_url), Not(Contains(maas_url))]))
+
def test_metadata_list(self):
# /enlist/latest/metadata request should list available keys
md_url = reverse('enlist-metadata-meta-data', args=['latest', ""])