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
=== modified file 'src/maasserver/node_action.py'
--- src/maasserver/node_action.py 2012-04-27 13:55:54 +0000
+++ src/maasserver/node_action.py 2012-05-08 16:24:22 +0000
@@ -129,7 +129,7 @@
129 permission = NODE_PERMISSION.ADMIN129 permission = NODE_PERMISSION.ADMIN
130130
131 def inhibit(self):131 def inhibit(self):
132 if self.node.owner is not None:132 if self.node.status == NODE_STATUS.ALLOCATED:
133 return "You cannot delete this node because it's in use."133 return "You cannot delete this node because it's in use."
134 return None134 return None
135135
136136
=== modified file 'src/maasserver/templates/maasserver/node_view.html'
--- src/maasserver/templates/maasserver/node_view.html 2012-04-25 16:58:45 +0000
+++ src/maasserver/templates/maasserver/node_view.html 2012-05-08 16:24:22 +0000
@@ -17,7 +17,9 @@
17 <form id="node_actions" method="post" action=".">17 <form id="node_actions" method="post" action=".">
18 {% for action in form.action_buttons %}18 {% for action in form.action_buttons %}
19 <input19 <input
20 class="secondary {% if action.inhibition %}disabled{% endif %} {% if not forloop.first %}space-top{% endif %}"20 class="secondary
21 {% if action.inhibition %}disabled{% endif %}
22 {% if not forloop.first %}space-top{% endif %}"
21 type="submit"23 type="submit"
22 name="{{ form.input_name }}"24 name="{{ form.input_name }}"
23 value="{{ action.display }}"25 value="{{ action.display }}"
2426
=== modified file 'src/maasserver/tests/test_node_action.py'
--- src/maasserver/tests/test_node_action.py 2012-04-27 13:55:54 +0000
+++ src/maasserver/tests/test_node_action.py 2012-05-08 16:24:22 +0000
@@ -162,20 +162,19 @@
162 action.fake_inhibition = factory.getRandomString()162 action.fake_inhibition = factory.getRandomString()
163 self.assertIsNone(action.inhibition)163 self.assertIsNone(action.inhibition)
164164
165 def test_Delete_inhibit_allows_if_node_has_no_owner(self):165 def test_Delete_inhibit_when_node_is_allocated(self):
166 unowned_node = factory.make_node(status=NODE_STATUS.READY)166 node = factory.make_node(status=NODE_STATUS.ALLOCATED)
167 self.assertIsNone(167 action = Delete(node, factory.make_admin())
168 Delete(unowned_node, factory.make_admin()).inhibit())
169
170 def test_Delete_inhibit_disallows_if_node_has_owner(self):
171 owned_node = factory.make_node(
172 status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
173 action = Delete(owned_node, factory.make_admin())
174 inhibition = action.inhibit()168 inhibition = action.inhibit()
175 self.assertIsNotNone(inhibition)
176 self.assertEqual(169 self.assertEqual(
177 "You cannot delete this node because it's in use.", inhibition)170 "You cannot delete this node because it's in use.", inhibition)
178171
172 def test_Delete_does_not_inhibit_otherwise(self):
173 node = factory.make_node(status=NODE_STATUS.FAILED_TESTS)
174 action = Delete(node, factory.make_admin())
175 inhibition = action.inhibit()
176 self.assertIsNone(inhibition)
177
179 def test_Delete_redirects_to_node_delete_view(self):178 def test_Delete_redirects_to_node_delete_view(self):
180 node = factory.make_node()179 node = factory.make_node()
181 action = Delete(node, factory.make_admin())180 action = Delete(node, factory.make_admin())