Merge lp:~blake-rouse/maas/fix-1597324-2.0 into lp:maas/2.0

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5140
Proposed branch: lp:~blake-rouse/maas/fix-1597324-2.0
Merge into: lp:maas/2.0
Diff against target: 39 lines (+17/-1)
2 files modified
src/maasserver/forms_interface_link.py (+4/-1)
src/maasserver/tests/test_forms_interface_link.py (+13/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1597324-2.0
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+298797@code.launchpad.net

Commit message

Allow selection of a DHCP link for the default gateway of a node.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Self-approving backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/forms_interface_link.py'
2--- src/maasserver/forms_interface_link.py 2016-03-28 13:54:47 +0000
3+++ src/maasserver/forms_interface_link.py 2016-06-30 15:22:24 +0000
4@@ -228,7 +228,10 @@
5 """Return IP links on the instance that are of the correct type,
6 have a subnet, and has a gateway_ip set."""
7 links = self.instance.ip_addresses.filter(
8- alloc_type__in=[IPADDRESS_TYPE.AUTO, IPADDRESS_TYPE.STICKY],
9+ alloc_type__in=[
10+ IPADDRESS_TYPE.AUTO,
11+ IPADDRESS_TYPE.STICKY,
12+ IPADDRESS_TYPE.DHCP],
13 subnet__isnull=False, subnet__gateway_ip__isnull=False)
14 links = links.select_related("subnet")
15 return [
16
17=== modified file 'src/maasserver/tests/test_forms_interface_link.py'
18--- src/maasserver/tests/test_forms_interface_link.py 2016-03-28 13:54:47 +0000
19+++ src/maasserver/tests/test_forms_interface_link.py 2016-06-30 15:22:24 +0000
20@@ -563,6 +563,19 @@
21 ]
22 self.assertItemsEqual(link_ids, choice_ids)
23
24+ def test__sets_gateway_links_works_on_dhcp_with_gateway_ip(self):
25+ interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
26+ ipv4_link = self.make_ip_family_link(
27+ interface, factory.make_ipv4_network(), IPADDRESS_TYPE.DHCP)
28+ ipv6_link = self.make_ip_family_link(
29+ interface, factory.make_ipv6_network(), IPADDRESS_TYPE.DHCP)
30+ form = InterfaceSetDefaultGatwayForm(instance=interface, data={})
31+ self.assertTrue(form.is_valid(), form.errors)
32+ interface = form.save()
33+ node = interface.get_node()
34+ self.assertEqual(ipv4_link, node.gateway_link_ipv4)
35+ self.assertEqual(ipv6_link, node.gateway_link_ipv6)
36+
37 def test__sets_gateway_links_on_node_when_no_link_id(self):
38 interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
39 ipv4_link = self.make_ip_family_link(

Subscribers

People subscribed via source and target branches

to all changes: