Update drivers VendorInterface validate() method

Update drivers VendorInterface validate() methods to remove the
verification of whether a method called exist or not. This verification
is now done by the conductor, validate() will always be called with a
valid method for drivers that are decorating their vendor methods with
the @passthru decorator.

Change-Id: Ia542df8283007ea2a2a049311a6418313a5859b4
This commit is contained in:
Lucas Alvares Gomes
2014-11-19 11:40:32 +00:00
parent 2d5f845e8d
commit 054ef087b8
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'])
def first_method(self, task, http_method, bar):
@@ -127,8 +116,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'])
def second_method(self, task, http_method, bar):

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")