111
111
'dual_bridge': ['ipmitool', '-m', '0', '-b', '0', '-t', '0',
112
112
'-B', '0', '-T', '0', '-h']}
114
# Note(TheJulia): This string is hardcoded in ipmitool's lanplus driver
115
# and is substituted in return for the error code received from the IPMI
116
# controller. As of 1.8.15, no internationalization support appears to
117
# be in ipmitool which means the string should always be returned in this
118
# form regardless of locale.
119
IPMITOOL_RETRYABLE_FAILURES = ['insufficient resources for session']
115
122
def _check_option_support(options):
116
123
"""Checks if the specific ipmitool options are supported on host.
335
342
args.append(driver_info[name])
337
344
# specify retry timing more precisely, if supported
346
(CONF.ipmi.retry_timeout // CONF.ipmi.min_command_interval), 1)
338
348
if _is_option_supported('timing'):
340
(CONF.ipmi.retry_timeout // CONF.ipmi.min_command_interval), 1)
341
349
args.append('-R')
342
350
args.append(str(num_tries))
344
352
args.append('-N')
345
353
args.append(str(CONF.ipmi.min_command_interval))
347
# 'ipmitool' command will prompt password if there is no '-f' option,
348
# we set it to '\0' to write a password file to support empty password
349
with _make_password_file(driver_info['password'] or '\0') as pw_file:
352
args.extend(command.split(" "))
355
end_time = (time.time() + CONF.ipmi.retry_timeout)
358
num_tries = num_tries - 1
353
359
# NOTE(deva): ensure that no communications are sent to a BMC more
354
360
# often than once every min_command_interval seconds.
355
361
time_till_next_poll = CONF.ipmi.min_command_interval - (
356
362
time.time() - LAST_CMD_TIME.get(driver_info['address'], 0))
357
363
if time_till_next_poll > 0:
358
364
time.sleep(time_till_next_poll)
360
out, err = utils.execute(*args)
362
LAST_CMD_TIME[driver_info['address']] = time.time()
365
# Resetting the list that will be utilized so the password arguments
366
# from any previous execution are preserved.
368
# 'ipmitool' command will prompt password if there is no '-f'
369
# option, we set it to '\0' to write a password file to support
371
with _make_password_file(
372
driver_info['password'] or '\0'
374
cmd_args.append('-f')
375
cmd_args.append(pw_file)
376
cmd_args.extend(command.split(" "))
378
out, err = utils.execute(*cmd_args)
380
except processutils.ProcessExecutionError as e:
381
with excutils.save_and_reraise_exception() as ctxt:
382
err_list = [x for x in IPMITOOL_RETRYABLE_FAILURES
384
if ((time.time() > end_time) or
387
LOG.error(_LE('IPMI Error while attempting '
388
'"%(cmd)s" for node %(node)s. '
391
'node': driver_info['uuid'],
397
LOG.warning(_LW('IPMI Error encountered, retrying '
398
'"%(cmd)s" for node %(node)s. '
401
'node': driver_info['uuid'],
406
LAST_CMD_TIME[driver_info['address']] = time.time()
366
409
def _sleep_time(iter):