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
diff --git a/src/maasserver/forms/settings.py b/src/maasserver/forms/settings.py
index 0b91e06..d318759 100644
--- a/src/maasserver/forms/settings.py
+++ b/src/maasserver/forms/settings.py
@@ -282,12 +282,12 @@ CONFIG_ITEMS = {
282 'default': True,282 'default': True,
283 'form': forms.BooleanField,283 'form': forms.BooleanField,
284 'form_kwargs': {284 'form_kwargs': {
285 'label': "Enable the use of an APT and HTTP/HTTPS proxy",285 'label': "Enable the use of an APT or YUM and HTTP/HTTPS proxy",
286 'required': False,286 'required': False,
287 'help_text': (287 'help_text': (
288 "Provision nodes to use the built-in HTTP proxy (or "288 "Provision nodes to use the built-in HTTP proxy (or "
289 "user specified proxy) for APT. MAAS also uses the proxy for "289 "user specified proxy) for APT or YUM. MAAS also uses the "
290 "downloading boot images.")290 "proxy for downloading boot images.")
291 }291 }
292 },292 },
293 'maas_proxy_port': {293 'maas_proxy_port': {
@@ -329,11 +329,11 @@ CONFIG_ITEMS = {
329 'default': None,329 'default': None,
330 'form': forms.URLField,330 'form': forms.URLField,
331 'form_kwargs': {331 'form_kwargs': {
332 'label': "Proxy for APT and HTTP/HTTPS",332 'label': "Proxy for APT or YUM and HTTP/HTTPS",
333 'required': False,333 'required': False,
334 'help_text': (334 'help_text': (
335 "This will be passed onto provisioned nodes to use as a "335 "This will be passed onto provisioned nodes to use as a "
336 "proxy for APT traffic. MAAS also uses the proxy for "336 "proxy for APT or YUM traffic. MAAS also uses the proxy for "
337 "downloading boot images. If no URL is provided, the built-in "337 "downloading boot images. If no URL is provided, the built-in "
338 "MAAS proxy will be used.")338 "MAAS proxy will be used.")
339 }339 }
diff --git a/src/maasserver/preseed.py b/src/maasserver/preseed.py
index fd6b829..142be73 100644
--- a/src/maasserver/preseed.py
+++ b/src/maasserver/preseed.py
@@ -36,6 +36,7 @@ from maasserver.compose_preseed import (
36 compose_debconf_cloud_init_preseed,36 compose_debconf_cloud_init_preseed,
37 compose_enlistment_preseed,37 compose_enlistment_preseed,
38 compose_preseed,38 compose_preseed,
39 get_apt_proxy,
39 get_archive_config,40 get_archive_config,
40 get_cloud_init_reporting,41 get_cloud_init_reporting,
41 RSYSLOG_PORT,42 RSYSLOG_PORT,
@@ -456,7 +457,7 @@ def get_curtin_config(request, node):
456 deprecated_context_variables = [457 deprecated_context_variables = [
457 'main_archive_hostname', 'main_archive_directory',458 'main_archive_hostname', 'main_archive_directory',
458 'ports_archive_hostname', 'ports_archive_directory',459 'ports_archive_hostname', 'ports_archive_directory',
459 'enable_http_proxy', 'http_proxy']460 'enable_http_proxy']
460 deprecated_config_variables = []461 deprecated_config_variables = []
461 for var in deprecated_context_variables:462 for var in deprecated_context_variables:
462 if var not in context:463 if var not in context:
@@ -497,6 +498,16 @@ def get_curtin_config(request, node):
497 if 's390x' in node.architecture:498 if 's390x' in node.architecture:
498 command = {'maas_00': 'chreipl node /dev/' + node.get_boot_disk().name}499 command = {'maas_00': 'chreipl node /dev/' + node.get_boot_disk().name}
499 config['late_commands'].update(command)500 config['late_commands'].update(command)
501 if node.osystem in ['centos', 'rhel'] and context['http_proxy']:
502 # The echo command must be one argument so direction works.
503 config['late_commands'].update({
504 'yum_proxy': [
505 'curtin', 'in-target', '--', 'bash', '-c',
506 'echo -e "\\n# Proxy configured by MAAS\\n'
507 'proxy=%s\\n" >> /etc/yum.conf' % context['http_proxy'],
508 ]
509 })
510
500 return yaml.safe_dump(config)511 return yaml.safe_dump(config)
501512
502513
@@ -755,6 +766,7 @@ def get_preseed_context(
755 metadata_enlist_url = request.build_absolute_uri(reverse('enlist'))766 metadata_enlist_url = request.build_absolute_uri(reverse('enlist'))
756 configs = Config.objects.get_configs(['remote_syslog', 'maas_syslog_port'])767 configs = Config.objects.get_configs(['remote_syslog', 'maas_syslog_port'])
757 syslog = configs['remote_syslog']768 syslog = configs['remote_syslog']
769 http_proxy = get_apt_proxy(request, rack_controller)
758 if not syslog:770 if not syslog:
759 syslog_port = configs['maas_syslog_port']771 syslog_port = configs['maas_syslog_port']
760 if not syslog_port:772 if not syslog_port:
@@ -767,6 +779,7 @@ def get_preseed_context(
767 'server_url': server_url,779 'server_url': server_url,
768 'syslog_host_port': syslog,780 'syslog_host_port': syslog,
769 'metadata_enlist_url': metadata_enlist_url,781 'metadata_enlist_url': metadata_enlist_url,
782 'http_proxy': http_proxy,
770 }783 }
771784
772785
@@ -819,7 +832,6 @@ def get_node_deprecated_preseed_context():
819 'ports_archive_hostname': ports_archive_hostname,832 'ports_archive_hostname': ports_archive_hostname,
820 'ports_archive_directory': ports_archive_directory,833 'ports_archive_directory': ports_archive_directory,
821 'enable_http_proxy': Config.objects.get_config('enable_http_proxy'),834 'enable_http_proxy': Config.objects.get_config('enable_http_proxy'),
822 'http_proxy': Config.objects.get_config('http_proxy'),
823 }835 }
824836
825837
diff --git a/src/maasserver/static/partials/intro.html b/src/maasserver/static/partials/intro.html
index aecd112..7c1c201 100644
--- a/src/maasserver/static/partials/intro.html
+++ b/src/maasserver/static/partials/intro.html
@@ -49,7 +49,7 @@
49 <li>49 <li>
50 <maas-obj-form obj="httpProxy" manager="configManager" class="p-form p-form--stacked">50 <maas-obj-form obj="httpProxy" manager="configManager" class="p-form p-form--stacked">
51 <div class="p-form__group">51 <div class="p-form__group">
52 <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>52 <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>
53 </div>53 </div>
54 </maas-obj-form>54 </maas-obj-form>
55 </li>55 </li>
diff --git a/src/maasserver/static/partials/proxy-settings.html b/src/maasserver/static/partials/proxy-settings.html
index 20bbab9..070c293 100644
--- a/src/maasserver/static/partials/proxy-settings.html
+++ b/src/maasserver/static/partials/proxy-settings.html
@@ -1,5 +1,5 @@
1<li class="help-msg">1<li class="help-msg">
2 <label>HTTP proxy used by MAAS to download images, and by provisioned machines for APT packages.</label>2 <label>HTTP proxy used by MAAS to download images, and by provisioned machines for APT and YUM packages.</label>
3</li>3</li>
4<li>4<li>
5 <input type="radio" ng-model="proxy_type" name="maas_proxy"5 <input type="radio" ng-model="proxy_type" name="maas_proxy"
diff --git a/src/maasserver/tests/test_preseed.py b/src/maasserver/tests/test_preseed.py
index fe8c571..cb4c2ae 100644
--- a/src/maasserver/tests/test_preseed.py
+++ b/src/maasserver/tests/test_preseed.py
@@ -461,7 +461,7 @@ class TestPreseedContext(MAASServerTestCase):
461 context = get_preseed_context(make_HttpRequest())461 context = get_preseed_context(make_HttpRequest())
462 self.assertItemsEqual(462 self.assertItemsEqual(
463 ['osystem', 'release', 'metadata_enlist_url', 'server_host',463 ['osystem', 'release', 'metadata_enlist_url', 'server_host',
464 'server_url', 'syslog_host_port'],464 'server_url', 'syslog_host_port', 'http_proxy'],
465 context.keys())465 context.keys())
466466
467 def test_get_preseed_context_includes_remote_syslog(self):467 def test_get_preseed_context_includes_remote_syslog(self):
@@ -490,7 +490,7 @@ class TestNodeDeprecatedPreseedContext(
490 self.assertItemsEqual(490 self.assertItemsEqual(
491 ['main_archive_hostname', 'main_archive_directory',491 ['main_archive_hostname', 'main_archive_directory',
492 'ports_archive_hostname', 'ports_archive_directory',492 'ports_archive_hostname', 'ports_archive_directory',
493 'enable_http_proxy', 'http_proxy'493 'enable_http_proxy',
494 ],494 ],
495 context.keys())495 context.keys())
496496
@@ -1067,7 +1067,8 @@ class TestCurtinUtilities(
1067 node = factory.make_Node_with_Interface_on_Subnet(1067 node = factory.make_Node_with_Interface_on_Subnet(
1068 primary_rack=self.rpc_rack_controller)1068 primary_rack=self.rpc_rack_controller)
1069 self.configure_get_boot_images_for_node(node, 'xinstall')1069 self.configure_get_boot_images_for_node(node, 'xinstall')
1070 config = get_curtin_config(make_HttpRequest(), node)1070 request = make_HttpRequest()
1071 config = get_curtin_config(request, node)
1071 self.assertThat(1072 self.assertThat(
1072 config,1073 config,
1073 Contains("debconf_selections:"))1074 Contains("debconf_selections:"))
@@ -1157,6 +1158,14 @@ class TestCurtinUtilities(
1157 Contains(1158 Contains(
1158 'maas_00: chreipl node /dev/' + node.get_boot_disk().name))1159 'maas_00: chreipl node /dev/' + node.get_boot_disk().name))
11591160
1161 def test_get_curtin_config_has_yum_proxy_late_command(self):
1162 node = factory.make_Node_with_Interface_on_Subnet(
1163 primary_rack=self.rpc_rack_controller,
1164 osystem=random.choice(['centos', 'rhel']))
1165 self.configure_get_boot_images_for_node(node, 'xinstall')
1166 config = get_curtin_config(make_HttpRequest(), node)
1167 self.assertThat(config, Contains('proxy='))
1168
1160 def make_fastpath_node(self, main_arch=None):1169 def make_fastpath_node(self, main_arch=None):
1161 """Return a `Node`, with FPI enabled, and the given main architecture.1170 """Return a `Node`, with FPI enabled, and the given main architecture.
11621171

Subscribers

People subscribed via source and target branches