Disallow new provision for nodes in maintenance

New deploy operation will not allowed for nodes in
'maintenance' mode.

Partial-Bug: #1260099
Change-Id: Idaf8c3d70bd78b2c95bbdcff734e235eb8063d91
This commit is contained in:
Yuriy Zveryanskyy 2013-12-24 14:49:28 +02:00 committed by Roman Prykhodchenko
parent 9bc5f92fb8
commit 3c10b567ce
2 changed files with 12 additions and 0 deletions

View File

@ -255,6 +255,11 @@ class ConductorManager(service.PeriodicService):
"state is already %(state)s.") %
{'node': node_id, 'state': node['provision_state']})
if node.maintenance:
raise exception.InstanceDeployFailure(_(
"RPC do_node_deploy called for %s, but node is in "
"maintenance mode.") % node_id)
try:
task.driver.deploy.validate(node)
except Exception as e:

View File

@ -307,6 +307,13 @@ class ManagerTestCase(base.DbTestCase):
self.service.do_node_deploy,
self.context, node['uuid'])
def test_do_node_deploy_maintenance(self):
ndict = utils.get_test_node(driver='fake', maintenance=True)
node = self.dbapi.create_node(ndict)
self.assertRaises(exception.InstanceDeployFailure,
self.service.do_node_deploy,
self.context, node['uuid'])
def test_do_node_deploy_driver_raises_error(self):
# test when driver.deploy.deploy raises an exception
ndict = utils.get_test_node(driver='fake',