From dffdf36ebd08eb8ed2c5f2cc03b5a7f3dba38927 Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Tue, 18 Apr 2017 12:59:11 +0200 Subject: [PATCH] Remove unneeded validation code in ValidateInterfacesHook oslo.config now sets enforce_type=True by default since [1], so there is no need to check in ValidateInterfacesHook that the value set in the config file is one of the valid values. [1] https://review.openstack.org/328692 Closes-Bug: #1683732 Change-Id: I5830466cb21f200ae1c33021cce4d166a26456be --- ironic_inspector/plugins/standard.py | 17 ----------------- .../test/unit/test_plugins_standard.py | 8 -------- 2 files changed, 25 deletions(-) diff --git a/ironic_inspector/plugins/standard.py b/ironic_inspector/plugins/standard.py index 7033e4c42..938e10a11 100644 --- a/ironic_inspector/plugins/standard.py +++ b/ironic_inspector/plugins/standard.py @@ -13,7 +13,6 @@ """Standard set of plugins.""" -import sys from ironic_lib import utils as il_utils import netaddr @@ -23,7 +22,6 @@ from oslo_utils import units import six from ironic_inspector.common.i18n import _ -from ironic_inspector import conf from ironic_inspector.plugins import base from ironic_inspector import utils @@ -126,21 +124,6 @@ class SchedulerHook(base.ProcessingHook): class ValidateInterfacesHook(base.ProcessingHook): """Hook to validate network interfaces.""" - def __init__(self): - if CONF.processing.add_ports not in conf.VALID_ADD_PORTS_VALUES: - LOG.critical('Accepted values for [processing]add_ports are ' - '%(valid)s, got %(actual)s', - {'valid': conf.VALID_ADD_PORTS_VALUES, - 'actual': CONF.processing.add_ports}) - sys.exit(1) - - if CONF.processing.keep_ports not in conf.VALID_KEEP_PORTS_VALUES: - LOG.critical('Accepted values for [processing]keep_ports are ' - '%(valid)s, got %(actual)s', - {'valid': conf.VALID_KEEP_PORTS_VALUES, - 'actual': CONF.processing.keep_ports}) - sys.exit(1) - def _get_interfaces(self, data=None): """Convert inventory to a dict with interfaces. diff --git a/ironic_inspector/test/unit/test_plugins_standard.py b/ironic_inspector/test/unit/test_plugins_standard.py index ae058b56e..dcc93edda 100644 --- a/ironic_inspector/test/unit/test_plugins_standard.py +++ b/ironic_inspector/test/unit/test_plugins_standard.py @@ -103,14 +103,6 @@ class TestValidateInterfacesHookLoad(test_base.NodeTest): ext = base.processing_hooks_manager()['validate_interfaces'] self.assertIsInstance(ext.obj, std_plugins.ValidateInterfacesHook) - def test_wrong_add_ports(self): - CONF.set_override('add_ports', 'foobar', 'processing') - self.assertRaises(SystemExit, std_plugins.ValidateInterfacesHook) - - def test_wrong_keep_ports(self): - CONF.set_override('keep_ports', 'foobar', 'processing') - self.assertRaises(SystemExit, std_plugins.ValidateInterfacesHook) - class TestValidateInterfacesHookBeforeProcessing(test_base.NodeTest): def setUp(self):