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
1=== modified file 'src/maasserver/forms.py'
2--- src/maasserver/forms.py 2012-10-04 13:00:54 +0000
3+++ src/maasserver/forms.py 2012-10-23 09:58:21 +0000
4@@ -569,6 +569,12 @@
5 label="Default domain for new nodes", required=False, help_text=(
6 "If 'local' is chosen, nodes must be using mDNS. Leave empty to "
7 "use hostnames without a domain for newly enlisted nodes."))
8+ http_proxy = forms.URLField(
9+ label="Proxy for HTTP and HTTPS traffic", required=False,
10+ help_text=(
11+ "This is used by the cluster and region controllers for "
12+ "downloading PXE boot images and other provisioning-related "
13+ "resources. It is not passed into provisioned nodes."))
14
15
16 class CommissioningForm(ConfigForm):
17
18=== modified file 'src/maasserver/models/config.py'
19--- src/maasserver/models/config.py 2012-09-27 13:50:34 +0000
20+++ src/maasserver/models/config.py 2012-10-23 09:58:21 +0000
21@@ -53,6 +53,7 @@
22 'enlistment_domain': b'local',
23 'default_distro_series': DISTRO_SERIES.precise,
24 'commissioning_distro_series': DISTRO_SERIES.precise,
25+ 'http_proxy': None,
26 ## /settings
27 }
28
29
30=== modified file 'src/maasserver/tests/test_config.py'
31--- src/maasserver/tests/test_config.py 2012-05-11 07:51:59 +0000
32+++ src/maasserver/tests/test_config.py 2012-10-23 09:58:21 +0000
33@@ -16,10 +16,8 @@
34
35 from fixtures import TestWithFixtures
36 from maasserver.models import Config
37-from maasserver.models.config import (
38- DEFAULT_CONFIG,
39- get_default_config,
40- )
41+import maasserver.models.config
42+from maasserver.models.config import get_default_config
43 from maasserver.testing.factory import factory
44 from maasserver.testing.testcase import TestCase
45
46@@ -31,6 +29,14 @@
47 default_config = get_default_config()
48 self.assertEqual(gethostname(), default_config['maas_name'])
49
50+ def test_defaults(self):
51+ expected = get_default_config()
52+ observed = {
53+ name: Config.objects.get_config(name)
54+ for name in expected
55+ }
56+ self.assertEqual(expected, observed)
57+
58
59 class CallRecorder:
60 """A utility class which tracks the calls to its 'call' method and
61@@ -63,13 +69,15 @@
62 def test_manager_get_config_not_found_in_default_config(self):
63 name = factory.getRandomString()
64 value = factory.getRandomString()
65- DEFAULT_CONFIG[name] = value
66+ self.patch(maasserver.models.config, "DEFAULT_CONFIG", {name: value})
67 config = Config.objects.get_config(name, None)
68 self.assertEqual(value, config)
69
70 def test_default_config_cannot_be_changed(self):
71 name = factory.getRandomString()
72- DEFAULT_CONFIG[name] = {'key': 'value'}
73+ self.patch(
74+ maasserver.models.config, "DEFAULT_CONFIG",
75+ {name: {'key': 'value'}})
76 config = Config.objects.get_config(name)
77 config.update({'key2': 'value2'})
78
79
80=== modified file 'src/maasserver/tests/test_views_settings.py'
81--- src/maasserver/tests/test_views_settings.py 2012-10-03 15:48:11 +0000
82+++ src/maasserver/tests/test_views_settings.py 2012-10-23 09:58:21 +0000
83@@ -82,6 +82,7 @@
84 self.patch(settings, "DNS_CONNECT", False)
85 new_name = factory.getRandomString()
86 new_domain = factory.getRandomString()
87+ new_proxy = "http://%s.example.com:1234/" % factory.getRandomString()
88 response = self.client.post(
89 reverse('settings'),
90 get_prefixed_form_data(
91@@ -89,12 +90,16 @@
92 data={
93 'maas_name': new_name,
94 'enlistment_domain': new_domain,
95+ 'http_proxy': new_proxy,
96 }))
97-
98- self.assertEqual(httplib.FOUND, response.status_code)
99- self.assertEqual(new_name, Config.objects.get_config('maas_name'))
100+ self.assertEqual(httplib.FOUND, response.status_code, response.content)
101 self.assertEqual(
102- new_domain, Config.objects.get_config('enlistment_domain'))
103+ (new_name,
104+ new_domain,
105+ new_proxy),
106+ (Config.objects.get_config('maas_name'),
107+ Config.objects.get_config('enlistment_domain'),
108+ Config.objects.get_config('http_proxy')))
109
110 def test_settings_commissioning_POST(self):
111 new_after_commissioning = factory.getRandomEnum(