Merge "Prevent power actions on node in cleaning"
This commit is contained in:
commit
8bcfb5ab80
@ -358,7 +358,7 @@ class NodeStatesController(rest.RestController):
|
|||||||
:raises: ClientSideError (HTTP 409) if a power operation is
|
:raises: ClientSideError (HTTP 409) if a power operation is
|
||||||
already in progress.
|
already in progress.
|
||||||
:raises: InvalidStateRequested (HTTP 400) if the requested target
|
:raises: InvalidStateRequested (HTTP 400) if the requested target
|
||||||
state is not valid.
|
state is not valid or if the node is in CLEANING state.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# TODO(lucasagomes): Test if it's able to transition to the
|
# TODO(lucasagomes): Test if it's able to transition to the
|
||||||
@ -373,6 +373,12 @@ class NodeStatesController(rest.RestController):
|
|||||||
action=target, node=node_ident,
|
action=target, node=node_ident,
|
||||||
state=rpc_node.power_state)
|
state=rpc_node.power_state)
|
||||||
|
|
||||||
|
# Don't change power state for nodes in cleaning
|
||||||
|
elif rpc_node.provision_state == ir_states.CLEANING:
|
||||||
|
raise exception.InvalidStateRequested(
|
||||||
|
action=target, node=node_ident,
|
||||||
|
state=rpc_node.power_state)
|
||||||
|
|
||||||
pecan.request.rpcapi.change_node_power_state(pecan.request.context,
|
pecan.request.rpcapi.change_node_power_state(pecan.request.context,
|
||||||
rpc_node.uuid, target,
|
rpc_node.uuid, target,
|
||||||
topic)
|
topic)
|
||||||
|
@ -1618,6 +1618,13 @@ class TestPut(test_api_base.FunctionalTest):
|
|||||||
{'target': 'not-supported'}, expect_errors=True)
|
{'target': 'not-supported'}, expect_errors=True)
|
||||||
self.assertEqual(400, ret.status_code)
|
self.assertEqual(400, ret.status_code)
|
||||||
|
|
||||||
|
def test_power_change_during_cleaning(self):
|
||||||
|
self.node.provision_state = states.CLEANING
|
||||||
|
self.node.save()
|
||||||
|
ret = self.put_json('/nodes/%s/states/power' % self.node.uuid,
|
||||||
|
{'target': states.POWER_OFF}, expect_errors=True)
|
||||||
|
self.assertEqual(400, ret.status_code)
|
||||||
|
|
||||||
def test_provision_invalid_state_request(self):
|
def test_provision_invalid_state_request(self):
|
||||||
ret = self.put_json('/nodes/%s/states/provision' % self.node.uuid,
|
ret = self.put_json('/nodes/%s/states/provision' % self.node.uuid,
|
||||||
{'target': 'not-supported'}, expect_errors=True)
|
{'target': 'not-supported'}, expect_errors=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user