diff --git a/ironic/drivers/modules/oneview/common.py b/ironic/drivers/modules/oneview/common.py index 20e0307ce1..7114a5cd35 100644 --- a/ironic/drivers/modules/oneview/common.py +++ b/ironic/drivers/modules/oneview/common.py @@ -19,7 +19,6 @@ from oslo_utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE -from ironic.common.i18n import _LW from ironic.common import states from ironic.conf import CONF from ironic.drivers import utils @@ -39,20 +38,15 @@ REQUIRED_ON_PROPERTIES = { 'server_hardware_type_uri': _( "Server Hardware Type URI. Required in properties/capabilities." ), + 'server_profile_template_uri': _( + "Server Profile Template URI to clone from. " + "Required in properties/capabilities." + ), } -# TODO(gabriel-bezerra): Move 'server_profile_template_uri' to -# REQUIRED_ON_PROPERTIES after Mitaka. See methods get_oneview_info, -# verify_node_info from this file; and test_verify_node_info_missing_spt -# and test_deprecated_spt_in_driver_info* from test_common tests. OPTIONAL_ON_PROPERTIES = { 'enclosure_group_uri': _( "Enclosure Group URI. Optional in properties/capabilities."), - - 'server_profile_template_uri': _( - "Server Profile Template URI to clone from. " - "Deprecated in driver_info. " - "Required in properties/capabilities."), } COMMON_PROPERTIES = {} @@ -109,29 +103,6 @@ def verify_node_info(node): _verify_node_info('properties/capabilities', capabilities_dict, REQUIRED_ON_PROPERTIES) - # TODO(gabriel-bezerra): Remove this after Mitaka - try: - _verify_node_info('properties/capabilities', capabilities_dict, - ['server_profile_template_uri']) - - except exception.MissingParameterValue: - try: - _verify_node_info('driver_info', driver_info, - ['server_profile_template_uri']) - - LOG.warning( - _LW("Using 'server_profile_template_uri' in driver_info is " - "now deprecated and will be ignored in future releases. " - "Node %s should have it in its properties/capabilities " - "instead."), - node.uuid - ) - except exception.MissingParameterValue: - raise exception.MissingParameterValue( - _("Missing 'server_profile_template_uri' parameter value in " - "properties/capabilities") - ) - # end _verify_node_info('driver_info', driver_info, REQUIRED_ON_DRIVER_INFO) @@ -168,8 +139,7 @@ def get_oneview_info(node): 'enclosure_group_uri': capabilities_dict.get('enclosure_group_uri'), 'server_profile_template_uri': - capabilities_dict.get('server_profile_template_uri') or - driver_info.get('server_profile_template_uri'), + capabilities_dict.get('server_profile_template_uri'), 'applied_server_profile_uri': driver_info.get('applied_server_profile_uri'), } diff --git a/ironic/tests/unit/drivers/modules/oneview/test_common.py b/ironic/tests/unit/drivers/modules/oneview/test_common.py index 928f3a574d..bbb50b9c89 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_common.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_common.py @@ -186,72 +186,6 @@ class OneViewCommonTestCase(db_base.DbTestCase): common.get_oneview_info, self.node) - # TODO(gabriel-bezerra): Remove this after Mitaka - @mock.patch.object(common, 'LOG', autospec=True) - def test_deprecated_spt_in_driver_info(self, log_mock): - # the current model has server_profile_template_uri in - # properties/capabilities instead of driver_info - - driver_info = db_utils.get_test_oneview_driver_info() - driver_info['server_profile_template_uri'] = 'fake_spt_uri' - - properties = db_utils.get_test_oneview_properties() - properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri," - "enclosure_group_uri:fake_eg_uri") - - self.node.driver_info = driver_info - self.node.properties = properties - - deprecated_node = self.node - expected_node_info = { - 'server_hardware_uri': 'fake_sh_uri', - 'server_hardware_type_uri': 'fake_sht_uri', - 'enclosure_group_uri': 'fake_eg_uri', - 'server_profile_template_uri': 'fake_spt_uri', - 'applied_server_profile_uri': None, - } - - self.assertEqual( - expected_node_info, - common.get_oneview_info(deprecated_node) - ) - - # must be valid - common.verify_node_info(deprecated_node) - - log_mock.warning.assert_called_once_with( - "Using 'server_profile_template_uri' in driver_info is " - "now deprecated and will be ignored in future releases. " - "Node %s should have it in its properties/capabilities " - "instead.", - self.node.uuid - ) - - # TODO(gabriel-bezerra): Remove this after Mitaka - def test_deprecated_spt_in_driver_info_and_in_capabilites(self): - # information in capabilities precedes driver_info - driver_info = db_utils.get_test_oneview_driver_info() - driver_info['server_profile_template_uri'] = 'unused_fake_spt_uri' - - self.node.driver_info = driver_info - - deprecated_node = self.node - expected_node_info = { - 'server_hardware_uri': 'fake_sh_uri', - 'server_hardware_type_uri': 'fake_sht_uri', - 'enclosure_group_uri': 'fake_eg_uri', - 'server_profile_template_uri': 'fake_spt_uri', - 'applied_server_profile_uri': None, - } - - self.assertEqual( - expected_node_info, - common.get_oneview_info(deprecated_node) - ) - - # must be valid - common.verify_node_info(deprecated_node) - def test__verify_node_info(self): common._verify_node_info("properties", {"a": True, diff --git a/releasenotes/notes/server_profile_template_uri-c79e4f15cc20a1cf.yaml b/releasenotes/notes/server_profile_template_uri-c79e4f15cc20a1cf.yaml new file mode 100644 index 0000000000..8e06b6c709 --- /dev/null +++ b/releasenotes/notes/server_profile_template_uri-c79e4f15cc20a1cf.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - When registering a OneView node in ironic, operator should make sure field + ``server_profile_template_uri`` is set in properties/capabilities and not + in driver_info anymore. Otherwise the node will fail on validation.