Merge lp:~allenap/maas/delete-failing-commissioning-node-bug-994781 into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 549
Proposed branch: lp:~allenap/maas/delete-failing-commissioning-node-bug-994781
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 61 lines (+13/-12)
3 files modified
src/maasserver/node_action.py (+1/-1)
src/maasserver/templates/maasserver/node_view.html (+3/-1)
src/maasserver/tests/test_node_action.py (+9/-10)
To merge this branch: bzr merge lp:~allenap/maas/delete-failing-commissioning-node-bug-994781
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+105083@code.launchpad.net

Commit message

Only inhibit node deletion when allocated.

Description of the change

Jeroen mentioned basically what the problem was this morning during the call.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

I wonder if we shouldn't also allow a user to delete nodes allocated _to themselves_. “There. It's running fine now. I want to keep it like this, without further control from MAAS.”

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

On 9 May 2012 10:22, Jeroen T. Vermeulen <email address hidden> wrote:
> Review: Approve
>
> I wonder if we shouldn't also allow a user to delete nodes allocated
> _to themselves_.  “There.  It's running fine now.  I want to keep it
> like this, without further control from MAAS.”

That's an interesting idea... I've filed bug 997092 about it because I
think it needs at least a little discussion.

Thank you for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/node_action.py'
2--- src/maasserver/node_action.py 2012-04-27 13:55:54 +0000
3+++ src/maasserver/node_action.py 2012-05-08 16:24:22 +0000
4@@ -129,7 +129,7 @@
5 permission = NODE_PERMISSION.ADMIN
6
7 def inhibit(self):
8- if self.node.owner is not None:
9+ if self.node.status == NODE_STATUS.ALLOCATED:
10 return "You cannot delete this node because it's in use."
11 return None
12
13
14=== modified file 'src/maasserver/templates/maasserver/node_view.html'
15--- src/maasserver/templates/maasserver/node_view.html 2012-04-25 16:58:45 +0000
16+++ src/maasserver/templates/maasserver/node_view.html 2012-05-08 16:24:22 +0000
17@@ -17,7 +17,9 @@
18 <form id="node_actions" method="post" action=".">
19 {% for action in form.action_buttons %}
20 <input
21- class="secondary {% if action.inhibition %}disabled{% endif %} {% if not forloop.first %}space-top{% endif %}"
22+ class="secondary
23+ {% if action.inhibition %}disabled{% endif %}
24+ {% if not forloop.first %}space-top{% endif %}"
25 type="submit"
26 name="{{ form.input_name }}"
27 value="{{ action.display }}"
28
29=== modified file 'src/maasserver/tests/test_node_action.py'
30--- src/maasserver/tests/test_node_action.py 2012-04-27 13:55:54 +0000
31+++ src/maasserver/tests/test_node_action.py 2012-05-08 16:24:22 +0000
32@@ -162,20 +162,19 @@
33 action.fake_inhibition = factory.getRandomString()
34 self.assertIsNone(action.inhibition)
35
36- def test_Delete_inhibit_allows_if_node_has_no_owner(self):
37- unowned_node = factory.make_node(status=NODE_STATUS.READY)
38- self.assertIsNone(
39- Delete(unowned_node, factory.make_admin()).inhibit())
40-
41- def test_Delete_inhibit_disallows_if_node_has_owner(self):
42- owned_node = factory.make_node(
43- status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
44- action = Delete(owned_node, factory.make_admin())
45+ def test_Delete_inhibit_when_node_is_allocated(self):
46+ node = factory.make_node(status=NODE_STATUS.ALLOCATED)
47+ action = Delete(node, factory.make_admin())
48 inhibition = action.inhibit()
49- self.assertIsNotNone(inhibition)
50 self.assertEqual(
51 "You cannot delete this node because it's in use.", inhibition)
52
53+ def test_Delete_does_not_inhibit_otherwise(self):
54+ node = factory.make_node(status=NODE_STATUS.FAILED_TESTS)
55+ action = Delete(node, factory.make_admin())
56+ inhibition = action.inhibit()
57+ self.assertIsNone(inhibition)
58+
59 def test_Delete_redirects_to_node_delete_view(self):
60 node = factory.make_node()
61 action = Delete(node, factory.make_admin())