← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/preseed-render-enlistment-service into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/preseed-render-enlistment-service into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~allenap/maas/preseed-render-enlistment-service/+merge/111591
-- 
https://code.launchpad.net/~allenap/maas/preseed-render-enlistment-service/+merge/111591
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/preseed-render-enlistment-service into lp:maas.
=== modified file 'src/metadataserver/api.py'
--- src/metadataserver/api.py	2012-06-22 09:01:32 +0000
+++ src/metadataserver/api.py	2012-06-22 12:55:27 +0000
@@ -42,7 +42,10 @@
     Node,
     SSHKey,
     )
-from maasserver.preseed import get_preseed
+from maasserver.preseed import (
+    get_enlist_preseed,
+    get_preseed,
+    )
 from metadataserver.models import (
     NodeCommissionResult,
     NodeKey,
@@ -331,6 +334,11 @@
 class AnonMetaDataHandler(VersionIndexHandler):
     """Anonymous metadata."""
 
+    @staticmethod
+    def get_enlist_preseed(request, version=None):
+        """Render and return a preseed script for enlistment."""
+        return HttpResponse(get_enlist_preseed(), mimetype="text/plain")
+
     @api_exported('GET')
     def get_preseed(self, request, version=None, system_id=None):
         """Render and return a preseed script for the given node."""

=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py	2012-06-22 09:01:32 +0000
+++ src/metadataserver/tests/test_api.py	2012-06-22 12:55:27 +0000
@@ -554,6 +554,23 @@
             (response.status_code, node.netboot),
             response)
 
+    def test_anonymous_get_enlist_preseed(self):
+        # The preseed for enlistment can be obtained anonymously.
+        anon_enlist_preseed_url = reverse(
+            'metadata-enlist-preseed', args=['latest'])
+        # Fake the preseed so we're just exercising the view.
+        fake_preseed = factory.getRandomString()
+        self.patch(api, "get_enlist_preseed", lambda: fake_preseed)
+        response = self.client.get(anon_enlist_preseed_url)
+        self.assertEqual(
+            (httplib.OK,
+             "text/plain",
+             fake_preseed),
+            (response.status_code,
+             response["Content-Type"],
+             response.content),
+            response)
+
     def test_anonymous_get_preseed(self):
         # The preseed for a node can be obtained anonymously.
         node = factory.make_node()

=== modified file 'src/metadataserver/urls.py'
--- src/metadataserver/urls.py	2012-06-21 20:56:18 +0000
+++ src/metadataserver/urls.py	2012-06-22 12:55:27 +0000
@@ -37,6 +37,7 @@
 
 # Handlers for anonymous metadata operations.
 meta_data_node_by_id_handler = Resource(AnonMetaDataHandler)
+meta_data_get_enlist_preseed = AnonMetaDataHandler.get_enlist_preseed
 
 
 # Handlers for UNSAFE anonymous random metadata access.
@@ -72,6 +73,10 @@
         r'(?P<version>[^/]+)/by-id/(?P<system_id>[\w\-]+)/$',
         meta_data_node_by_id_handler,
         name='metadata-node-by-id'),
+    url(
+        r'(?P<version>[^/]+)/enlist-preseed$',
+        meta_data_get_enlist_preseed,
+        name='metadata-enlist-preseed'),
     )
 
 # UNSAFE anonymous random metadata access, keyed by MAC address.  These won't