Validate the power interface before deployment

This patch makes the do_node_deploy() validate the drivers power interface
before start deploying a node because powering the node on/off is part
of the deployment.

Change-Id: Ic52c49ac6c8631f81eb50b69a5bdb56a113a72b4
Closes-Bug: #1378301
This commit is contained in:
Lucas Alvares Gomes 2014-10-07 12:24:26 +01:00
parent 0827173215
commit ae2f9699e0
2 changed files with 12 additions and 4 deletions

View File

@ -514,12 +514,13 @@ class ConductorManager(periodic_task.PeriodicTasks):
node=node.uuid)
try:
task.driver.power.validate(task)
task.driver.deploy.validate(task)
except (exception.InvalidParameterValue,
exception.MissingParameterValue) as e:
raise exception.InstanceDeployFailure(_(
"RPC do_node_deploy failed to validate deploy info. "
"Error: %(msg)s") % {'msg': e})
"RPC do_node_deploy failed to validate deploy or "
"power info. Error: %(msg)s") % {'msg': e})
# Save the previous states so we can rollback the node to a
# consistent state in case there's no free workers to do the

View File

@ -663,8 +663,7 @@ class DoNodeDeployTearDownTestCase(_ServiceSetUpMixin,
# Verify reservation has been cleared.
self.assertIsNone(node.reservation)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.validate')
def test_do_node_deploy_validate_fail(self, mock_validate):
def _test_do_node_deploy_validate_fail(self, mock_validate):
# InvalidParameterValue should be re-raised as InstanceDeployFailure
mock_validate.side_effect = exception.InvalidParameterValue('error')
node = obj_utils.create_test_node(self.context, driver='fake')
@ -678,6 +677,14 @@ class DoNodeDeployTearDownTestCase(_ServiceSetUpMixin,
# Verify reservation has been cleared.
self.assertIsNone(node.reservation)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.validate')
def test_do_node_deploy_validate_fail(self, mock_validate):
self._test_do_node_deploy_validate_fail(mock_validate)
@mock.patch('ironic.drivers.modules.fake.FakePower.validate')
def test_do_node_deploy_power_validate_fail(self, mock_validate):
self._test_do_node_deploy_validate_fail(mock_validate)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.deploy')
def test__do_node_deploy_driver_raises_error(self, mock_deploy):
# test when driver.deploy.deploy raises an exception