Change-Id: I86a8515e8b0461c10e395c99a993fd553a11f843
4.1 KiB
Developing BIOS Interface
To support a driver specific BIOS interface it is necessary to create
a class inheriting from the BIOSInterface
class:
from ironic.drivers import base
class ExampleBIOS(base.BIOSInterface):
def get_properties(self):
return {}
def validate(self, task):
pass
See /contributor/drivers
for a detailed explanation of
hardware type and interface.
The get_properties
and validate
are methods
that all driver interfaces have. The hardware interface that supports
BIOS settings should also implement the following three methods:
Implement a method named
cache_bios_settings
. This method stores BIOS settings to thebios_settings
table during cleaning operations and updates thebios_settings
table whenapply_configuration
orfactory_reset
are successfully called.from ironic.drivers import base = importutils.try_import('driver.client') driver_client class ExampleBIOS(base.BIOSInterface): def __init__(self): if driver_client is None: raise exception.DriverLoadError( =self.__class__.__name__, driver=_("Unable to import driver library")) reason def cache_bios_settings(self, task): = task.node.id node_id = driver_common.parse_driver_info(task.node) node_info = driver_client.get_bios_settings(node_info) settings = ( create_list, update_list, delete_list, nochange_list objects.BIOSSettingList.sync_node_setting(settings)) if len(create_list) > 0: objects.BIOSSettingList.create( task.context, node_id, create_list)if len(update_list) > 0: objects.BIOSSettingList.save( task.context, node_id, update_list)if len(delete_list) > 0: = [] delete_names for setting in delete_list: delete_names.append(setting.name) objects.BIOSSettingList.delete( task.context, node_id, delete_names)
Note
driver.client
is vendor specific library to control and manage the bare metal hardware, for example: python-dracclient, sushy.Implement a method named
factory_reset
. This method needs to use theclean_step
decorator. It resets BIOS settings to factory default on the given node. It callscache_bios_settings
automatically to update existingbios_settings
table once successfully executed.class ExampleBIOS(base.BIOSInterface): @base.clean_step(priority=0) def factory_reset(self, task): = driver_common.parse_driver_info(task.node) node_info driver_client.reset_bios_settings(node_info)
Implement a method named
apply_configuration
. This method needs to use the clean_step decorator. It takes the given BIOS settings and applies them on the node. It also callscache_bios_settings
automatically to update existingbios_settings
table after successfully applying given settings on the node.class ExampleBIOS(base.BIOSInterface): @base.clean_step(priority=0, argsinfo={ 'settings': { 'description': ( 'A list of BIOS settings to be applied' ),'required': True } })def apply_configuration(self, task, settings): = driver_common.parse_driver_info(task.node) node_info driver_client.apply_bios_settings(node_info, settings)
The
settings
parameter is a list of BIOS settings to be configured. for example:[ { "setting name": { "name": "String", "value": "String" } }, { "setting name": { "name": "String", "value": "String" } }, ... ]