Use driver_internal_info methods for other drivers

This change switches the rest of the driver classes to using
set_driver_internal_info, del_driver_internal_info,
timestamp_driver_internal_info node methods for modifying
driver_internal_info.

This completes the switchover to using these methods, outside of unit
tests there should be no direct modifying of driver_internal_info
values.

Change-Id: I17772a3274f09ee02390cc6e941ca302f396a03c
This commit is contained in:
Steve Baker 2021-11-19 15:10:48 +13:00
parent c2d98c2294
commit b66d371fd6
6 changed files with 31 additions and 43 deletions

View File

@ -269,9 +269,7 @@ class CustomAgentDeploy(agent_base.AgentBaseMixin, agent_base.AgentDeployMixin,
# deploy step.
if not task.node.driver_internal_info.get('deployment_reboot'):
manager_utils.node_power_action(task, states.REBOOT)
info = task.node.driver_internal_info
info.pop('deployment_reboot', None)
task.node.driver_internal_info = info
task.node.del_driver_internal_info('deployment_reboot')
task.node.save()
return states.DEPLOYWAIT
@ -600,15 +598,13 @@ class AgentDeploy(CustomAgentDeploy):
# NOTE(mjturek): In the case of local boot using a partition image on
# ppc64* hardware we need to provide the 'PReP_Boot_partition_uuid' to
# direct where the bootloader should be installed.
driver_internal_info = task.node.driver_internal_info
client = agent_client.get_client(task)
partition_uuids = client.get_partition_uuids(node).get(
'command_result') or {}
root_uuid = partition_uuids.get('root uuid')
if root_uuid:
driver_internal_info['root_uuid_or_disk_id'] = root_uuid
task.node.driver_internal_info = driver_internal_info
node.set_driver_internal_info('root_uuid_or_disk_id', root_uuid)
task.node.save()
elif not iwdi:
LOG.error('No root UUID returned from the ramdisk for node '
@ -738,7 +734,7 @@ class AgentRAID(base.RAIDInterface):
create_nonroot_volumes=create_nonroot_volumes)
# Rewrite it back to the node object, but no need to save it as
# we need to just send this to the agent ramdisk.
node.driver_internal_info['target_raid_config'] = target_raid_config
node.set_driver_internal_info('target_raid_config', target_raid_config)
LOG.debug("Calling agent RAID create_configuration for node %(node)s "
"with the following target RAID configuration: %(target)s",

View File

@ -140,16 +140,15 @@ class AgentPower(base.PowerInterface):
self._client.reboot(node)
info = node.driver_internal_info
# NOTE(dtantsur): wipe the agent token, otherwise the rebooted agent
# won't be able to heartbeat. This is mostly a precaution since the
# calling code in conductor is expected to handle it.
if not info.get('agent_secret_token_pregenerated'):
info.pop('agent_secret_token', None)
if not node.driver_internal_info.get(
'agent_secret_token_pregenerated'):
node.del_driver_internal_info('agent_secret_token')
# NOTE(dtantsur): the URL may change on reboot, wipe it as well (but
# only after we call reboot).
info.pop('agent_url', None)
node.driver_internal_info = info
node.del_driver_internal_info('agent_url')
node.save()
LOG.debug('Requested reboot of node %(node)s via the agent, waiting '

View File

@ -962,20 +962,18 @@ def _constructor_checks(driver):
def _allocate_port(task, host=None):
node = task.node
dii = node.driver_internal_info or {}
allocated_port = console_utils.acquire_port(host=host)
dii['allocated_ipmi_terminal_port'] = allocated_port
node.driver_internal_info = dii
node.set_driver_internal_info('allocated_ipmi_terminal_port',
allocated_port)
node.save()
return allocated_port
def _release_allocated_port(task):
node = task.node
dii = node.driver_internal_info or {}
allocated_port = dii.pop('allocated_ipmi_terminal_port', None)
allocated_port = node.del_driver_internal_info(
'allocated_ipmi_terminal_port')
if allocated_port:
node.driver_internal_info = dii
node.save()
console_utils.release_port(allocated_port)
@ -1255,16 +1253,18 @@ class IPMIManagement(base.ManagementInterface):
"""
driver_info = task.node.driver_info
driver_internal_info = task.node.driver_internal_info
node = task.node
ifbd = driver_info.get('ipmi_force_boot_device', False)
driver_info = _parse_driver_info(task.node)
if (strutils.bool_from_string(ifbd)
and driver_internal_info.get('persistent_boot_device')
and driver_internal_info.get('is_next_boot_persistent', True)):
and node.driver_internal_info.get('persistent_boot_device')
and node.driver_internal_info.get('is_next_boot_persistent',
True)):
return {
'boot_device': driver_internal_info['persistent_boot_device'],
'boot_device': node.driver_internal_info[
'persistent_boot_device'],
'persistent': True
}

View File

@ -145,7 +145,5 @@ class IRMCBIOS(base.BIOSInterface):
delete_names)
def _resume_cleaning(self, task):
driver_internal_info = task.node.driver_internal_info
driver_internal_info['cleaning_reboot'] = True
task.node.driver_internal_info = driver_internal_info
task.node.set_driver_internal_info('cleaning_reboot', True)
task.node.save()

View File

@ -288,20 +288,20 @@ def _prepare_boot_iso(task, root_uuid):
for BIOS boot_mode failed.
"""
deploy_info = _parse_deploy_info(task.node)
driver_internal_info = task.node.driver_internal_info
# fetch boot iso
if deploy_info.get('boot_iso'):
boot_iso_href = deploy_info['boot_iso']
if _is_image_href_ordinary_file_name(boot_iso_href):
driver_internal_info['boot_iso'] = boot_iso_href
task.node.set_driver_internal_info('boot_iso', boot_iso_href)
else:
boot_iso_filename = _get_iso_name(task.node, label='boot')
boot_iso_fullpathname = os.path.join(
CONF.irmc.remote_image_share_root, boot_iso_filename)
images.fetch(task.context, boot_iso_href, boot_iso_fullpathname)
driver_internal_info['boot_iso'] = boot_iso_filename
task.node.set_driver_internal_info('boot_iso',
boot_iso_filename)
# create boot iso
else:
@ -329,10 +329,10 @@ def _prepare_boot_iso(task, root_uuid):
kernel_params=kernel_params,
boot_mode=boot_mode)
driver_internal_info['boot_iso'] = boot_iso_filename
task.node.set_driver_internal_info('boot_iso',
boot_iso_filename)
# save driver_internal_info['boot_iso']
task.node.driver_internal_info = driver_internal_info
task.node.save()
@ -1047,8 +1047,8 @@ class IRMCVirtualMediaBoot(base.BootInterface, IRMCVolumeBootMixIn):
manager_utils.node_set_boot_device(task, boot_devices.DISK,
persistent=True)
else:
driver_internal_info = node.driver_internal_info
root_uuid_or_disk_id = driver_internal_info['root_uuid_or_disk_id']
root_uuid_or_disk_id = node.driver_internal_info[
'root_uuid_or_disk_id']
self._configure_vmedia_boot(task, root_uuid_or_disk_id)
# Enable secure boot, if being requested
@ -1073,11 +1073,9 @@ class IRMCVirtualMediaBoot(base.BootInterface, IRMCVolumeBootMixIn):
boot_mode_utils.deconfigure_secure_boot_if_needed(task)
_remove_share_file(_get_iso_name(task.node, label='boot'))
driver_internal_info = task.node.driver_internal_info
driver_internal_info.pop('boot_iso', None)
driver_internal_info.pop('irmc_boot_iso', None)
task.node.del_driver_internal_info('boot_iso')
task.node.del_driver_internal_info('irmc_boot_iso')
task.node.driver_internal_info = driver_internal_info
task.node.save()
_cleanup_vmedia_boot(task)

View File

@ -139,9 +139,8 @@ def backup_bios_config(task):
error=e)
# Save bios config into the driver_internal_info
internal_info = task.node.driver_internal_info
internal_info['irmc_bios_config'] = result['bios_config']
task.node.driver_internal_info = internal_info
task.node.set_driver_internal_info('irmc_bios_config',
result['bios_config'])
task.node.save()
LOG.info('BIOS config is backed up successfully for node %s',
@ -170,14 +169,12 @@ def _restore_bios_config(task):
def _remove_bios_config(task, reboot_flag=False):
"""Remove backup bios config from the node."""
internal_info = task.node.driver_internal_info
internal_info.pop('irmc_bios_config', None)
task.node.del_driver_internal_info('irmc_bios_config')
# NOTE(tiendc): If reboot flag is raised, then the BM will
# reboot and cause a bug if the next clean step is in-band.
# See https://storyboard.openstack.org/#!/story/2002731
if reboot_flag:
internal_info['cleaning_reboot'] = True
task.node.driver_internal_info = internal_info
task.node.set_driver_internal_info('cleaning_reboot', True)
task.node.save()
irmc_info = irmc_common.parse_driver_info(task.node)