From 01a9726c04590045eb9095ba849738d568d06fd8 Mon Sep 17 00:00:00 2001 From: Madhuri Kumari Date: Wed, 10 Jul 2019 14:22:57 +0530 Subject: [PATCH] Follow-up to the IntelIPMIHardware patch Change-Id: I240c27c25f70b0a916bbed6cc4a4122c0bffd9a9 --- doc/source/admin/drivers/intel-ipmi.rst | 20 +++++++++---------- .../drivers/modules/intel_ipmi/management.py | 18 ++++++++--------- .../modules/intel_ipmi/test_management.py | 19 +++++++++--------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/doc/source/admin/drivers/intel-ipmi.rst b/doc/source/admin/drivers/intel-ipmi.rst index 92806c8c1e..256ab15ce3 100644 --- a/doc/source/admin/drivers/intel-ipmi.rst +++ b/doc/source/admin/drivers/intel-ipmi.rst @@ -18,17 +18,15 @@ Intel SST-PP supports three configuration levels: * 2 - Intel SST-PP Config 2 The following table shows the list of active cores and their base frequency at -different SST-PP config levels:: +different SST-PP config levels: - +-------------+---------+-------------------+ - | Config | Cores | Base Freq (GHz) | - +=============+=========+===================+ - | Base | 24 | 2.4 | - +-------------+---------+-------------------+ - | Config 1 | 20 | 2.5 | - +-------------+---------+-------------------+ - | Config 2 | 16 | 2.7 | - +-------------+---------+-------------------+ + ============== ========= =================== + Config Cores Base Freq (GHz) + ============== ========= =================== + Base 24 2.4 + Config 1 20 2.5 + Config 2 16 2.7 + ============== ========= =================== This configuration is managed by the management interface ``intel-ipmitool`` for IntelIPMI hardware. @@ -95,7 +93,7 @@ A node with Intel SST-PP can be configured to use it via * ``intel_speedselect_config``: Hexadecimal code of Intel SST-PP configuration. Accepted values are - ['0x00', '0x01', '0x02']. These values correspond to + '0x00', '0x01', '0x02'. These values correspond to `Intel SST-PP Config Base`, `Intel SST-PP Config 1`, `Intel SST-PP Config 2` respectively. The input value must be a string. diff --git a/ironic/drivers/modules/intel_ipmi/management.py b/ironic/drivers/modules/intel_ipmi/management.py index 8661b494ef..ce31aa7797 100644 --- a/ironic/drivers/modules/intel_ipmi/management.py +++ b/ironic/drivers/modules/intel_ipmi/management.py @@ -42,7 +42,7 @@ class IntelIPMIManagement(ipmitool.IPMIManagement): socket_count = int(sockets) if socket_count <= 0: raise ValueError - except ValueError: + except (ValueError, TypeError): raise exception.InvalidParameterValue(_( "Invalid number of socket %(socket)s value specified. " "Expected a positive integer.") % {"socket": sockets}) @@ -51,8 +51,8 @@ class IntelIPMIManagement(ipmitool.IPMIManagement): 'intel_speedselect_config': { 'description': ( "Hexadecimal code of Intel SST-PP configuration provided. " - "Input value should be string. Accepted values are " - "['0x00', '0x01', '0x02']. " + "Input value should be string. Accepted values are %s." + % ', '.join(INTEL_SST_PP_CONFIG_HEXA_CODES) ), 'required': True }, @@ -70,17 +70,15 @@ class IntelIPMIManagement(ipmitool.IPMIManagement): "for node %(node)s with socket count %(socket)s", {"config": config, "node": task.node.uuid, "socket": socket_count}) - self._configure_intel_speed_select(task, config, socket_count) - - def _configure_intel_speed_select(self, task, config, socket_count): iss_conf = "0x2c 0x41 0x04 0x00 0x0%s %s" for socket in range(socket_count): hexa_code = iss_conf % (socket, config) try: ipmitool.send_raw(task, hexa_code) except exception.IPMIFailure as e: - msg = ("Failed to set Intel SST-PP configuration level " - "%(cfg)s on socket number %(skt)s due to reason " - "%(exc)s." % {"cfg": config, "skt": socket, "exc": e}) - LOG.exception(msg) + msg = (_("Failed to set Intel SST-PP configuration level " + "%(cfg)s on socket number %(skt)s due to " + "reason %(exc)s.") % {"cfg": config, + "skt": socket, "exc": e}) + LOG.error(msg) raise exception.IPMIFailure(message=msg) diff --git a/ironic/tests/unit/drivers/modules/intel_ipmi/test_management.py b/ironic/tests/unit/drivers/modules/intel_ipmi/test_management.py index cb8a80d576..589906777d 100644 --- a/ironic/tests/unit/drivers/modules/intel_ipmi/test_management.py +++ b/ironic/tests/unit/drivers/modules/intel_ipmi/test_management.py @@ -64,11 +64,11 @@ class IntelIPMIManagementTestCase(base.IntelIPMITestCase): send_raw_mock.side_effect = exception.IPMIFailure('err') config = {"intel_speedselect_config": "0x02", "socket_count": 1} with task_manager.acquire(self.context, self.node.uuid) as task: - e = self.assertRaises( + self.assertRaisesRegex( exception.IPMIFailure, + "Failed to set Intel SST-PP configuration", task.driver.management.configure_intel_speedselect, task, **config) - self.assertIn("Failed to set Intel SST-PP configuration", str(e)) def test_configure_intel_speedselect_invalid_input(self): config = {"intel_speedselect_config": "0", "socket_count": 1} @@ -77,10 +77,11 @@ class IntelIPMIManagementTestCase(base.IntelIPMITestCase): exception.InvalidParameterValue, task.driver.management.configure_intel_speedselect, task, **config) - - config = {"intel_speedselect_config": "0x00", "socket_count": -1} - with task_manager.acquire(self.context, self.node.uuid) as task: - self.assertRaises( - exception.InvalidParameterValue, - task.driver.management.configure_intel_speedselect, - task, **config) + for value in (-1, None): + config = {"intel_speedselect_config": "0x00", + "socket_count": value} + with task_manager.acquire(self.context, self.node.uuid) as task: + self.assertRaises( + exception.InvalidParameterValue, + task.driver.management.configure_intel_speedselect, + task, **config)