15
15
iLO Management Interface
18
from oslo.utils import importutils
18
from oslo_config import cfg
19
from oslo_utils import importutils
20
21
from ironic.common import boot_devices
21
22
from ironic.common import exception
22
23
from ironic.common.i18n import _
24
from ironic.common.i18n import _LI
25
from ironic.common.i18n import _LW
23
26
from ironic.conductor import task_manager
24
27
from ironic.drivers import base
25
28
from ironic.drivers.modules.ilo import common as ilo_common
29
32
LOG = logging.getLogger(__name__)
31
ilo_client = importutils.try_import('proliantutils.ilo.ribcl')
34
ilo_error = importutils.try_import('proliantutils.exception')
33
36
BOOT_DEVICE_MAPPING_TO_ILO = {boot_devices.PXE: 'NETWORK',
34
37
boot_devices.DISK: 'HDD',
35
38
boot_devices.CDROM: 'CDROM'
37
40
BOOT_DEVICE_ILO_TO_GENERIC = {v: k
38
41
for k, v in BOOT_DEVICE_MAPPING_TO_ILO.items()}
43
MANAGEMENT_PROPERTIES = ilo_common.REQUIRED_PROPERTIES.copy()
44
MANAGEMENT_PROPERTIES.update(ilo_common.CLEAN_PROPERTIES)
47
cfg.IntOpt('clean_priority_reset_ilo',
49
help='Priority for reset_ilo clean step.'),
50
cfg.IntOpt('clean_priority_reset_bios_to_default',
52
help='Priority for reset_bios_to_default clean step.'),
53
cfg.IntOpt('clean_priority_reset_secure_boot_keys_to_default',
55
help='Priority for reset_secure_boot_keys clean step. This '
56
'step will reset the secure boot keys to manufacturing '
58
cfg.IntOpt('clean_priority_clear_secure_boot_keys',
60
help='Priority for clear_secure_boot_keys clean step. This '
61
'step is not enabled by default. It can be enabled to '
62
'to clear all secure boot keys enrolled with iLO.'),
63
cfg.IntOpt('clean_priority_reset_ilo_credential',
65
help='Priority for reset_ilo_credential clean step. This step '
66
'requires "ilo_change_password" parameter to be updated '
67
'in nodes\'s driver_info with the new password.'),
71
CONF.register_opts(clean_step_opts, group='ilo')
74
def _execute_ilo_clean_step(node, step, *args, **kwargs):
75
"""Executes a particular clean step.
77
:param node: an Ironic node object.
78
:param step: a clean step to be executed.
79
:param args: The args to be passed to the clean step.
80
:param kwargs: The kwargs to be passed to the clean step.
81
:raises: NodeCleaningFailure, on failure to execute step.
83
ilo_object = ilo_common.get_ilo_object(node)
86
clean_step = getattr(ilo_object, step)
87
except AttributeError:
88
# The specified clean step is not present in the proliantutils
89
# package. Raise exception to update the proliantutils package
91
raise exception.NodeCleaningFailure(_("Clean step '%s' not "
92
"found. 'proliantutils' package needs to be updated.") % step)
94
clean_step(*args, **kwargs)
95
except ilo_error.IloCommandNotSupportedError:
96
# This clean step is not supported on Gen8 and below servers.
97
# Log the failure and continue with cleaning.
98
LOG.warn(_LW("'%(step)s' clean step is not supported on node "
99
"%(uuid)s. Skipping the clean step."),
100
{'step': step, 'uuid': node.uuid})
101
except ilo_error.IloError as ilo_exception:
102
raise exception.NodeCleaningFailure(_("Clean step %(step)s failed "
103
"on node %(node)s with error: %(err)s") %
104
{'node': node.uuid, 'step': step, 'err': ilo_exception})
41
107
class IloManagement(base.ManagementInterface):
43
109
def get_properties(self):
44
return ilo_common.REQUIRED_PROPERTIES
110
return MANAGEMENT_PROPERTIES
46
112
def validate(self, task):
47
113
"""Check that 'driver_info' contains required ILO credentials.
162
228
ilo_common.update_ipmi_properties(task)
163
229
ipmi_management = ipmitool.IPMIManagement()
164
230
return ipmi_management.get_sensors_data(task)
232
@base.clean_step(priority=CONF.ilo.clean_priority_reset_ilo)
233
def reset_ilo(self, task):
236
:param task: a task from TaskManager.
237
:raises: NodeCleaningFailure, on failure to execute step.
239
return _execute_ilo_clean_step(task.node, 'reset_ilo')
241
@base.clean_step(priority=CONF.ilo.clean_priority_reset_ilo_credential)
242
def reset_ilo_credential(self, task):
243
"""Resets the iLO password.
245
:param task: a task from TaskManager.
246
:raises: NodeCleaningFailure, on failure to execute step.
248
info = task.node.driver_info
249
password = info.pop('ilo_change_password', None)
252
LOG.info(_LI("Missing 'ilo_change_password' parameter in "
253
"driver_info. Clean step 'reset_ilo_credential' is "
254
"not performed on node %s."), task.node.uuid)
257
_execute_ilo_clean_step(task.node, 'reset_ilo_credential', password)
259
info['ilo_password'] = password
260
task.node.driver_info = info
263
@base.clean_step(priority=CONF.ilo.clean_priority_reset_bios_to_default)
264
def reset_bios_to_default(self, task):
265
"""Resets the BIOS settings to default values.
267
Resets BIOS to default settings. This operation is currently supported
268
only on HP Proliant Gen9 and above servers.
270
:param task: a task from TaskManager.
271
:raises: NodeCleaningFailure, on failure to execute step.
273
return _execute_ilo_clean_step(task.node, 'reset_bios_to_default')
275
@base.clean_step(priority=CONF.ilo.
276
clean_priority_reset_secure_boot_keys_to_default)
277
def reset_secure_boot_keys_to_default(self, task):
278
"""Reset secure boot keys to manufacturing defaults.
280
Resets the secure boot keys to manufacturing defaults. This
281
operation is supported only on HP Proliant Gen9 and above servers.
283
:param task: a task from TaskManager.
284
:raises: NodeCleaningFailure, on failure to execute step.
286
return _execute_ilo_clean_step(task.node, 'reset_secure_boot_keys')
288
@base.clean_step(priority=CONF.ilo.clean_priority_clear_secure_boot_keys)
289
def clear_secure_boot_keys(self, task):
290
"""Clear all secure boot keys.
292
Clears all the secure boot keys. This operation is supported only
293
on HP Proliant Gen9 and above servers.
295
:param task: a task from TaskManager.
296
:raises: NodeCleaningFailure, on failure to execute step.
298
return _execute_ilo_clean_step(task.node, 'clear_secure_boot_keys')