← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/use-proxy into lp:maas

 

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

Commit message:
Pass the configured proxy onto nodes.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/use-proxy/+merge/134275

Pass the configured proxy onto nodes.  If set, the proxy will be used instead of the default (the deb proxy installed on the region controller).

= Notes =

Pre imp'ed with Julian.
-- 
https://code.launchpad.net/~rvb/maas/use-proxy/+merge/134275
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/use-proxy into lp:maas.
=== modified file 'contrib/preseeds_v2/generic'
--- contrib/preseeds_v2/generic	2012-11-12 14:32:26 +0000
+++ contrib/preseeds_v2/generic	2012-11-14 10:35:26 +0000
@@ -9,7 +9,11 @@
 d-i     mirror/http/hostname string {{ports_archive_hostname}}
 d-i     mirror/http/directory string {{ports_archive_directory}}
 {{endif}}
+{{if http_proxy }}
+d-i     mirror/http/proxy string {{http_proxy}}
+{{else}}
 d-i     mirror/http/proxy string http://{{server_host}}:8000/
+{{endif}}
 {{enddef}}
 
 {{def client_packages}}

=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py	2012-11-13 10:44:22 +0000
+++ src/maasserver/forms.py	2012-11-14 10:35:26 +0000
@@ -608,7 +608,9 @@
         help_text=(
             "This is used by the cluster and region controllers for "
             "downloading PXE boot images and other provisioning-related "
-            "resources. It is not passed into provisioned nodes."))
+            "resources. This will also be passed onto provisioned "
+            "nodes instead of the default proxy (the region controller "
+            "proxy)."))
 
 
 class CommissioningForm(ConfigForm):

=== modified file 'src/maasserver/preseed.py'
--- src/maasserver/preseed.py	2012-11-12 14:32:26 +0000
+++ src/maasserver/preseed.py	2012-11-14 10:35:26 +0000
@@ -231,6 +231,7 @@
         'server_host': server_host,
         'server_url': absolute_reverse('nodes_handler'),
         'metadata_enlist_url': absolute_reverse('enlist'),
+        'http_proxy': Config.objects.get_config('http_proxy'),
         }
     if node is not None:
         # Create the url and the url-data (POST parameters) used to turn off

=== modified file 'src/maasserver/tests/test_preseed.py'
--- src/maasserver/tests/test_preseed.py	2012-11-12 14:32:26 +0000
+++ src/maasserver/tests/test_preseed.py	2012-11-14 10:35:26 +0000
@@ -23,10 +23,7 @@
     NODE_STATUS,
     PRESEED_TYPE,
     )
-from maasserver.models import (
-    BootImage,
-    Config,
-    )
+from maasserver.models import Config
 from maasserver.preseed import (
     compose_enlistment_preseed_url,
     compose_preseed_url,
@@ -328,7 +325,9 @@
              'server_host', 'server_url', 'preseed_data',
              'node_disable_pxe_url', 'node_disable_pxe_data',
              'main_archive_hostname', 'main_archive_directory',
-             'ports_archive_hostname', 'ports_archive_directory'],
+             'ports_archive_hostname', 'ports_archive_directory',
+             'http_proxy',
+             ],
             context)
 
     def test_get_preseed_context_if_node_None(self):
@@ -340,7 +339,9 @@
         self.assertItemsEqual(
             ['release', 'metadata_enlist_url', 'server_host', 'server_url',
             'main_archive_hostname', 'main_archive_directory',
-            'ports_archive_hostname', 'ports_archive_directory'],
+            'ports_archive_hostname', 'ports_archive_directory',
+            'http_proxy',
+            ],
             context)
 
     def test_get_preseed_context_archive_refs(self):
@@ -425,6 +426,31 @@
         self.assertThat(preseed, ContainsAll(default_snippets))
 
 
+class TestPreseedProxy(TestCase):
+
+    def test_preseed_uses_default_proxy(self):
+        server_host = factory.getRandomString().lower()
+        url = 'http://%s:%d/%s' % (
+            server_host, factory.getRandomPort(), factory.getRandomString())
+        self.patch(settings, 'DEFAULT_MAAS_URL', url)
+        expected_proxy_statement = (
+                "mirror/http/proxy string http://%s:8000"; % server_host)
+        preseed = render_preseed(
+            factory.make_node(), PRESEED_TYPE.DEFAULT, "precise")
+        self.assertIn(expected_proxy_statement, preseed)
+
+    def test_preseed_uses_configured_proxy(self):
+        http_proxy = 'http://%s:%d/%s' % (
+            factory.getRandomString(), factory.getRandomPort(),
+            factory.getRandomString())
+        Config.objects.set_config('http_proxy', http_proxy)
+        expected_proxy_statement = (
+            "mirror/http/proxy string %s" % http_proxy)
+        preseed = render_preseed(
+            factory.make_node(), PRESEED_TYPE.DEFAULT, "precise")
+        self.assertIn(expected_proxy_statement, preseed)
+
+
 class TestPreseedMethods(TestCase):
     """Tests for `get_enlist_preseed` and `get_preseed`.