Merge lp:~allenap/maas/proxy-settings into lp:maas/trunk

Proposed by Gavin Panella on 2012-10-23
Status: Merged
Approved by: Gavin Panella on 2012-10-23
Approved revision: 1294
Merged at revision: 1292
Proposed branch: lp:~allenap/maas/proxy-settings
Merge into: lp:maas/trunk
Diff against target: 111 lines (+30/-10)
4 files modified
src/maasserver/forms.py (+6/-0)
src/maasserver/models/config.py (+1/-0)
src/maasserver/tests/test_config.py (+14/-6)
src/maasserver/tests/test_views_settings.py (+9/-4)
To merge this branch: bzr merge lp:~allenap/maas/proxy-settings
Reviewer Review Type Date Requested Status
Julian Edwards (community) 2012-10-23 Approve on 2012-10-23
Review via email: mp+130966@code.launchpad.net

Commit message

Add an http_proxy configuration setting, and allow it to be edited from the settings page.

To post a comment you must log in.
lp:~allenap/maas/proxy-settings updated on 2012-10-23
1293. By Gavin Panella on 2012-10-23

Remove unnecessary comma.

Julian Edwards (julian-edwards) wrote :

You might want to change the list of assertions into a single "matches all"

review: Approve
lp:~allenap/maas/proxy-settings updated on 2012-10-23
1294. By Gavin Panella on 2012-10-23

Check all updated configs at once.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-10-04 13:00:54 +0000
+++ src/maasserver/forms.py 2012-10-23 09:58:21 +0000
@@ -569,6 +569,12 @@
569 label="Default domain for new nodes", required=False, help_text=(569 label="Default domain for new nodes", required=False, help_text=(
570 "If 'local' is chosen, nodes must be using mDNS. Leave empty to "570 "If 'local' is chosen, nodes must be using mDNS. Leave empty to "
571 "use hostnames without a domain for newly enlisted nodes."))571 "use hostnames without a domain for newly enlisted nodes."))
572 http_proxy = forms.URLField(
573 label="Proxy for HTTP and HTTPS traffic", required=False,
574 help_text=(
575 "This is used by the cluster and region controllers for "
576 "downloading PXE boot images and other provisioning-related "
577 "resources. It is not passed into provisioned nodes."))
572578
573579
574class CommissioningForm(ConfigForm):580class CommissioningForm(ConfigForm):
575581
=== modified file 'src/maasserver/models/config.py'
--- src/maasserver/models/config.py 2012-09-27 13:50:34 +0000
+++ src/maasserver/models/config.py 2012-10-23 09:58:21 +0000
@@ -53,6 +53,7 @@
53 'enlistment_domain': b'local',53 'enlistment_domain': b'local',
54 'default_distro_series': DISTRO_SERIES.precise,54 'default_distro_series': DISTRO_SERIES.precise,
55 'commissioning_distro_series': DISTRO_SERIES.precise,55 'commissioning_distro_series': DISTRO_SERIES.precise,
56 'http_proxy': None,
56 ## /settings57 ## /settings
57 }58 }
5859
5960
=== modified file 'src/maasserver/tests/test_config.py'
--- src/maasserver/tests/test_config.py 2012-05-11 07:51:59 +0000
+++ src/maasserver/tests/test_config.py 2012-10-23 09:58:21 +0000
@@ -16,10 +16,8 @@
1616
17from fixtures import TestWithFixtures17from fixtures import TestWithFixtures
18from maasserver.models import Config18from maasserver.models import Config
19from maasserver.models.config import (19import maasserver.models.config
20 DEFAULT_CONFIG,20from maasserver.models.config import get_default_config
21 get_default_config,
22 )
23from maasserver.testing.factory import factory21from maasserver.testing.factory import factory
24from maasserver.testing.testcase import TestCase22from maasserver.testing.testcase import TestCase
2523
@@ -31,6 +29,14 @@
31 default_config = get_default_config()29 default_config = get_default_config()
32 self.assertEqual(gethostname(), default_config['maas_name'])30 self.assertEqual(gethostname(), default_config['maas_name'])
3331
32 def test_defaults(self):
33 expected = get_default_config()
34 observed = {
35 name: Config.objects.get_config(name)
36 for name in expected
37 }
38 self.assertEqual(expected, observed)
39
3440
35class CallRecorder:41class CallRecorder:
36 """A utility class which tracks the calls to its 'call' method and42 """A utility class which tracks the calls to its 'call' method and
@@ -63,13 +69,15 @@
63 def test_manager_get_config_not_found_in_default_config(self):69 def test_manager_get_config_not_found_in_default_config(self):
64 name = factory.getRandomString()70 name = factory.getRandomString()
65 value = factory.getRandomString()71 value = factory.getRandomString()
66 DEFAULT_CONFIG[name] = value72 self.patch(maasserver.models.config, "DEFAULT_CONFIG", {name: value})
67 config = Config.objects.get_config(name, None)73 config = Config.objects.get_config(name, None)
68 self.assertEqual(value, config)74 self.assertEqual(value, config)
6975
70 def test_default_config_cannot_be_changed(self):76 def test_default_config_cannot_be_changed(self):
71 name = factory.getRandomString()77 name = factory.getRandomString()
72 DEFAULT_CONFIG[name] = {'key': 'value'}78 self.patch(
79 maasserver.models.config, "DEFAULT_CONFIG",
80 {name: {'key': 'value'}})
73 config = Config.objects.get_config(name)81 config = Config.objects.get_config(name)
74 config.update({'key2': 'value2'})82 config.update({'key2': 'value2'})
7583
7684
=== modified file 'src/maasserver/tests/test_views_settings.py'
--- src/maasserver/tests/test_views_settings.py 2012-10-03 15:48:11 +0000
+++ src/maasserver/tests/test_views_settings.py 2012-10-23 09:58:21 +0000
@@ -82,6 +82,7 @@
82 self.patch(settings, "DNS_CONNECT", False)82 self.patch(settings, "DNS_CONNECT", False)
83 new_name = factory.getRandomString()83 new_name = factory.getRandomString()
84 new_domain = factory.getRandomString()84 new_domain = factory.getRandomString()
85 new_proxy = "http://%s.example.com:1234/" % factory.getRandomString()
85 response = self.client.post(86 response = self.client.post(
86 reverse('settings'),87 reverse('settings'),
87 get_prefixed_form_data(88 get_prefixed_form_data(
@@ -89,12 +90,16 @@
89 data={90 data={
90 'maas_name': new_name,91 'maas_name': new_name,
91 'enlistment_domain': new_domain,92 'enlistment_domain': new_domain,
93 'http_proxy': new_proxy,
92 }))94 }))
9395 self.assertEqual(httplib.FOUND, response.status_code, response.content)
94 self.assertEqual(httplib.FOUND, response.status_code)
95 self.assertEqual(new_name, Config.objects.get_config('maas_name'))
96 self.assertEqual(96 self.assertEqual(
97 new_domain, Config.objects.get_config('enlistment_domain'))97 (new_name,
98 new_domain,
99 new_proxy),
100 (Config.objects.get_config('maas_name'),
101 Config.objects.get_config('enlistment_domain'),
102 Config.objects.get_config('http_proxy')))
98103
99 def test_settings_commissioning_POST(self):104 def test_settings_commissioning_POST(self):
100 new_after_commissioning = factory.getRandomEnum(105 new_after_commissioning = factory.getRandomEnum(