Skip to main content

SUMA Operation Flow

In this document, we will explain the flow of the main function in the (ansible-power-aix) plugins/modules/nim_suma.py module. The process involves initializing and validating SUMA parameters, running the SUMA download or preview, validating target machines, computing the request type, computing the SUMA request name, and finally building and executing the SUMA command.

The flow starts with initializing and validating the SUMA parameters to ensure all necessary inputs are correctly set. Then, it runs the SUMA download or preview action based on these parameters. Next, it validates the target machines and computes the request type to ensure everything is correctly specified. After that, it computes the SUMA request name based on metadata information. Finally, it builds and executes the SUMA command to perform the actual operation of previewing or downloading software updates.

Flow drill down


Initializing and validating SUMA parameters

First, the main function initializes the SUMA parameters and validates the input arguments. This step ensures that all necessary parameters for the SUMA operation are correctly set up and validated before proceeding with the download or preview action.

def main():
global results
suma_params = {}

module = AnsibleModule(
argument_spec=dict(
action=dict(required=False,
choices=['download', 'preview'],
type='str', default='preview'),
targets=dict(required=True, type='list', elements='str'),
oslevel=dict(required=False, type='str', default='Latest'),
lpp_source_name=dict(required=False, type='str'),
download_dir=dict(required=False, type='path'),
download_only=dict(required=False, type='bool', default=False),
extend_fs=dict(required=False, type='bool', default=True),
description=dict(required=False, type='str'),
metadata_dir=dict(required=False, type='path', default='/var/adm/ansible/metadata'),
),
supports_check_mode=True
)



Running SUMA download or preview

Next, the main function calls suma_download to execute the SUMA download or preview action based on the initialized parameters. This step is crucial as it performs the core functionality of downloading or previewing software updates.

    # Run Suma preview or download
suma_download(module, suma_params)

# Exit
msg = f'Suma {action} completed successfully'


Validating target machines and computing request type

Moving to the suma_download function, it first validates the target machines and computes the request type. This step ensures that the target machines are correctly specified and the request type is valid, which is essential for the subsequent SUMA operations.

    if not targets_list:
if req_oslevel == 'Latest':
msg = 'Oslevel target could not be empty or equal "Latest" when' \
' target machine list is empty'
module.log(msg)
results['msg'] = msg
module.fail_json(**results)
elif re.match(r"^([0-9]{4}-[0-9]{2})(-00|-00-0000)$", req_oslevel):
msg = 'When no Service Pack is provided, a target machine list is required'
module.log(msg)
results['msg'] = msg
module.fail_json(**results)
else:
if re.match(r"^([0-9]{4})(|-00|-00-00|-00-00-0000)$", req_oslevel):
msg = 'Specify a non 0 value for the Technical Level or the Service Pack'
module.log(msg)
results['msg'] = msg
module.fail_json(**results)


Computing SUMA request name

Then, the suma_download function calls compute_rq_name to compute the SUMA request name based on the metadata information. This step is important as it determines the specific software update request name that will be used in the SUMA operation.

    # compute SUMA request name based on metadata info
rq_name = compute_rq_name(module, suma_params, rq_type, suma_params['req_oslevel'], clients_oslevel)
suma_params['RqName'] = rq_name
module.debug(f"Suma req Name: {rq_name}")


Building and executing SUMA command

Finally, the suma_download function builds and executes the SUMA command for preview. This step performs the actual SUMA operation, either previewing or downloading the software updates based on the specified parameters.

    # SUMA command for preview
stdout = suma_command(module, 'Preview', suma_params)
module.debug(f"SUMA preview stdout:{stdout}")


 

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