summaryrefslogtreecommitdiff
path: root/ironic/drivers
diff options
context:
space:
mode:
authorMadhuri Kumari <madhuri.rai07@gmail.com>2019-05-16 12:40:33 +0000
committerMadhuri Kumari <madhuri.kumari@intel.com>2019-06-25 13:46:26 +0530
commit5127b6f6ddaddba329e2e250399b334a6a58dbba (patch)
treeaab4e6eb999884a239c4eeff96864ac17f13d684 /ironic/drivers
parent0a3b1968aa18b7960afddff66c462709d8e1351b (diff)
downloadironic-5127b6f6ddaddba329e2e250399b334a6a58dbba.tar.gz
Add IntelIPMIHardware
IntelIPMIHardware is a hardware that supports configuring Intel Speed Select Performance Profile using ipmitool. Change-Id: I49abccb4735b43aed3155ea7e24b2fa0416c83b2 Story: 2005390 Task: 30484
Diffstat (limited to 'ironic/drivers')
-rw-r--r--ironic/drivers/intel_ipmi.py27
-rw-r--r--ironic/drivers/modules/intel_ipmi/__init__.py0
-rw-r--r--ironic/drivers/modules/intel_ipmi/management.py86
3 files changed, 113 insertions, 0 deletions
diff --git a/ironic/drivers/intel_ipmi.py b/ironic/drivers/intel_ipmi.py
new file mode 100644
index 000000000..905e93048
--- /dev/null
+++ b/ironic/drivers/intel_ipmi.py
@@ -0,0 +1,27 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from ironic.drivers import ipmi
+from ironic.drivers.modules.intel_ipmi import management
+
+
+class IntelIPMIHardware(ipmi.IPMIHardware):
+ """Intel IPMI hardware type.
+
+ Uses ``ipmitool`` to implement power and management.
+ Provides serial console implementations via ``shellinabox`` or ``socat``.
+ Supports Intel SST-PP feature.
+ """
+ @property
+ def supported_management_interfaces(self):
+ """List of supported management interfaces."""
+ return [management.IntelIPMIManagement]
diff --git a/ironic/drivers/modules/intel_ipmi/__init__.py b/ironic/drivers/modules/intel_ipmi/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ironic/drivers/modules/intel_ipmi/__init__.py
diff --git a/ironic/drivers/modules/intel_ipmi/management.py b/ironic/drivers/modules/intel_ipmi/management.py
new file mode 100644
index 000000000..8661b494e
--- /dev/null
+++ b/ironic/drivers/modules/intel_ipmi/management.py
@@ -0,0 +1,86 @@
+# coding=utf-8
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+Intel IPMI Hardware.
+
+Supports Intel Speed Select Performance Profile.
+"""
+
+from oslo_log import log as logging
+
+from ironic.common import exception
+from ironic.common.i18n import _
+from ironic.drivers import base
+from ironic.drivers.modules import ipmitool
+
+
+LOG = logging.getLogger(__name__)
+INTEL_SST_PP_CONFIG_HEXA_CODES = ['0x00', '0x01', '0x02']
+
+
+class IntelIPMIManagement(ipmitool.IPMIManagement):
+
+ def _validate_input(self, config, sockets):
+ if config not in INTEL_SST_PP_CONFIG_HEXA_CODES:
+ raise exception.InvalidParameterValue(_(
+ "Invalid Intel SST-PP configuration value %(config)s "
+ "specified. Valid values are %(config_list)s.")
+ % {"config": config,
+ "config_list": INTEL_SST_PP_CONFIG_HEXA_CODES})
+ try:
+ socket_count = int(sockets)
+ if socket_count <= 0:
+ raise ValueError
+ except ValueError:
+ raise exception.InvalidParameterValue(_(
+ "Invalid number of socket %(socket)s value specified. "
+ "Expected a positive integer.") % {"socket": sockets})
+
+ @base.deploy_step(priority=200, argsinfo={
+ 'intel_speedselect_config': {
+ 'description': (
+ "Hexadecimal code of Intel SST-PP configuration provided. "
+ "Input value should be string. Accepted values are "
+ "['0x00', '0x01', '0x02']. "
+ ),
+ 'required': True
+ },
+ 'socket_count': {
+ 'description': (
+ "Number of sockets. Input value should be a positive integer."
+ )
+ }
+ })
+ def configure_intel_speedselect(self, task, **kwargs):
+ config = kwargs.get('intel_speedselect_config')
+ socket_count = kwargs.get('socket_count', 1)
+ self._validate_input(config, socket_count)
+ LOG.debug("Going to set Intel SST-PP configuration level %(config)s "
+ "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)
+ raise exception.IPMIFailure(message=msg)