Handling NIM Operations
This document explains the flow of handling different NIM operations. The main
The flow starts with the main
nim_update
register_client
register_client
build_nim_node
Flow drill down
Handling different NIM operations
First, the main
nim_update
# skip build nim node for actions: master_setup or show
if action != 'master_setup' and action != 'show' and action != 'register_client':
# Build nim node info
build_nim_node(module)
if action == 'register_client':
targets = module.params['new_targets']
register_client(module, targets)
if action == 'update':
params['targets'] = targets
params['lpp_source'] = lpp_source
params['asynchronous'] = asynchronous
params['force'] = force
params['alt_disk_update_name'] = alt_disk_update_name
nim_update(module, params)
Registering a new client
Next, if the action is register_client
main
register_client
if action == 'register_client':
targets = module.params['new_targets']
register_client(module, targets)
Building NIM node information
Then, for actions other than master_setup
register_client
main
build_nim_node
if action != 'master_setup' and action != 'show' and action != 'register_client':
# Build nim node info
build_nim_node(module)
Performing NIM update
Diving into the nim_update
def nim_update(module, params):
"""
Update nim clients (targets) with a specified lpp_source.
In case of updating to the latest TL or SP, the synchronous mode is forced.
Interim fixes that could block the install are removed.
arguments:
module (dict): The Ansible module
params (dict): The module parameters for the command.
note:
Exits with fail_json in case of error
"""
lpp_source = params['lpp_source']
alt_disk_update_name = params['alt_disk_update_name']
targets = params['targets']
async_update = 'no'
if params['asynchronous']:
async_update = 'yes'
Handling asynchronous updates
Next, if the update is asynchronous, the function checks if the specified lpp_source
if async_update == 'yes': # async update
if lpp_source not in results['nim_node']['lpp_source']:
debug_lpp_src = results['nim_node']['lpp_source']
results['msg'] = f'Cannot find lpp_source \'{ debug_lpp_src }\'.'
module.log('NIM - Error: ' + results['msg'])
module.fail_json(**results)
msg_target_list = ','.join(target_list)
msg = f'Asynchronous software customization for client(s) { msg_target_list } with resource { lpp_source }.'
results['meta']['messages'].append(msg)
module.log('NIM - ' + msg)
rc = perform_customization(module, lpp_source, target_list, True)
if rc:
results['msg'] = 'Asynchronous software customization operation failed. See status and meta for details.'
module.log('NIM - Error: ' + results['msg'])
module.fail_json(**results)
Handling synchronous updates
Then, if the update is synchronous, the function retrieves the current oslevel of the targets, determines the new lpp_source
else: # synchronous update
# Get the oslevels of the specified targets only
oslevels = get_oslevels(module, target_list)
for (k, val) in oslevels.items():
if k != 'master':
results['nim_node']['standalone'][k]['oslevel'] = val
else:
results['nim_node']['master']['oslevel'] = val
for target in target_list:
# get current oslevel
cur_oslevel = ''
if target == 'master':
cur_oslevel = results['nim_node']['master']['oslevel']
else:
cur_oslevel = results['nim_node']['standalone'][target]['oslevel']
if (cur_oslevel is None) or (not cur_oslevel.strip()) or cur_oslevel == 'timedout':
msg = f'Invalid oslevel got: \'{ cur_oslevel }\'.'
results['meta'][target]['messages'].append(msg)
module.log(f'NIM - WARNING: On { target } with msg: { msg } ')
results['msg'] += f"{target} - {results['meta'][target]['messages']}"
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human