Merge lp:~rvb/maas/bug-1364591 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2883
Proposed branch: lp:~rvb/maas/bug-1364591
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 73 lines (+17/-10)
2 files modified
src/maasserver/preseed.py (+9/-5)
src/maasserver/tests/test_preseed.py (+8/-5)
To merge this branch: bzr merge lp:~rvb/maas/bug-1364591
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+233175@code.launchpad.net

Commit message

When generating the preseed, use the port from the 'main_archive' setting if provided.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/preseed.py'
2--- src/maasserver/preseed.py 2014-08-13 21:49:35 +0000
3+++ src/maasserver/preseed.py 2014-09-03 08:19:34 +0000
4@@ -354,10 +354,14 @@
5 return get_template(prefix, None, default=True)
6
7
8-def get_hostname_and_path(url):
9- """Return a tuple of the hostname and the hierarchical path from a url."""
10+def get_netloc_and_path(url):
11+ """Return a tuple of the netloc and the hierarchical path from a url.
12+
13+ The netloc, the "Network location part", is composed of the hostname
14+ and, optionally, the port.
15+ """
16 parsed_url = urlparse(url)
17- return parsed_url.hostname, parsed_url.path
18+ return parsed_url.netloc, parsed_url.path
19
20
21 def pick_cluster_controller_address(node):
22@@ -408,9 +412,9 @@
23 :rtype: dict.
24 """
25 server_host = get_maas_facing_server_host(nodegroup=nodegroup)
26- main_archive_hostname, main_archive_directory = get_hostname_and_path(
27+ main_archive_hostname, main_archive_directory = get_netloc_and_path(
28 Config.objects.get_config('main_archive'))
29- ports_archive_hostname, ports_archive_directory = get_hostname_and_path(
30+ ports_archive_hostname, ports_archive_directory = get_netloc_and_path(
31 Config.objects.get_config('ports_archive'))
32 if nodegroup is None:
33 base_url = None
34
35=== modified file 'src/maasserver/tests/test_preseed.py'
36--- src/maasserver/tests/test_preseed.py 2014-08-19 11:05:33 +0000
37+++ src/maasserver/tests/test_preseed.py 2014-09-03 08:19:34 +0000
38@@ -38,7 +38,7 @@
39 get_curtin_installer_url,
40 get_curtin_userdata,
41 get_enlist_preseed,
42- get_hostname_and_path,
43+ get_netloc_and_path,
44 get_node_preseed_context,
45 get_preseed,
46 get_preseed_context,
47@@ -83,19 +83,22 @@
48 self.assertEqual(['amd64', 'test'], split_subarch('amd64/test'))
49
50
51-class TestGetHostnameAndPath(MAASServerTestCase):
52- """Tests for `get_hostname_and_path`."""
53+class TestGetNetlocAndPath(MAASServerTestCase):
54+ """Tests for `get_netloc_and_path`."""
55
56- def test_get_hostname_and_path(self):
57+ def test_get_netloc_and_path(self):
58 input_and_results = [
59+ ('http://name.domain:66/my/path', ('name.domain:66', '/my/path')),
60+ ('http://name.domain:80/my/path', ('name.domain:80', '/my/path')),
61 ('http://name.domain/my/path', ('name.domain', '/my/path')),
62 ('https://domain/path', ('domain', '/path')),
63+ ('http://domain:12', ('domain:12', '')),
64 ('http://domain/', ('domain', '/')),
65 ('http://domain', ('domain', '')),
66 ]
67 inputs = [input for input, _ in input_and_results]
68 results = [result for _, result in input_and_results]
69- self.assertEqual(results, map(get_hostname_and_path, inputs))
70+ self.assertEqual(results, map(get_netloc_and_path, inputs))
71
72
73 class TestGetPreseedFilenames(MAASServerTestCase):