Merge lp:~bjornt/maas/get-apt-proxy into lp:~maas-committers/maas/trunk
- get-apt-proxy
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Björn Tillenius |
Approved revision: | 6070 |
Merged at revision: | 6090 |
Proposed branch: | lp:~bjornt/maas/get-apt-proxy |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
120 lines (+15/-20) 3 files modified
src/maasserver/compose_preseed.py (+9/-9) src/maasserver/preseed.py (+2/-7) src/maasserver/tests/test_compose_preseed.py (+4/-4) |
To merge this branch: | bzr merge lp:~bjornt/maas/get-apt-proxy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike Pontillo (community) | Approve | ||
Review via email: mp+325756@code.launchpad.net |
Commit message
Description of the change
Factor out getting the APT proxy.
The same logic was duplicated in two places. I'm going to change the
logic later, so having it in one place makes it easier.
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~bjornt/maas/get-apt-proxy into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 0s (661 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-p...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~bjornt/maas/get-apt-proxy into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Hit:2 http://
Hit:3 http://
Hit:4 http://
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is already the newest version (2.6.1-1build2).
python-simplejson is already the newest version (3.8.1-1ubuntu2).
python-tem...
- 6070. By Björn Tillenius
-
Fix imports.
Preview Diff
1 | === modified file 'src/maasserver/compose_preseed.py' | |||
2 | --- src/maasserver/compose_preseed.py 2017-03-29 21:13:51 +0000 | |||
3 | +++ src/maasserver/compose_preseed.py 2017-06-16 09:11:46 +0000 | |||
4 | @@ -31,17 +31,17 @@ | |||
5 | 31 | RSYSLOG_PORT = 514 | 31 | RSYSLOG_PORT = 514 |
6 | 32 | 32 | ||
7 | 33 | 33 | ||
10 | 34 | def get_apt_proxy_for_node(node): | 34 | def get_apt_proxy(rack_controller=None): |
11 | 35 | """Return the APT proxy for the `node`.""" | 35 | """Return the APT proxy for the `rack_controller`.""" |
12 | 36 | if Config.objects.get_config("enable_http_proxy"): | 36 | if Config.objects.get_config("enable_http_proxy"): |
13 | 37 | http_proxy = Config.objects.get_config("http_proxy") | 37 | http_proxy = Config.objects.get_config("http_proxy") |
16 | 38 | if (http_proxy is not None and len(http_proxy) > 0 and | 38 | if http_proxy is not None: |
17 | 39 | not http_proxy.isspace()): | 39 | http_proxy = http_proxy.strip() |
18 | 40 | if http_proxy: | ||
19 | 40 | return http_proxy | 41 | return http_proxy |
20 | 41 | else: | 42 | else: |
21 | 42 | return compose_URL( | 43 | return compose_URL( |
24 | 43 | "http://:8000/", get_maas_facing_server_host( | 44 | "http://:8000/", get_maas_facing_server_host(rack_controller)) |
23 | 44 | node.get_boot_rack_controller())) | ||
25 | 45 | else: | 45 | else: |
26 | 46 | return None | 46 | return None |
27 | 47 | 47 | ||
28 | @@ -58,7 +58,7 @@ | |||
29 | 58 | arch = node.split_arch()[0] | 58 | arch = node.split_arch()[0] |
30 | 59 | archive = PackageRepository.objects.get_default_archive(arch) | 59 | archive = PackageRepository.objects.get_default_archive(arch) |
31 | 60 | repositories = PackageRepository.objects.get_additional_repositories(arch) | 60 | repositories = PackageRepository.objects.get_additional_repositories(arch) |
33 | 61 | apt_proxy = get_apt_proxy_for_node(node) | 61 | apt_proxy = get_apt_proxy(node.get_boot_rack_controller()) |
34 | 62 | 62 | ||
35 | 63 | # Process the default Ubuntu Archives or Mirror. | 63 | # Process the default Ubuntu Archives or Mirror. |
36 | 64 | archives = {} | 64 | archives = {} |
37 | @@ -225,7 +225,7 @@ | |||
38 | 225 | } | 225 | } |
39 | 226 | # Add the system configuration information. | 226 | # Add the system configuration information. |
40 | 227 | config.update(get_system_info()) | 227 | config.update(get_system_info()) |
42 | 228 | apt_proxy = get_apt_proxy_for_node(node) | 228 | apt_proxy = get_apt_proxy(node.get_boot_rack_controller()) |
43 | 229 | if apt_proxy: | 229 | if apt_proxy: |
44 | 230 | config['apt_proxy'] = apt_proxy | 230 | config['apt_proxy'] = apt_proxy |
45 | 231 | # Add APT configuration for new cloud-init (>= 0.7.7-17) | 231 | # Add APT configuration for new cloud-init (>= 0.7.7-17) |
46 | @@ -313,7 +313,7 @@ | |||
47 | 313 | } | 313 | } |
48 | 314 | # Add the system configuration information. | 314 | # Add the system configuration information. |
49 | 315 | cloud_config.update(get_system_info()) | 315 | cloud_config.update(get_system_info()) |
51 | 316 | apt_proxy = get_apt_proxy_for_node(node) | 316 | apt_proxy = get_apt_proxy(node.get_boot_rack_controller()) |
52 | 317 | if apt_proxy: | 317 | if apt_proxy: |
53 | 318 | cloud_config['apt_proxy'] = apt_proxy | 318 | cloud_config['apt_proxy'] = apt_proxy |
54 | 319 | # Add APT configuration for new cloud-init (>= 0.7.7-17) | 319 | # Add APT configuration for new cloud-init (>= 0.7.7-17) |
55 | 320 | 320 | ||
56 | === modified file 'src/maasserver/preseed.py' | |||
57 | --- src/maasserver/preseed.py 2017-06-13 10:54:20 +0000 | |||
58 | +++ src/maasserver/preseed.py 2017-06-16 09:11:46 +0000 | |||
59 | @@ -33,6 +33,7 @@ | |||
60 | 33 | from maasserver.compose_preseed import ( | 33 | from maasserver.compose_preseed import ( |
61 | 34 | compose_cloud_init_preseed, | 34 | compose_cloud_init_preseed, |
62 | 35 | compose_preseed, | 35 | compose_preseed, |
63 | 36 | get_apt_proxy, | ||
64 | 36 | get_archive_config, | 37 | get_archive_config, |
65 | 37 | get_system_info, | 38 | get_system_info, |
66 | 38 | RSYSLOG_PORT, | 39 | RSYSLOG_PORT, |
67 | @@ -111,13 +112,7 @@ | |||
68 | 111 | :return: The rendered enlistment user-data string. | 112 | :return: The rendered enlistment user-data string. |
69 | 112 | :rtype: unicode. | 113 | :rtype: unicode. |
70 | 113 | """ | 114 | """ |
78 | 114 | server_host = get_maas_facing_server_host(rack_controller=rack_controller) | 115 | http_proxy = get_apt_proxy(rack_controller=rack_controller) |
72 | 115 | http_proxy = None | ||
73 | 116 | if Config.objects.get_config('enable_http_proxy'): | ||
74 | 117 | if Config.objects.get_config('http_proxy'): | ||
75 | 118 | http_proxy = Config.objects.get_config('http_proxy') | ||
76 | 119 | elif server_host: | ||
77 | 120 | http_proxy = "http://%s:8000/" % server_host | ||
79 | 121 | enlist_userdata = render_enlistment_preseed( | 116 | enlist_userdata = render_enlistment_preseed( |
80 | 122 | USERDATA_TYPE.ENLIST, rack_controller=rack_controller) | 117 | USERDATA_TYPE.ENLIST, rack_controller=rack_controller) |
81 | 123 | config = get_system_info() | 118 | config = get_system_info() |
82 | 124 | 119 | ||
83 | === modified file 'src/maasserver/tests/test_compose_preseed.py' | |||
84 | --- src/maasserver/tests/test_compose_preseed.py 2017-03-29 22:00:38 +0000 | |||
85 | +++ src/maasserver/tests/test_compose_preseed.py 2017-06-16 09:11:46 +0000 | |||
86 | @@ -9,7 +9,7 @@ | |||
87 | 9 | 9 | ||
88 | 10 | from maasserver.compose_preseed import ( | 10 | from maasserver.compose_preseed import ( |
89 | 11 | compose_preseed, | 11 | compose_preseed, |
91 | 12 | get_apt_proxy_for_node, | 12 | get_apt_proxy, |
92 | 13 | ) | 13 | ) |
93 | 14 | from maasserver.enum import ( | 14 | from maasserver.enum import ( |
94 | 15 | NODE_STATUS, | 15 | NODE_STATUS, |
95 | @@ -89,7 +89,7 @@ | |||
96 | 89 | interface=True, status=NODE_STATUS.COMMISSIONING) | 89 | interface=True, status=NODE_STATUS.COMMISSIONING) |
97 | 90 | Config.objects.set_config("enable_http_proxy", self.enable) | 90 | Config.objects.set_config("enable_http_proxy", self.enable) |
98 | 91 | Config.objects.set_config("http_proxy", self.http_proxy) | 91 | Config.objects.set_config("http_proxy", self.http_proxy) |
100 | 92 | actual = get_apt_proxy_for_node(node) | 92 | actual = get_apt_proxy(node.get_boot_rack_controller()) |
101 | 93 | self.assertEqual(self.result, actual) | 93 | self.assertEqual(self.result, actual) |
102 | 94 | 94 | ||
103 | 95 | 95 | ||
104 | @@ -180,7 +180,7 @@ | |||
105 | 180 | nic.vlan.dhcp_on = True | 180 | nic.vlan.dhcp_on = True |
106 | 181 | nic.vlan.primary_rack = rack_controller | 181 | nic.vlan.primary_rack = rack_controller |
107 | 182 | nic.vlan.save() | 182 | nic.vlan.save() |
109 | 183 | apt_proxy = get_apt_proxy_for_node(node) | 183 | apt_proxy = get_apt_proxy(node.get_boot_rack_controller()) |
110 | 184 | preseed = yaml.safe_load( | 184 | preseed = yaml.safe_load( |
111 | 185 | compose_preseed(PRESEED_TYPE.COMMISSIONING, node)) | 185 | compose_preseed(PRESEED_TYPE.COMMISSIONING, node)) |
112 | 186 | self.assertIn('datasource', preseed) | 186 | self.assertIn('datasource', preseed) |
113 | @@ -365,7 +365,7 @@ | |||
114 | 365 | nic.vlan.primary_rack = rack_controller | 365 | nic.vlan.primary_rack = rack_controller |
115 | 366 | nic.vlan.save() | 366 | nic.vlan.save() |
116 | 367 | self.useFixture(RunningClusterRPCFixture()) | 367 | self.useFixture(RunningClusterRPCFixture()) |
118 | 368 | apt_proxy = get_apt_proxy_for_node(node) | 368 | apt_proxy = get_apt_proxy(node.get_boot_rack_controller()) |
119 | 369 | preseed = yaml.safe_load( | 369 | preseed = yaml.safe_load( |
120 | 370 | compose_preseed(PRESEED_TYPE.CURTIN, node)) | 370 | compose_preseed(PRESEED_TYPE.CURTIN, node)) |
121 | 371 | 371 |
Looks good to me!