Skip to main content

VIOS Health Check Flow

This document explains the flow of the main function in the (ansible-power-aix) plugins/modules/nim_vios_hc.py module. The main function orchestrates the process of performing a health check on VIOS targets. It involves building a target list, checking the health status of each target, collecting necessary UUIDs, and running the health check.

The flow starts by building a list of targets from the module parameters. If the list is empty, a warning is logged. Next, the health status of each target is checked and logged. If UUIDs for the targets are not available, they are collected. Finally, a health check is performed to determine if the targets can support a rolling update, and the results are logged.

Flow drill down


Building the Target List

First, we retrieve the list of targets from the module parameters and build the target list. If the target list is empty, a warning is logged, and the process continues. This step ensures that we have a valid list of targets to perform the health check on.

    targets = module.params['targets']

OUTPUT.append(f'VIOS Health Check operation for {targets}')

target_list = []
targets_health_status = {}

# Build nim node info
build_nim_node(module)

ret = check_vios_targets(module, targets)
if (ret is None) or (not ret):
OUTPUT.append(' Warning: Empty target list')
module.log(f'[WARNING] Empty target list: "{targets}"')
else:
target_list = ret
OUTPUT.append(f' Targets list: {target_list}')
module.debug(f'Targets list: {target_list}')


Checking the Health Status of VIOS Targets

Next, we call the health_check function to assess the health status of each VIOS target. The results are logged and stored in the results dictionary. This step is crucial as it determines whether the VIOS targets are in a healthy state and can support a rolling update operation.

        targets_health_status = health_check(module, target_list)

OUTPUT.append('VIOS Health Check status:')
module.log('VIOS Health Check status:')
for vios_key, vios_health_status in targets_health_status.items():
OUTPUT.append(f" {vios_key} : {vios_health_status}")
module.log(f' {vios_key} : {vios_health_status}')


Collecting VIOS UUIDs

Diving into the health_check function, we first check if the UUIDs for the VIOS targets are available. If not, we call the vios_health_init function to collect the UUIDs. This step ensures that we have the necessary UUIDs to perform the health check.

        # if needed call vios_health_init to get the UUIDs value
if 'vios_uuid' not in NIM_NODE['nim_vios'][vios1] \
or tup_len == 2 and 'vios_uuid' not in NIM_NODE['nim_vios'][vios2]:
OUTPUT.append(' Getting VIOS UUID')

ret = vios_health_init(module, hmc_id, hmc_ip)
if ret != 0:
OUTPUT.append(f' Unable to get UUIDs of {vios1} and {vios2}, ret: {ret}')
module.log(f"[WARNING] Unable to get UUIDs of {vios1} and {vios2}, ret: {ret}")
health_tab[vios_key] = 'FAILURE-HC'
continue


Running the Health Check

Then, we run the vios_health function to check if the VIOS targets can support a rolling update. The results of the health check are logged and stored in the health_tab dictionary. This step is critical as it determines the success or failure of the health check for each VIOS target.

            # run the vios_health check for the vios tuple
vios_uuid.append(NIM_NODE['nim_vios'][vios1]['vios_uuid'])
if tup_len == 2:
vios_uuid.append(NIM_NODE['nim_vios'][vios2]['vios_uuid'])

mgmt_uuid = NIM_NODE['nim_vios'][vios1]['cec_uuid']

OUTPUT.append(' Checking if we can update the VIOS')
ret = vios_health(module, mgmt_uuid, hmc_ip, vios_uuid)

if ret == 0:
OUTPUT.append(' Health check succeeded')
module.log(f"Health check succeeded for {vios_key}")
health_tab[vios_key] = 'SUCCESS-HC'
else:
OUTPUT.append(' Health check failed')
module.log(f"Health check failed for {vios_key}")
health_tab[vios_key] = 'FAILURE-HC'

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human