Merge lp:~jtv/maas/bug-987585 into lp:~maas-committers/maas/trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jeroen T. Vermeulen | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 514 | ||||
Proposed branch: | lp:~jtv/maas/bug-987585 | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Prerequisite: | lp:~jtv/maas/pre-987585-cosmetics-and-test-helper | ||||
Diff against target: |
238 lines (+81/-22) 4 files modified
src/maasserver/forms.py (+28/-8) src/maasserver/tests/test_forms.py (+16/-2) src/maasserver/tests/test_views_nodes.py (+20/-11) src/maasserver/views/nodes.py (+17/-1) |
||||
To merge this branch: | bzr merge lp:~jtv/maas/bug-987585 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+103332@code.launchpad.net |
Commit message
Make “Start node” action acquire the node, if it was Ready.
Description of the change
The need for this was discussed with Julian, if memory serves. When applied to a node in Ready state, the Start Node action is meant not just to start it up but to acquire it first. This is of course not desired if it's already in Allocated state. (These are the two states for which the action is offered). The obvious solution, given how node actions are defined, is to define slightly different actions for the two original node states.
Acquiring a node involves grabbing the OAuth key that was used to make the request. We might get away with grabbing any old key for the user, but it seemed arbitrary; what if it's an obsolete one? So instead, I extended the actions methods to take the UI request as an argument.
You'll note that I changed the feedback messages. I wanted to make the difference between “I allocated this node for you and started it up” and “you have just told this node to start” explicitly clear; I hope the former conveys a proportionate sense of assumed responsibility. The text “Node started” text was also a bit optimistic in two respects: first, it seemed to imply that startup had already completed and second, it appears to exclude any possibility that the node might not comply. And so I changed the wording to say that the node has been _asked_ to start up.
Since there are conceivable (if hopefully improbable) circumstances under which a node action might fail, I also defined a new rule (which I also discussed with Raphaël): as a special favour, a node action may raise a MAASAPIException on failure. Normally such an exception in a non-API request would appear to the client as a server error, but the view responsible for node actions will catch it, extract its status code, and return it to the client in at least a somewhat friendly way.
Jeroen
Looks good :)
[1]
+def start_commissio ning_node( node, user, request=None): commissioning( node, user)
+ """Start the commissioning process for a node."""
+ Node.start_
node.start_ commissioning( user) ?
[2]
+ notices = '\n'.join([ context[ 'messages' ]])
+ message.message for message in response.
No need for the [].