Merge lp:~lamont/maas/bug-1636251 into lp:maas

Proposed by LaMont Jones
Status: Merged
Approved by: LaMont Jones
Approved revision: 5504
Merged at revision: 5512
Proposed branch: lp:~lamont/maas/bug-1636251
Merge into: lp:maas
Diff against target: 67 lines (+22/-4)
2 files modified
src/maasserver/preseed_network.py (+5/-1)
src/maasserver/tests/test_preseed_network.py (+17/-3)
To merge this branch: bzr merge lp:~lamont/maas/bug-1636251
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+309184@code.launchpad.net

Commit message

Place the domain that the host is in at the front of the search list, so that the FQDN is correctly generated.

Description of the change

Place the domain that the host is in at the front of the search list, so that the FQDN is correctly generated.

To post a comment you must log in.
lp:~lamont/maas/bug-1636251 updated
5504. By LaMont Jones

Make sure we test that the domain of the node is set correctly.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

LGTM!

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_network.py'
2--- src/maasserver/preseed_network.py 2016-08-25 14:19:40 +0000
3+++ src/maasserver/preseed_network.py 2016-10-24 23:23:34 +0000
4@@ -62,10 +62,14 @@
5 self.addr_family_present[4] = True
6 default_dns_servers = self.node.get_default_dns_servers(
7 ipv4=self.addr_family_present[4], ipv6=self.addr_family_present[6])
8+ search_list = [self.node.domain.name] + [
9+ name
10+ for name in sorted(get_dns_search_paths())
11+ if name != self.node.domain.name]
12 self.network_config.append({
13 "type": "nameserver",
14 "address": default_dns_servers,
15- "search": sorted(get_dns_search_paths()),
16+ "search": search_list,
17 })
18
19 network_config = {
20
21=== modified file 'src/maasserver/tests/test_preseed_network.py'
22--- src/maasserver/tests/test_preseed_network.py 2016-08-24 21:04:59 +0000
23+++ src/maasserver/tests/test_preseed_network.py 2016-10-24 23:23:34 +0000
24@@ -244,7 +244,11 @@
25 def collectDNSConfig(self, node, ipv4=True, ipv6=True):
26 config = "- type: nameserver\n address: %s\n search:\n" % (
27 repr(node.get_default_dns_servers(ipv4=ipv4, ipv6=ipv6)))
28- dns_searches = sorted(get_dns_search_paths())
29+ domain_name = node.domain.name
30+ dns_searches = [domain_name] + [
31+ name
32+ for name in sorted(get_dns_search_paths())
33+ if name != domain_name]
34 for dns_name in dns_searches:
35 config += " - %s\n" % dns_name
36 return config
37@@ -258,9 +262,14 @@
38 )
39
40 def test_renders_expected_output(self):
41+ # Force it to have a domain name in the middle of two others. This
42+ # will confirm that sorting is working correctly.
43+ factory.make_Domain('aaa')
44+ domain = factory.make_Domain('bbb')
45+ factory.make_Domain('ccc')
46 subnet = factory.make_Subnet(version=self.version)
47 node = factory.make_Node_with_Interface_on_Subnet(
48- interface_count=2, subnet=subnet)
49+ interface_count=2, subnet=subnet, domain=domain)
50 for iface in node.interface_set.filter(enabled=True):
51 factory.make_StaticIPAddress(
52 interface=iface,
53@@ -288,8 +297,13 @@
54 class TestSimpleNetworkLayout(MAASServerTestCase, AssertNetworkConfigMixin):
55
56 def test__renders_expected_output(self):
57+ # Force it to have a domain name in the middle of two others. This
58+ # will confirm that sorting is working correctly.
59+ factory.make_Domain('aaa')
60+ domain = factory.make_Domain('bbb')
61+ factory.make_Domain('ccc')
62 node = factory.make_Node_with_Interface_on_Subnet(
63- interface_count=2)
64+ interface_count=2, domain=domain)
65 for iface in node.interface_set.filter(enabled=True):
66 factory.make_StaticIPAddress(
67 interface=iface,