Merge lp:~mpontillo/maas/gateway-with-auto-ip--bug-1671891 into lp:maas/2.1

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 5592
Proposed branch: lp:~mpontillo/maas/gateway-with-auto-ip--bug-1671891
Merge into: lp:maas/2.1
Diff against target: 78 lines (+39/-5)
3 files modified
docs/changelog.rst (+2/-0)
src/maasserver/models/interface.py (+7/-5)
src/maasserver/models/tests/test_interface.py (+30/-0)
To merge this branch: bzr merge lp:~mpontillo/maas/gateway-with-auto-ip--bug-1671891
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+320267@code.launchpad.net

Commit message

Fix deployment with AUTO IPs set as the gateway link. (Merge revision 5820 from trunk.)

 * Previously the gateway link would be thrown away and replaced.
   Now the existing link will be updated with the allocated
   IP address.

Description of the change

-

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Self-approve backport, just in case we need to release 2.1.x again.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/changelog.rst'
--- docs/changelog.rst 2017-03-01 15:54:17 +0000
+++ docs/changelog.rst 2017-03-17 23:26:59 +0000
@@ -36,6 +36,8 @@
3636
37LP: #1665143 Select the shortest by-id path when discovering block devices to address issues when discovering nvme devices.37LP: #1665143 Select the shortest by-id path when discovering block devices to address issues when discovering nvme devices.
3838
39LP: #1671891 Fix deployment with AUTO IPs set as the gateway link.
40
3941
40Other notable changes42Other notable changes
41---------------------43---------------------
4244
=== modified file 'src/maasserver/models/interface.py'
--- src/maasserver/models/interface.py 2016-12-07 12:59:10 +0000
+++ src/maasserver/models/interface.py 2017-03-17 23:26:59 +0000
@@ -1055,13 +1055,15 @@
1055 new_ip = StaticIPAddress.objects.allocate_new(1055 new_ip = StaticIPAddress.objects.allocate_new(
1056 subnet=subnet, alloc_type=IPADDRESS_TYPE.AUTO,1056 subnet=subnet, alloc_type=IPADDRESS_TYPE.AUTO,
1057 exclude_addresses=exclude_addresses)1057 exclude_addresses=exclude_addresses)
1058 self.ip_addresses.add(new_ip)1058 auto_ip.ip = new_ip.ip
1059 # Throw away the newly-allocated address and assign it to the old AUTO
1060 # address, so that the interface link IDs remain consistent.
1061 new_ip.delete()
1062 auto_ip.save()
1059 maaslog.info("Allocated automatic IP address %s for %s." % (1063 maaslog.info("Allocated automatic IP address %s for %s." % (
1060 new_ip.ip,1064 auto_ip.ip,
1061 self.get_log_string()))1065 self.get_log_string()))
10621066 return auto_ip
1063 auto_ip.delete()
1064 return new_ip
10651067
1066 def release_auto_ips(self):1068 def release_auto_ips(self):
1067 """Release all AUTO IP address for this interface that have an IP1069 """Release all AUTO IP address for this interface that have an IP
10681070
=== modified file 'src/maasserver/models/tests/test_interface.py'
--- src/maasserver/models/tests/test_interface.py 2016-12-07 12:59:10 +0000
+++ src/maasserver/models/tests/test_interface.py 2017-03-17 23:26:59 +0000
@@ -2661,6 +2661,36 @@
2661 "Should have 3 AUTO IP addresses with an IP address assigned.")2661 "Should have 3 AUTO IP addresses with an IP address assigned.")
2662 self.assertItemsEqual(assigned_addresses, observed)2662 self.assertItemsEqual(assigned_addresses, observed)
26632663
2664 def test__keeps_ip_address_ids_consistent(self):
2665 auto_ip_ids = []
2666 with transaction.atomic():
2667 interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
2668 for _ in range(3):
2669 subnet = factory.make_ipv4_Subnet_with_IPRanges(
2670 vlan=interface.vlan)
2671 auto_ip = factory.make_StaticIPAddress(
2672 alloc_type=IPADDRESS_TYPE.AUTO, ip="",
2673 subnet=subnet, interface=interface)
2674 auto_ip_ids.append(auto_ip.id)
2675 with transaction.atomic():
2676 observed = interface.claim_auto_ips()
2677 # Should now have 3 AUTO with IP addresses assigned.
2678 interface = reload_object(interface)
2679 assigned_addresses = interface.ip_addresses.filter(
2680 alloc_type=IPADDRESS_TYPE.AUTO)
2681 assigned_addresses = [
2682 ip
2683 for ip in assigned_addresses
2684 if ip.ip
2685 ]
2686 self.assertEqual(
2687 3, len(assigned_addresses),
2688 "Should have 3 AUTO IP addresses with an IP address assigned.")
2689 self.assertItemsEqual(assigned_addresses, observed)
2690 # Make sure the IDs didn't change upon allocation.
2691 self.assertItemsEqual(
2692 auto_ip_ids, (ip.id for ip in assigned_addresses))
2693
2664 def test__claims_all_missing_assigned_auto_ip_addresses(self):2694 def test__claims_all_missing_assigned_auto_ip_addresses(self):
2665 with transaction.atomic():2695 with transaction.atomic():
2666 interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)2696 interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)

Subscribers

People subscribed via source and target branches

to all changes: