Merge lp:~mpontillo/maas/bug-1506247 into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 4378
Proposed branch: lp:~mpontillo/maas/bug-1506247
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 69 lines (+24/-2)
3 files modified
.idea/maas.iml (+1/-0)
src/maasserver/preseed_network.py (+2/-2)
src/maasserver/tests/test_preseed_network.py (+21/-0)
To merge this branch: bzr merge lp:~mpontillo/maas/bug-1506247
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+274495@code.launchpad.net

Commit message

Fix curtin networking preseed generator to render DHCP configurations appropriately.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.idea/maas.iml'
2--- .idea/maas.iml 2015-05-16 06:21:20 +0000
3+++ .idea/maas.iml 2015-10-15 01:34:27 +0000
4@@ -4,6 +4,7 @@
5 <content url="file://$MODULE_DIR$">
6 <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7 <excludeFolder url="file://$MODULE_DIR$/.bzr" />
8+ <excludeFolder url="file://$MODULE_DIR$/bin" />
9 <excludeFolder url="file://$MODULE_DIR$/coverage" />
10 <excludeFolder url="file://$MODULE_DIR$/local" />
11 <excludeFolder url="file://$MODULE_DIR$/logs" />
12
13=== modified file 'src/maasserver/preseed_network.py'
14--- src/maasserver/preseed_network.py 2015-09-30 07:29:27 +0000
15+++ src/maasserver/preseed_network.py 2015-10-15 01:34:27 +0000
16@@ -224,7 +224,8 @@
17 IPADDRESS_TYPE.DISCOVERED,
18 IPADDRESS_TYPE.DHCP,
19 ]).order_by('id'))
20- if self._is_link_up(addresses):
21+ dhcp_type = self._get_dhcp_type(iface)
22+ if self._is_link_up(addresses) and not dhcp_type:
23 addrs.append({"type": "manual"})
24 else:
25 for address in addresses:
26@@ -240,7 +241,6 @@
27 subnet_operation["dns_nameservers"] = (
28 subnet.dns_servers)
29 addrs.append(subnet_operation)
30- dhcp_type = self._get_dhcp_type(iface)
31 if dhcp_type:
32 addrs.append(
33 {"type": dhcp_type}
34
35=== modified file 'src/maasserver/tests/test_preseed_network.py'
36--- src/maasserver/tests/test_preseed_network.py 2015-09-30 07:29:27 +0000
37+++ src/maasserver/tests/test_preseed_network.py 2015-10-15 01:34:27 +0000
38@@ -29,6 +29,7 @@
39 from maasserver.preseed_network import compose_curtin_network_config
40 from maasserver.testing.factory import factory
41 from maasserver.testing.testcase import MAASServerTestCase
42+from netaddr import IPNetwork
43 from testtools.matchers import (
44 ContainsDict,
45 Equals,
46@@ -311,3 +312,23 @@
47 net_config += self.collectDNSConfig(node)
48 config = compose_curtin_network_config(node)
49 self.assertNetworkConfig(net_config, config)
50+
51+
52+class TestDHCPNetworkLayout(MAASServerTestCase,
53+ AssertNetworkConfigMixin):
54+
55+ def test__dhcp_configurations_rendered(self):
56+ node = factory.make_Node_with_Interface_on_Subnet()
57+ iface = node.interface_set.first()
58+ subnet = iface.vlan.subnet_set.first()
59+ factory.make_StaticIPAddress(
60+ ip=None,
61+ alloc_type=IPADDRESS_TYPE.DHCP,
62+ interface=iface,
63+ subnet=subnet)
64+ config = compose_curtin_network_config(node)
65+ config_yaml = yaml.load(config[0])
66+ self.assertThat(
67+ config_yaml['network']['config'][0]['subnets'][0]['type'],
68+ Equals('dhcp' + unicode(IPNetwork(subnet.cidr).version))
69+ )