Merge lp:~jtv/maas/1.2-bug-1077075 into lp:maas/1.2

Proposed by Jeroen T. Vermeulen on 2012-11-09
Status: Merged
Approved by: Jeroen T. Vermeulen on 2012-11-09
Approved revision: 1297
Merged at revision: 1296
Proposed branch: lp:~jtv/maas/1.2-bug-1077075
Merge into: lp:maas/1.2
Diff against target: 41 lines (+16/-0)
2 files modified
src/maasserver/forms.py (+5/-0)
src/maasserver/tests/test_forms.py (+11/-0)
To merge this branch: bzr merge lp:~jtv/maas/1.2-bug-1077075
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve on 2012-11-09
Review via email: mp+133727@code.launchpad.net

Commit message

Backport trunk r1344: Fix oops when renaming accepted nodegroup without interfaces.

Description of the change

Fixes bug 1077075 in Quantal. Backported from trunk without changes.

Jeroen

To post a comment you must log in.
Jeroen T. Vermeulen (jtv) wrote :

Already reviewed & landed in trunk. Tests pass. Self-approving.

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.py'
2--- src/maasserver/forms.py 2012-11-08 09:14:58 +0000
3+++ src/maasserver/forms.py 2012-11-09 18:17:21 +0000
4@@ -833,6 +833,11 @@
5 return new_name
6
7 interface = self.instance.get_managed_interface()
8+ if interface is None:
9+ # No network interfaces. It's weird, but there certainly
10+ # won't be a problem with the name change.
11+ return new_name
12+
13 if interface.management != NODEGROUPINTERFACE_MANAGEMENT.DHCP_AND_DNS:
14 # MAAS is not managing DNS on this network, so the user can
15 # rename the zone at will.
16
17=== modified file 'src/maasserver/tests/test_forms.py'
18--- src/maasserver/tests/test_forms.py 2012-10-30 15:15:30 +0000
19+++ src/maasserver/tests/test_forms.py 2012-11-09 18:17:21 +0000
20@@ -57,6 +57,7 @@
21 MACAddress,
22 Node,
23 NodeGroup,
24+ NodeGroupInterface,
25 )
26 from maasserver.models.config import DEFAULT_CONFIG
27 from maasserver.node_action import (
28@@ -992,3 +993,13 @@
29 self.assertTrue(form.is_valid())
30 form.save()
31 self.assertEqual(data['name'], reload_object(nodegroup).name)
32+
33+ def test_accepts_name_change_if_nodegroup_has_no_interface(self):
34+ nodegroup, node = make_unrenamable_nodegroup_with_node()
35+ NodeGroupInterface.objects.filter(nodegroup=nodegroup).delete()
36+ data = self.make_form_data(nodegroup)
37+ data['name'] = factory.make_name('new-name')
38+ form = NodeGroupEdit(instance=nodegroup, data=data)
39+ self.assertTrue(form.is_valid())
40+ form.save()
41+ self.assertEqual(data['name'], reload_object(nodegroup).name)

Subscribers

People subscribed via source and target branches

to status/vote changes: