Skip to content

Commit

Permalink
Validate -K supported tunables (#605)
Browse files Browse the repository at this point in the history
* Validate -K supported tunables

Signed-off-by: Nitish K Mishra <[email protected]>

* Lintings

Signed-off-by: Nitish K Mishra <[email protected]>

* Fix for tunables which are not live supported tunables

Signed-off-by: Nitish K Mishra <[email protected]>

---------

Signed-off-by: Nitish K Mishra <[email protected]>
  • Loading branch information
nitismis authored Jan 31, 2025
1 parent 5877aed commit a397462
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions plugins/modules/tunables.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,14 @@ def reset(module):

live_update = getOSlevel(module)
if live_update and component in ['vmo', 'no']:
cmd += '-K '
valid_live_update_tunables = validate_live_update(module, tunable_params)
if valid_live_update_tunables:
if change_type != "reboot":
results['msg'] = "In AIX 7.3, if you want to change tunables which support"
results['msg'] += "live update flag, -K, then provide change_type as reboot."
module.fail_json(**results)
else:
cmd += '-K '

# -p when used in combination with -o, -d or -D, makes changes apply to both current and
# reboot values, that is, turns on the updating of the /etc/tunables/nextboot file in addition
Expand Down Expand Up @@ -635,7 +642,17 @@ def modify(module):

live_update = getOSlevel(module)
if live_update and component in ['vmo', 'no']:
cmd += '-K '
to_be_validated = []
for params in tunable_params_with_value.keys():
to_be_validated.append(params)
valid_live_update_tunables = validate_live_update(module, to_be_validated)
if valid_live_update_tunables:
if change_type != "reboot":
results['msg'] = "In AIX 7.3, if you want to change tunables which support"
results['msg'] += "live update flag, -K, then provide change_type as reboot."
module.fail_json(**results)
else:
cmd += '-K '

# include the tunables to be modified and their new values in command
for tunable, value in tunable_params_with_value.items():
Expand Down Expand Up @@ -663,6 +680,42 @@ def modify(module):
results['reboot_required'] = True


def validate_live_update(module, to_be_validated):
'''
Checks that all tunables support -K option in AIX 7.3
arguments:
module: The ansible module
tunable_params_with_value (dict): Tunable parameters and values
note:
Exits with fail_json in case of both supported and non supported tunables are present
return:
True if all tunables are -K supported
'''

contain_supported_tunables = False
contain_non_supported_tunables = False

supported_tunables = ["ame_cpus_per_pool", "kernel_heap_size", "msem_nlocks",
"num_locks_per_semid", "vmm_klock_mode", "timer_wheel_tick",
"extendednetstats", "lo_perf", "ipqmaxlen", "arptab_bsiz",
"arptab_nb", "tcp_inpcb_hashtab_siz", "udp_inpcb_hashtab_siz",
"use_sndbufpool", "udp_recv_perf", "udp_send_perf", "rtentry_lock_complex"]

for params in to_be_validated:
if params in supported_tunables:
contain_supported_tunables = True
else:
contain_non_supported_tunables = True
if contain_supported_tunables and contain_non_supported_tunables:
results['msg'] = "Live update flag -K supported and non supported tunables are used together."
results['msg'] += "Please use those tunables separately."
module.fail_json(**results)

if contain_supported_tunables and not contain_non_supported_tunables:
return True


def main():
'''
Main function
Expand Down

0 comments on commit a397462

Please sign in to comment.