Merge ~ltrager/maas:lp1800524 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: ea1adc29eaa89d985fd7cb5ff0417e08128df83d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1800524
Merge into: maas:master
Diff against target: 166 lines (+33/-12)
5 files modified
src/maasserver/forms/settings.py (+5/-5)
src/maasserver/preseed.py (+14/-2)
src/maasserver/static/partials/intro.html (+1/-1)
src/maasserver/static/partials/proxy-settings.html (+1/-1)
src/maasserver/tests/test_preseed.py (+12/-3)
Reviewer Review Type Date Requested Status
Newell Jensen (community) Approve
MAAS Lander Needs Fixing
Andres Rodriguez (community) Needs Fixing
Review via email: mp+358213@code.launchpad.net

Commit message

LP: #1800524 - Configure yum to use the MAAS proxy when set on CentOS/RHEL.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1800524 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4374/console
COMMIT: 1f06f546cbdae3c9244ef1ba045bba8a9b3e15bc

review: Needs Fixing
Revision history for this message
Andres Rodriguez (andreserl) wrote :

See inline.

review: Needs Fixing
Revision history for this message
Lee Trager (ltrager) wrote :

Responded inline

Revision history for this message
Lee Trager (ltrager) wrote :

After discussing this with the team we agreed to put the late_command to configure yum to use a proxy during preseed generation. Users who wish to use a different proxy for yum or not set one at all will have to use their own late_command.

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1800524 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4380/console
COMMIT: 1dbd3faef37670f931a66ec9be4859cb6e972a65

review: Needs Fixing
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :
~ltrager/maas:lp1800524 updated
b71e4fd... by Lee Trager

Merge branch 'master' into lp1800524

ea1adc2... by Lee Trager

