Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate -K supported tunables #605

Open
wants to merge 3 commits into
base: dev-collection
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion plugins/modules/tunables.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,14 @@ def modify(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_with_value)
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 +670,42 @@ def modify(module):
results['reboot_required'] = True


def validate_live_update(module, tunable_params_with_value):
'''
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 tunable_params_with_value.keys():
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