Merge lp:~julian-edwards/maas/better-ip-exhaustion-error-bug-1388033 into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 3353
Proposed branch: lp:~julian-edwards/maas/better-ip-exhaustion-error-bug-1388033
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 32 lines (+7/-2)
2 files modified
src/maasserver/models/staticipaddress.py (+3/-1)
src/maasserver/models/tests/test_staticipaddress.py (+4/-1)
To merge this branch: bzr merge lp:~julian-edwards/maas/better-ip-exhaustion-error-bug-1388033
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+241035@code.launchpad.net

Commit message

Return an error message along with a SERVICE_UNAVAILABLE code when trying to allocate a static IP when they are all in use.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/staticipaddress.py'
2--- src/maasserver/models/staticipaddress.py 2014-11-05 03:41:22 +0000
3+++ src/maasserver/models/staticipaddress.py 2014-11-07 05:31:52 +0000
4@@ -195,7 +195,9 @@
5 # this critical section is in a lock...
6 continue
7 else:
8- raise StaticIPAddressExhaustion()
9+ raise StaticIPAddressExhaustion(
10+ "No more IPs available in range %s-%s" % (
11+ range_low.format(), range_high.format()))
12
13 def _deallocate(self, filter):
14 """Helper func to deallocate the records in the supplied queryset
15
16=== modified file 'src/maasserver/models/tests/test_staticipaddress.py'
17--- src/maasserver/models/tests/test_staticipaddress.py 2014-11-05 03:55:10 +0000
18+++ src/maasserver/models/tests/test_staticipaddress.py 2014-11-07 05:31:52 +0000
19@@ -56,9 +56,12 @@
20 def test_allocate_new_raises_when_addresses_exhausted(self):
21 low = high = "192.168.230.1"
22 StaticIPAddress.objects.allocate_new(low, high)
23- self.assertRaises(
24+ e = self.assertRaises(
25 StaticIPAddressExhaustion,
26 StaticIPAddress.objects.allocate_new, low, high)
27+ self.assertEqual(
28+ "No more IPs available in range %s-%s" % (low, high),
29+ unicode(e))
30
31 def test_allocate_new_sets_user(self):
32 low, high = factory.make_ip_range()