Merge lp:~julian-edwards/maas/stop-even-when-ready-bug-1368400 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: 3290
Proposed branch: lp:~julian-edwards/maas/stop-even-when-ready-bug-1368400
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 49 lines (+18/-3)
2 files modified
src/maasserver/node_action.py (+1/-1)
src/maasserver/tests/test_node_action.py (+17/-2)
To merge this branch: bzr merge lp:~julian-edwards/maas/stop-even-when-ready-bug-1368400
Reviewer Review Type Date Requested Status
Christian Reis (community) Needs Information
Graham Binns (community) Approve
Review via email: mp+239339@code.launchpad.net

Commit message

Allow nodes in the READY state to accept a NodeStop action. This is so admins can power down nodes that are erroneously on for some reason.

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

Lovely!

review: Approve
Revision history for this message
Christian Reis (kiko) wrote :

Well, I'm not so sure about this one. The reason is that I think power control should be handled somewhat independently of node status, and presented as a separate set of administrative actions on the nodes. And in fact, I think we have this planned or at least in other bug reports.

review: Needs Information
Revision history for this message
Julian Edwards (julian-edwards) wrote :

I think you're right to a certain extent, but we don't want people hitting that button during some operations, such as deployment and during disk erasing. So I don't think we can get away from it completely, but this change at least helps people out in the short term.

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 2014-10-21 07:15:09 +0000
3+++ src/maasserver/node_action.py 2014-10-23 05:56:06 +0000
4@@ -365,7 +365,7 @@
5 display = "Stop node"
6 display_bulk = "Stop selected nodes"
7 actionable_statuses = (
8- [NODE_STATUS.DEPLOYED] +
9+ [NODE_STATUS.DEPLOYED, NODE_STATUS.READY] +
10 # Also let a user ask a failed node to shutdown: this
11 # is useful to try to recover from power failures.
12 FAILED_STATUSES
13
14=== modified file 'src/maasserver/tests/test_node_action.py'
15--- src/maasserver/tests/test_node_action.py 2014-10-21 07:15:09 +0000
16+++ src/maasserver/tests/test_node_action.py 2014-10-23 05:56:06 +0000
17@@ -396,7 +396,7 @@
18
19 class TestStopNodeNodeAction(MAASServerTestCase):
20
21- def test_StopNode_stops_deployed_node(self):
22+ def test__stops_deployed_node(self):
23 user = factory.make_User()
24 params = dict(
25 power_address=factory.make_string(),
26@@ -412,7 +412,22 @@
27
28 self.assertThat(node_stop, MockCalledOnceWith(user))
29
30- def test_StopNode_actionnable_for_failed_states(self):
31+ def test__stops_Ready_node(self):
32+ admin = factory.make_admin()
33+ params = dict(
34+ power_address=factory.make_string(),
35+ power_user=factory.make_string(),
36+ power_pass=factory.make_string())
37+ node = factory.make_Node(
38+ mac=True, status=NODE_STATUS.READY,
39+ power_type='ipmi', power_parameters=params)
40+ node_stop = self.patch_autospec(node, 'stop')
41+
42+ StopNode(node, admin).execute()
43+
44+ self.assertThat(node_stop, MockCalledOnceWith(admin))
45+
46+ def test__actionnable_for_failed_states(self):
47 status = random.choice(FAILED_STATUSES)
48 node = factory.make_Node(status=status, power_type='ipmi')
49 actions = compile_node_actions(