Move "server_profile_template_uri" to REQUIRED_ON_PROPERTIES

According to the description in [1], "server_profile_template_uri"
is now stored in properties/capabilities instead of driver_info.
And also, gabriel-bezerra has commented that we should move
"server_profile_template_uri" to REQUIRED_ON_PROPERTIES and remove
the related unit tests after Mitaka.

So this patch does it.

[1] http://docs.openstack.org/developer/ironic/drivers/oneview.html#registering-a-oneview-node-in-ironic

Change-Id: Idea37b157ec0537a55a7c77f9bef284ff2bb94d5
This commit is contained in:
Tang Chen 2016-07-26 13:50:39 +08:00
parent 5e07d2bb4c
commit 134ac32ec7
3 changed files with 10 additions and 101 deletions

View File

@ -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'),
}

View File

@ -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,

View File

@ -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.