Add maintenance check before call do_node_deploy
Currently if we set provision state to active or rebuild, there is no maintenance check before signal to conductor, so add the check on api side to save a rpc call. Closes-Bug: #1441413 Change-Id: I2898b874b92f865d7e566fac0ede568d1b6c3831
This commit is contained in:
parent
0bac0ac02e
commit
6aace9c774
@ -426,6 +426,11 @@ class NodeStatesController(rest.RestController):
|
|||||||
raise exception.NodeLocked(node=rpc_node.uuid,
|
raise exception.NodeLocked(node=rpc_node.uuid,
|
||||||
host=rpc_node.reservation)
|
host=rpc_node.reservation)
|
||||||
|
|
||||||
|
if (target in (ir_states.ACTIVE, ir_states.REBUILD)
|
||||||
|
and rpc_node.maintenance):
|
||||||
|
raise exception.NodeInMaintenance(op=_('provisioning'),
|
||||||
|
node=rpc_node.uuid)
|
||||||
|
|
||||||
m = ir_states.machine.copy()
|
m = ir_states.machine.copy()
|
||||||
m.initialize(rpc_node.provision_state)
|
m.initialize(rpc_node.provision_state)
|
||||||
if not m.is_valid_event(ir_states.VERBS.get(target, target)):
|
if not m.is_valid_event(ir_states.VERBS.get(target, target)):
|
||||||
|
@ -1899,11 +1899,8 @@ class TestPut(test_api_base.FunctionalTest):
|
|||||||
True, 'test-topic')
|
True, 'test-topic')
|
||||||
|
|
||||||
def test_provision_node_in_maintenance_fail(self):
|
def test_provision_node_in_maintenance_fail(self):
|
||||||
with mock.patch.object(rpcapi.ConductorAPI, 'do_node_deploy') as dnd:
|
|
||||||
self.node.maintenance = True
|
self.node.maintenance = True
|
||||||
self.node.save()
|
self.node.save()
|
||||||
dnd.side_effect = exception.NodeInMaintenance(op='provisioning',
|
|
||||||
node=self.node.uuid)
|
|
||||||
|
|
||||||
ret = self.put_json('/nodes/%s/states/provision' % self.node.uuid,
|
ret = self.put_json('/nodes/%s/states/provision' % self.node.uuid,
|
||||||
{'target': states.ACTIVE},
|
{'target': states.ACTIVE},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user