Skip to main content

NIM Resource Overview

NIM Resource Overview

NIM Resource refers to various types of resources managed by the Network Installation Manager (NIM) on AIX systems. These resources include 'spot', lpp_source, 'script', bosinst_data, image_data, installp_bundle, fix_bundle, resolv_conf, exclude_files, and adapter_def. The module facilitates the display, creation, and deletion of these NIM resource objects.

Displaying NIM Resources

The res_show function is used to display NIM resources, fetching general information about the resource object class.


The res_show function displays NIM resources by fetching general information about the resource object class. It constructs a command to list NIM resources and executes it.

def res_show(module):
'''
Show nim resources.

arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
updated results dictionary.
'''

cmd = '/usr/sbin/lsnim -l'
name = module.params['name']
object_type = module.params['object_type']

# This module will only show general information about the resource
# object class.
if not object_type and not name:
cmd += ' -c resources'

Creating NIM Resources

The res_create function defines a new NIM resource object, requiring parameters such as name, object type, and attributes.


The res_create function defines a new NIM resource object. It constructs a command to create the resource based on the provided parameters and executes it.

def res_create(nim_cmd, module):
'''
Define a NIM resource object.

arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
updated results dictionary.
'''

opts = ""
name = module.params['name']
object_type = module.params['object_type']
attributes = module.params['attributes']

if object_type:
if object_type == "res_group":
cmd = nim_cmd + ' -o define '
else:

Deleting NIM Resources

The res_delete function removes a specified NIM resource object.


The res_delete function removes a specified NIM resource object. It constructs a command to delete the resource and executes it.

def res_delete(nim_cmd, module):
'''
Remove a NIM resource object.

arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
updated results dictionary.
'''

name = module.params['name']
cmd = nim_cmd + f' -o remove {name}'

if module.check_mode:
results['msg'] = f'Command \'{cmd}\' in preview mode, execution skipped.'
return

return_code, stdout, stderr = module.run_command(cmd)

Fetching NIM Resource Contents

The res_showres function fetches the contents of valid NIM object resources, specifically for 'spot' and lpp_source types.


The res_showres function fetches the contents of valid NIM object resources. It constructs a command to retrieve the resource contents and executes it.

def res_showres(module, resource, info):
"""
Fetch contents of valid NIM object resource

arguments:
module (dict): The Ansible module
resource (str): NIM resource name
info (info): NIM resource attributes information
return:
contents: (dict): NIM resource contents
"""
fail_msg = f'Unable to fetch contents of {resource}.'
max_retries = module.params['showres']['max_retries']
retry_wait_time = module.params['showres']['max_retries']
contents = {}
results['testing'] = ""
# 0042-001 nim: processing error encountered on "master":,
# 0042-207 m_showres: Unable to allocate the spot_72V_2114 resource to master.
pattern = r"0042-207"

if info['type'] in NIM_SHOWRES:

 

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