summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/ipmitool.py
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2021-01-20 12:11:54 +0100
committerDmitry Tantsur <dtantsur@protonmail.com>2021-01-28 16:41:45 +0100
commit121b3348c813eb075ca38bd264a9315ee3acc2fe (patch)
treed5d142ae8da3cf56a4bb198c2d42ccc9ba5bbcd0 /ironic/drivers/modules/ipmitool.py
parentfd34d3c437e15dd53c0acac39bdf600123fbb1de (diff)
downloadironic-121b3348c813eb075ca38bd264a9315ee3acc2fe.tar.gz
Refactor vendor detection and add Redfish implementation
Get rid of the TODO in the code and prepare for more management interfaces supporting detect_vendor(). Vendor detecting now runs during transition to manageable and on power state sync (essentially same as before but for all drivers not only IPMI). Update the IPMI implementation to no longer hide exceptions since they're not handled on the upper level. Simplify the regex and fix the docstring. Add the Redfish implementation as a foundation for future vendor-specific changes. Change-Id: Ie521cf2295613dde5842cbf9a053540a40be4b9c
Diffstat (limited to 'ironic/drivers/modules/ipmitool.py')
-rw-r--r--ironic/drivers/modules/ipmitool.py45
1 files changed, 6 insertions, 39 deletions
diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py
index 13391ef4e..9020b8234 100644
--- a/ironic/drivers/modules/ipmitool.py
+++ b/ironic/drivers/modules/ipmitool.py
@@ -939,25 +939,6 @@ class IPMIPower(base.PowerInterface):
call).
"""
- # NOTE(TheJulia): Temporary until we promote detect_vendor as
- # a higher level management method and able to automatically
- # run detection upon either power state sync or in the enrollment
- # to management step.
- try:
- properties = task.node.properties
- if not properties.get('vendor'):
- # We have no vendor stored, so we'll go ahead and
- # call to store it.
- vendor = task.driver.management.detect_vendor(task)
- if vendor:
- task.upgrade_lock()
- props = task.node.properties
- props['vendor'] = vendor
- task.node.properties = props
- task.node.save()
- except exception.UnsupportedDriverExtension:
- pass
-
driver_info = _parse_driver_info(task.node)
return _power_status(driver_info)
@@ -1244,12 +1225,7 @@ class IPMIManagement(base.ManagementInterface):
@METRICS.timer('IPMIManagement.detect_vendor')
def detect_vendor(self, task):
- """Detects, stores, and returns the hardware vendor.
-
- If the Node object ``properties`` field does not already contain
- a ``vendor`` field, then this method is intended to query
- Detects the BMC hardware vendor and stores the returned value
- with-in the Node object ``properties`` field if detected.
+ """Detects and returns the hardware vendor.
:param task: A task from TaskManager.
:raises: InvalidParameterValue if an invalid component, indicator
@@ -1258,20 +1234,11 @@ class IPMIManagement(base.ManagementInterface):
:returns: String representing the BMC reported Vendor or
Manufacturer, otherwise returns None.
"""
- try:
- driver_info = _parse_driver_info(task.node)
- out, err = _exec_ipmitool(driver_info, "mc info")
- re_obj = re.search("Manufacturer Name .*: (.+)", out)
- if re_obj:
- bmc_vendor = str(re_obj.groups('')[0]).lower().split(':')
- # Pull unparsed data and save the vendor
- return bmc_vendor[-1]
- except (exception.PasswordFileFailedToCreate,
- processutils.ProcessExecutionError) as e:
- LOG.warning('IPMI get boot device failed to detect vendor '
- 'of bmc for %(node)s. Error %(err)s',
- {'node': task.node.uuid,
- 'err': e})
+ driver_info = _parse_driver_info(task.node)
+ out, err = _exec_ipmitool(driver_info, "mc info")
+ re_obj = re.search("Manufacturer Name *: (.+)", out)
+ if re_obj:
+ return re_obj.group(1).lower()
@METRICS.timer('IPMIManagement.get_sensors_data')
def get_sensors_data(self, task):