From 054ef087b8a5a22c82e74af013db9dc89e34834b Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Wed, 19 Nov 2014 11:40:32 +0000 Subject: [PATCH] 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 --- ironic/drivers/modules/fake.py | 13 ------------- ironic/drivers/modules/ilo/deploy.py | 8 +------- ironic/drivers/modules/ipmitool.py | 8 +------- ironic/drivers/modules/pxe.py | 8 +------- ironic/tests/drivers/test_ipmitool.py | 8 -------- 5 files changed, 3 insertions(+), 42 deletions(-) diff --git a/ironic/drivers/modules/fake.py b/ironic/drivers/modules/fake.py index e07680d725..0d4ba68f1e 100644 --- a/ironic/drivers/modules/fake.py +++ b/ironic/drivers/modules/fake.py @@ -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): diff --git a/ironic/drivers/modules/ilo/deploy.py b/ironic/drivers/modules/ilo/deploy.py index 21eab2b68a..27fc09f25a 100644 --- a/ironic/drivers/modules/ilo/deploy.py +++ b/ironic/drivers/modules/ilo/deploy.py @@ -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 diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index c2b7f73d58..36ddfa8b0a 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -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) diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 74a0a067e8..3876b29b93 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -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 diff --git a/ironic/tests/drivers/test_ipmitool.py b/ironic/tests/drivers/test_ipmitool.py index 8386056adf..db01de136f 100644 --- a/ironic/tests/drivers/test_ipmitool.py +++ b/ironic/tests/drivers/test_ipmitool.py @@ -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")