Fix lint

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/forms/settings.py b/src/maasserver/forms/settings.py
2index 0b91e06..d318759 100644
3--- a/src/maasserver/forms/settings.py
4+++ b/src/maasserver/forms/settings.py
5@@ -282,12 +282,12 @@ CONFIG_ITEMS = {
6 'default': True,
7 'form': forms.BooleanField,
8 'form_kwargs': {
9- 'label': "Enable the use of an APT and HTTP/HTTPS proxy",
10+ 'label': "Enable the use of an APT or YUM and HTTP/HTTPS proxy",
11 'required': False,
12 'help_text': (
13 "Provision nodes to use the built-in HTTP proxy (or "
14- "user specified proxy) for APT. MAAS also uses the proxy for "
15- "downloading boot images.")
16+ "user specified proxy) for APT or YUM. MAAS also uses the "
17+ "proxy for downloading boot images.")
18 }
19 },
20 'maas_proxy_port': {
21@@ -329,11 +329,11 @@ CONFIG_ITEMS = {
22 'default': None,
23 'form': forms.URLField,
24 'form_kwargs': {
25- 'label': "Proxy for APT and HTTP/HTTPS",
26+ 'label': "Proxy for APT or YUM and HTTP/HTTPS",
27 'required': False,
28 'help_text': (
29 "This will be passed onto provisioned nodes to use as a "
30- "proxy for APT traffic. MAAS also uses the proxy for "
31+ "proxy for APT or YUM traffic. MAAS also uses the proxy for "
32 "downloading boot images. If no URL is provided, the built-in "
33 "MAAS proxy will be used.")
34 }
35diff --git a/src/maasserver/preseed.py b/src/maasserver/preseed.py
36index fd6b829..142be73 100644
37--- a/src/maasserver/preseed.py
38+++ b/src/maasserver/preseed.py
39@@ -36,6 +36,7 @@ from maasserver.compose_preseed import (
40 compose_debconf_cloud_init_preseed,
41 compose_enlistment_preseed,
42 compose_preseed,
43+ get_apt_proxy,
44 get_archive_config,
45 get_cloud_init_reporting,
46 RSYSLOG_PORT,
47@@ -456,7 +457,7 @@ def get_curtin_config(request, node):
48 deprecated_context_variables = [
49 'main_archive_hostname', 'main_archive_directory',
50 'ports_archive_hostname', 'ports_archive_directory',
51- 'enable_http_proxy', 'http_proxy']
52+ 'enable_http_proxy']
53 deprecated_config_variables = []
54 for var in deprecated_context_variables:
55 if var not in context:
56@@ -497,6 +498,16 @@ def get_curtin_config(request, node):
57 if 's390x' in node.architecture:
58 command = {'maas_00': 'chreipl node /dev/' + node.get_boot_disk().name}
59 config['late_commands'].update(command)
60+ if node.osystem in ['centos', 'rhel'] and context['http_proxy']:
61+ # The echo command must be one argument so direction works.
62+ config['late_commands'].update({
63+ 'yum_proxy': [
64+ 'curtin', 'in-target', '--', 'bash', '-c',
65+ 'echo -e "\\n# Proxy configured by MAAS\\n'
66+ 'proxy=%s\\n" >> /etc/yum.conf' % context['http_proxy'],
67+ ]
68+ })
69+
70 return yaml.safe_dump(config)
71
72
73@@ -755,6 +766,7 @@ def get_preseed_context(
74 metadata_enlist_url = request.build_absolute_uri(reverse('enlist'))
75 configs = Config.objects.get_configs(['remote_syslog', 'maas_syslog_port'])
76 syslog = configs['remote_syslog']
77+ http_proxy = get_apt_proxy(request, rack_controller)
78 if not syslog:
79 syslog_port = configs['maas_syslog_port']
80 if not syslog_port:
81@@ -767,6 +779,7 @@ def get_preseed_context(
82 'server_url': server_url,
83 'syslog_host_port': syslog,
84 'metadata_enlist_url': metadata_enlist_url,
85+ 'http_proxy': http_proxy,
86 }
87
88
89@@ -819,7 +832,6 @@ def get_node_deprecated_preseed_context():
90 'ports_archive_hostname': ports_archive_hostname,
91 'ports_archive_directory': ports_archive_directory,
92 'enable_http_proxy': Config.objects.get_config('enable_http_proxy'),
93- 'http_proxy': Config.objects.get_config('http_proxy'),
94 }
95
96
97diff --git a/src/maasserver/static/partials/intro.html b/src/maasserver/static/partials/intro.html
98index aecd112..7c1c201 100644
99--- a/src/maasserver/static/partials/intro.html
100+++ b/src/maasserver/static/partials/intro.html
101@@ -49,7 +49,7 @@
102 <li>
103 <maas-obj-form obj="httpProxy" manager="configManager" class="p-form p-form--stacked">
104 <div class="p-form__group">
105- <maas-obj-field type="text" key="value" label="APT &amp; HTTP/HTTPS proxy server" subtle="false" blur-on-enter="true" help-text="This will be passed onto deployed machines to use as a proxy for APT traffic. MAAS also uses the proxy for downloading boot images. If no URL is provided, the build-in MAAS proxy will be used."></maas-obj-field>
106+ <maas-obj-field type="text" key="value" label="APT &amp; HTTP/HTTPS proxy server" subtle="false" blur-on-enter="true" help-text="This will be passed onto deployed machines to use as a proxy for APT and YUM traffic. MAAS also uses the proxy for downloading boot images. If no URL is provided, the build-in MAAS proxy will be used."></maas-obj-field>
107 </div>
108 </maas-obj-form>
109 </li>
110diff --git a/src/maasserver/static/partials/proxy-settings.html b/src/maasserver/static/partials/proxy-settings.html
111index 20bbab9..070c293 100644
112--- a/src/maasserver/static/partials/proxy-settings.html
113+++ b/src/maasserver/static/partials/proxy-settings.html
114@@ -1,5 +1,5 @@
115 <li class="help-msg">
116- <label>HTTP proxy used by MAAS to download images, and by provisioned machines for APT packages.</label>
117+ <label>HTTP proxy used by MAAS to download images, and by provisioned machines for APT and YUM packages.</label>
118 </li>
119 <li>
120 <input type="radio" ng-model="proxy_type" name="maas_proxy"
121diff --git a/src/maasserver/tests/test_preseed.py b/src/maasserver/tests/test_preseed.py
122index fe8c571..cb4c2ae 100644
123--- a/src/maasserver/tests/test_preseed.py
124+++ b/src/maasserver/tests/test_preseed.py
125@@ -461,7 +461,7 @@ class TestPreseedContext(MAASServerTestCase):
126 context = get_preseed_context(make_HttpRequest())
127 self.assertItemsEqual(
128 ['osystem', 'release', 'metadata_enlist_url', 'server_host',
129- 'server_url', 'syslog_host_port'],
130+ 'server_url', 'syslog_host_port', 'http_proxy'],
131 context.keys())
132
133 def test_get_preseed_context_includes_remote_syslog(self):
134@@ -490,7 +490,7 @@ class TestNodeDeprecatedPreseedContext(
135 self.assertItemsEqual(
136 ['main_archive_hostname', 'main_archive_directory',
137 'ports_archive_hostname', 'ports_archive_directory',
138- 'enable_http_proxy', 'http_proxy'
139+ 'enable_http_proxy',
140 ],
141 context.keys())
142
143@@ -1067,7 +1067,8 @@ class TestCurtinUtilities(
144 node = factory.make_Node_with_Interface_on_Subnet(
145 primary_rack=self.rpc_rack_controller)
146 self.configure_get_boot_images_for_node(node, 'xinstall')
147- config = get_curtin_config(make_HttpRequest(), node)
148+ request = make_HttpRequest()
149+ config = get_curtin_config(request, node)
150 self.assertThat(
151 config,
152 Contains("debconf_selections:"))
153@@ -1157,6 +1158,14 @@ class TestCurtinUtilities(
154 Contains(
155 'maas_00: chreipl node /dev/' + node.get_boot_disk().name))
156
157+ def test_get_curtin_config_has_yum_proxy_late_command(self):
158+ node = factory.make_Node_with_Interface_on_Subnet(
159+ primary_rack=self.rpc_rack_controller,
160+ osystem=random.choice(['centos', 'rhel']))
161+ self.configure_get_boot_images_for_node(node, 'xinstall')
162+ config = get_curtin_config(make_HttpRequest(), node)
163+ self.assertThat(config, Contains('proxy='))
164+
165 def make_fastpath_node(self, main_arch=None):
166 """Return a `Node`, with FPI enabled, and the given main architecture.
167

Subscribers

People subscribed via source and target branches