Merge "Update drivers VendorInterface validate() method"

This commit is contained in:
Jenkins 2014-11-19 22:12:13 +00:00 committed by Gerrit Code Review
commit 9aebde3981
5 changed files with 3 additions and 42 deletions

View File

@ -31,15 +31,6 @@ from ironic.common import states
from ironic.drivers import base
def _raise_unsupported_error(method=None):
if method:
raise exception.InvalidParameterValue(_(
"Unsupported method (%s) passed through to vendor extension.")
% method)
raise exception.MissingParameterValue(_(
"Method not specified when calling vendor extension."))
class FakePower(base.PowerInterface):
"""Example implementation of a simple power interface."""
@ -105,8 +96,6 @@ class FakeVendorA(base.VendorInterface):
if not bar:
raise exception.MissingParameterValue(_(
"Parameter 'bar' not passed to method 'first_method'."))
return
_raise_unsupported_error(method)
@base.passthru(['POST'],
description=_("Test if the value of bar is baz"))
@ -128,8 +117,6 @@ class FakeVendorB(base.VendorInterface):
if not bar:
raise exception.MissingParameterValue(_(
"Parameter 'bar' not passed to method '%s'.") % method)
return
_raise_unsupported_error(method)
@base.passthru(['POST'],
description=_("Test if the value of bar is kazoo"))

View File

@ -591,13 +591,7 @@ class VendorPassthru(base.VendorInterface):
:raises: InvalidParameterValue, if any of the parameters have invalid
value.
"""
method = kwargs['method']
if method == 'pass_deploy_info':
iscsi_deploy.get_deploy_info(task.node, **kwargs)
else:
raise exception.InvalidParameterValue(_(
"Unsupported method (%s) passed to iLO driver.")
% method)
iscsi_deploy.get_deploy_info(task.node, **kwargs)
@base.passthru(['POST'], method='pass_deploy_info')
@task_manager.require_exclusive_lock

View File

@ -907,13 +907,7 @@ class VendorPassthru(base.VendorInterface):
raise exception.InvalidParameterValue(_(
'Parameter raw_bytes (string of bytes) was not '
'specified.'))
elif method == 'bmc_reset':
# no additional parameters needed
pass
else:
raise exception.InvalidParameterValue(_(
"Unsupported method (%s) passed to IPMItool driver.")
% method)
_parse_driver_info(task.node)

View File

@ -444,13 +444,7 @@ class VendorPassthru(base.VendorInterface):
:raises: InvalidParameterValue if method is invalid or any parameters
to the method is invalid.
"""
method = kwargs['method']
if method == 'pass_deploy_info':
iscsi_deploy.get_deploy_info(task.node, **kwargs)
else:
raise exception.InvalidParameterValue(_(
"Unsupported method (%s) passed to PXE driver.")
% method)
iscsi_deploy.get_deploy_info(task.node, **kwargs)
@base.passthru(['POST'], method='pass_deploy_info')
@task_manager.require_exclusive_lock

View File

@ -1043,14 +1043,6 @@ class IPMIToolDriverTestCase(db_base.DbTestCase):
self.assertEqual(manager.mock_calls, expected)
@mock.patch.object(ipmi, '_parse_driver_info')
def test_vendor_passthru_validate_method_notmatch(self, info_mock):
with task_manager.acquire(self.context, self.node['uuid']) as task:
self.assertRaises(exception.InvalidParameterValue,
self.driver.vendor.validate,
task, method='fake_method')
self.assertFalse(info_mock.called)
@mock.patch.object(ipmi, '_parse_driver_info')
def test_vendor_passthru_validate__parse_driver_info_fail(self, info_mock):
info_mock.side_effect = exception.InvalidParameterValue("bad")