Merge lp:~blake-rouse/maas/fix-1456698 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 3932
Proposed branch: lp:~blake-rouse/maas/fix-1456698
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 54 lines (+14/-2)
3 files modified
src/maasserver/node_action.py (+3/-0)
src/maasserver/static/partials/nodes-list.html (+1/-1)
src/maasserver/tests/test_node_action.py (+10/-1)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1456698
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+259954@code.launchpad.net

Commit message

Raise error when marking a node fixed when the power is on. Drive-by fix for the mis-alignment of the error icon on the nodes listing for actions.

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

Code looks good in general, but I'm worried that we're focused on this one corner case without seeing the big picture. (see question below)

review: Needs Information
Revision history for this message
Blake Rouse (blake-rouse) :
Revision history for this message
Mike Pontillo (mpontillo) :
Revision history for this message
Blake Rouse (blake-rouse) :
Revision history for this message
Mike Pontillo (mpontillo) :
review: Approve
Revision history for this message
Mike Pontillo (mpontillo) :

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 2015-05-13 11:33:20 +0000
3+++ src/maasserver/node_action.py 2015-05-22 16:17:28 +0000
4@@ -422,6 +422,9 @@
5
6 def execute(self):
7 """See `NodeAction.execute`."""
8+ if self.node.power_state == POWER_STATE.ON:
9+ raise NodeActionError(
10+ "Unable to be mark fixed because the power is currently on.")
11 self.node.mark_fixed()
12
13
14
15=== modified file 'src/maasserver/static/partials/nodes-list.html'
16--- src/maasserver/static/partials/nodes-list.html 2015-05-17 23:45:55 +0000
17+++ src/maasserver/static/partials/nodes-list.html 2015-05-22 16:17:28 +0000
18@@ -95,7 +95,7 @@
19 {$ tabs.nodes.actionProgress.completed $} of {$ tabs.nodes.actionProgress.total $}
20 nodes have been {$ tabs.nodes.actionOption.sentence $}.
21 </p>
22- <p class="page-header__feedback-message error progress"
23+ <p class="page-header__feedback-message error"
24 data-ng-repeat="(error, nodes) in tabs.nodes.actionProgress.errors">
25 The {$ tabs.nodes.actionOption.title.toLowerCase() $} action for {$ nodes.length $}
26 <span data-ng-pluralize count="nodes.length" when="{'one': 'node', 'other': 'nodes'}"></span>
27
28=== modified file 'src/maasserver/tests/test_node_action.py'
29--- src/maasserver/tests/test_node_action.py 2015-05-21 19:32:24 +0000
30+++ src/maasserver/tests/test_node_action.py 2015-05-22 16:17:28 +0000
31@@ -683,13 +683,22 @@
32 class TestMarkFixedAction(MAASServerTestCase):
33
34 def test_changes_status(self):
35- node = factory.make_Node(status=NODE_STATUS.BROKEN)
36+ node = factory.make_Node(
37+ status=NODE_STATUS.BROKEN, power_state=POWER_STATE.OFF)
38 user = factory.make_admin()
39 action = MarkFixed(node, user)
40 self.assertTrue(action.is_permitted())
41 action.execute()
42 self.assertEqual(NODE_STATUS.READY, reload_object(node).status)
43
44+ def test_raise_NodeActionError_if_on(self):
45+ node = factory.make_Node(
46+ status=NODE_STATUS.BROKEN, power_state=POWER_STATE.ON)
47+ user = factory.make_admin()
48+ action = MarkFixed(node, user)
49+ self.assertTrue(action.is_permitted())
50+ self.assertRaises(NodeActionError, action.execute)
51+
52 def test_requires_admin_permission(self):
53 user = factory.make_User()
54 node = factory.make_Node()