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
=== modified file 'src/maasserver/preseed_network.py'
--- src/maasserver/preseed_network.py 2016-08-25 14:19:40 +0000
+++ src/maasserver/preseed_network.py 2016-10-24 23:23:34 +0000
@@ -62,10 +62,14 @@
62 self.addr_family_present[4] = True62 self.addr_family_present[4] = True
63 default_dns_servers = self.node.get_default_dns_servers(63 default_dns_servers = self.node.get_default_dns_servers(
64 ipv4=self.addr_family_present[4], ipv6=self.addr_family_present[6])64 ipv4=self.addr_family_present[4], ipv6=self.addr_family_present[6])
65 search_list = [self.node.domain.name] + [
66 name
67 for name in sorted(get_dns_search_paths())
68 if name != self.node.domain.name]
65 self.network_config.append({69 self.network_config.append({
66 "type": "nameserver",70 "type": "nameserver",
67 "address": default_dns_servers,71 "address": default_dns_servers,
68 "search": sorted(get_dns_search_paths()),72 "search": search_list,
69 })73 })
7074
71 network_config = {75 network_config = {
7276
=== modified file 'src/maasserver/tests/test_preseed_network.py'
--- src/maasserver/tests/test_preseed_network.py 2016-08-24 21:04:59 +0000
+++ src/maasserver/tests/test_preseed_network.py 2016-10-24 23:23:34 +0000
@@ -244,7 +244,11 @@
244 def collectDNSConfig(self, node, ipv4=True, ipv6=True):244 def collectDNSConfig(self, node, ipv4=True, ipv6=True):
245 config = "- type: nameserver\n address: %s\n search:\n" % (245 config = "- type: nameserver\n address: %s\n search:\n" % (
246 repr(node.get_default_dns_servers(ipv4=ipv4, ipv6=ipv6)))246 repr(node.get_default_dns_servers(ipv4=ipv4, ipv6=ipv6)))
247 dns_searches = sorted(get_dns_search_paths())247 domain_name = node.domain.name
248 dns_searches = [domain_name] + [
249 name
250 for name in sorted(get_dns_search_paths())
251 if name != domain_name]
248 for dns_name in dns_searches:252 for dns_name in dns_searches:
249 config += " - %s\n" % dns_name253 config += " - %s\n" % dns_name
250 return config254 return config
@@ -258,9 +262,14 @@
258 )262 )
259263
260 def test_renders_expected_output(self):264 def test_renders_expected_output(self):
265 # Force it to have a domain name in the middle of two others. This
266 # will confirm that sorting is working correctly.
267 factory.make_Domain('aaa')
268 domain = factory.make_Domain('bbb')
269 factory.make_Domain('ccc')
261 subnet = factory.make_Subnet(version=self.version)270 subnet = factory.make_Subnet(version=self.version)
262 node = factory.make_Node_with_Interface_on_Subnet(271 node = factory.make_Node_with_Interface_on_Subnet(
263 interface_count=2, subnet=subnet)272 interface_count=2, subnet=subnet, domain=domain)
264 for iface in node.interface_set.filter(enabled=True):273 for iface in node.interface_set.filter(enabled=True):
265 factory.make_StaticIPAddress(274 factory.make_StaticIPAddress(
266 interface=iface,275 interface=iface,
@@ -288,8 +297,13 @@
288class TestSimpleNetworkLayout(MAASServerTestCase, AssertNetworkConfigMixin):297class TestSimpleNetworkLayout(MAASServerTestCase, AssertNetworkConfigMixin):
289298
290 def test__renders_expected_output(self):299 def test__renders_expected_output(self):
300 # Force it to have a domain name in the middle of two others. This
301 # will confirm that sorting is working correctly.
302 factory.make_Domain('aaa')
303 domain = factory.make_Domain('bbb')
304 factory.make_Domain('ccc')
291 node = factory.make_Node_with_Interface_on_Subnet(305 node = factory.make_Node_with_Interface_on_Subnet(
292 interface_count=2)306 interface_count=2, domain=domain)
293 for iface in node.interface_set.filter(enabled=True):307 for iface in node.interface_set.filter(enabled=True):
294 factory.make_StaticIPAddress(308 factory.make_StaticIPAddress(
295 interface=iface,309 interface=iface,