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
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
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
suma_download
# 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
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
compute_rq_name
# 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
# 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