Merge "Use server_profile_template_uri at scheduling"

This commit is contained in:
Jenkins 2015-11-20 15:04:57 +00:00 committed by Gerrit Code Review
commit 91c387bd4c
5 changed files with 164 additions and 44 deletions

View File

@ -174,13 +174,13 @@ etc. In this case, to be enrolled, the node must have the following parameters:
* In ``driver_info``
- ``server_hardware_uri``: URI of the Server Hardware on OneView.
- ``server_profile_template_uri``: URI of the Server Profile Template used
to create the Server Profile of the Server Hardware.
* In ``properties/capabilities``
- ``server_hardware_type_uri``: URI of the Server Hardware Type of the
Server Hardware.
- ``server_profile_template_uri``: URI of the Server Profile Template used
to create the Server Profile of the Server Hardware.
- ``enclosure_group_uri`` (optional): URI of the Enclosure Group of the
Server Hardware.
@ -191,14 +191,13 @@ To enroll a node with any of the OneView drivers, do::
To update the ``driver_info`` field of a newly enrolled OneView node, do::
$ ironic node-update $NODE_UUID add \
driver_info/server_hardware_uri=$SH_URI \
driver_info/server_profile_template_uri=$SPT_URI
driver_info/server_hardware_uri=$SH_URI
To update the ``properties/capabilities`` namespace of a newly enrolled
OneView node, do::
$ ironic node-update $NODE_UUID add \
properties/capabilities=server_hardware_type_uri:$SHT_URI,enclosure_group_uri:$EG_URI
properties/capabilities=server_hardware_type_uri:$SHT_URI,enclosure_group_uri:$EG_URI,server_profile_template_uri=$SPT_URI
In order to deploy, a Server Profile consistent with the Server Profile
Template of the node MUST be applied to the Server Hardware it represents.

View File

@ -21,6 +21,7 @@ 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.drivers import utils
@ -54,17 +55,27 @@ CONF = cfg.CONF
CONF.register_opts(opts, group='oneview')
REQUIRED_ON_DRIVER_INFO = {
'server_hardware_uri': _("Server Hardware URI. Required."),
'server_profile_template_uri': _("Server Profile Template URI to clone "
"from. Required."),
'server_hardware_uri': _("Server Hardware URI. Required in driver_info."),
}
REQUIRED_ON_PROPERTIES = {
'server_hardware_type_uri': _("Server Hardware Type URI. Required."),
'server_hardware_type_uri': _(
"Server Hardware Type URI. 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.")
'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 = {}
@ -112,6 +123,30 @@ 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)
@ -144,8 +179,10 @@ 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'),
}
return oneview_info

View File

@ -334,13 +334,13 @@ def get_test_oneview_properties():
"cpus": "8",
"local_gb": "10",
"memory_mb": "4096",
"capabilities": "server_hardware_type_uri:fake_sht_uri,"
"enclosure_group_uri:fake_eg_uri"
"capabilities": ("server_hardware_type_uri:fake_sht_uri,"
"enclosure_group_uri:fake_eg_uri,"
"server_profile_template_uri:fake_spt_uri"),
}
def get_test_oneview_driver_info():
return {
'server_hardware_uri': 'fake_uri',
'server_profile_template_uri': 'fake_spt_uri'
'server_hardware_uri': 'fake_sh_uri',
}

View File

@ -24,28 +24,20 @@ from ironic.conductor import task_manager
from ironic.drivers.modules.oneview import common
from ironic.tests.unit.conductor import mgr_utils
from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils
oneview_states = importutils.try_import('oneview_client.states')
PROPERTIES_DICT = {"cpu_arch": "x86_64",
"cpus": "8",
"local_gb": "10",
"memory_mb": "4096",
"capabilities": "server_hardware_type_uri:fake_sht_uri,"
"enclosure_group_uri:fake_eg_uri"}
DRIVER_INFO_DICT = {'server_hardware_uri': 'fake_sh_uri',
'server_profile_template_uri': 'fake_spt_uri'}
class OneViewCommonTestCase(db_base.DbTestCase):
def setUp(self):
super(OneViewCommonTestCase, self).setUp()
self.node = obj_utils.create_test_node(
self.context, driver='fake_oneview', properties=PROPERTIES_DICT,
driver_info=DRIVER_INFO_DICT,
self.context, driver='fake_oneview',
properties=db_utils.get_test_oneview_properties(),
driver_info=db_utils.get_test_oneview_driver_info(),
)
self.config(manager_url='https://1.2.3.4', group='oneview')
self.config(username='user', group='oneview')
@ -61,7 +53,8 @@ class OneViewCommonTestCase(db_base.DbTestCase):
"cpus": "8",
"local_gb": "10",
"memory_mb": "4096",
"capabilities": "enclosure_group_uri:fake_eg_uri"
"capabilities": ("enclosure_group_uri:fake_eg_uri,"
"server_profile_template_uri:fake_spt_uri")
}
exc = self.assertRaises(
@ -75,9 +68,7 @@ class OneViewCommonTestCase(db_base.DbTestCase):
str(exc))
def test_verify_node_info_missing_node_driver_info(self):
self.node.driver_info = {
'server_hardware_uri': 'fake_sh_uri'
}
self.node.driver_info = {}
exc = self.assertRaises(
exception.MissingParameterValue,
@ -85,9 +76,27 @@ class OneViewCommonTestCase(db_base.DbTestCase):
self.node
)
self.assertEqual("Missing the keys for the following OneView data in "
"node's driver_info: server_profile_template_uri.",
"node's driver_info: server_hardware_uri.",
str(exc))
def test_verify_node_info_missing_spt(self):
properties = db_utils.get_test_oneview_properties()
properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri,"
"enclosure_group_uri:fake_eg_uri")
self.node.properties = properties
exc = self.assertRaises(
exception.MissingParameterValue,
common.verify_node_info,
self.node
)
# TODO(gabriel-bezerra): Simplify this after Mitaka
self.assertEqual(
("Missing 'server_profile_template_uri' parameter value in "
"properties/capabilities"),
str(exc))
def test_get_oneview_info(self):
complete_node = self.node
expected_node_info = {
@ -102,6 +111,93 @@ class OneViewCommonTestCase(db_base.DbTestCase):
common.get_oneview_info(complete_node)
)
def test_get_oneview_info_missing_spt(self):
driver_info = db_utils.get_test_oneview_driver_info()
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
incomplete_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': None,
}
self.assertEqual(
expected_node_info,
common.get_oneview_info(incomplete_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',
}
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',
}
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

@ -29,21 +29,9 @@ from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils
oneview_exceptions = importutils.try_import('oneview_client.exceptions')
# TODO(afaranha) move this variable to db_utils.get_test_oneview_properties()
PROPERTIES_DICT = {'cpu_arch': 'x86_64',
'cpus': '8',
'local_gb': '10',
'memory_mb': '4096',
'capabilities': 'server_hardware_type_uri:fake_sht_uri,'
'enclosure_group_uri:fake_eg_uri',
}
DRIVER_INFO_DICT = {'server_hardware_uri': 'fake_uri',
'server_profile_template_uri': 'fake_spt_uri',
}
POWER_ON = 'On'
POWER_OFF = 'Off'
ERROR = 'error'