From e308176f3eab75b99c7d174bcb0da91723ef81fe Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Wed, 20 Sep 2017 10:06:38 +0530 Subject: [PATCH] fix write_on_file nxos_snapshot (#30545) * fix write_on_file nxos_snapshot Signed-off-by: Trishna Guha * some more logic Signed-off-by: Trishna Guha --- lib/ansible/modules/network/nxos/nxos_snapshot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ansible/modules/network/nxos/nxos_snapshot.py b/lib/ansible/modules/network/nxos/nxos_snapshot.py index fef3e52b25..d486b11551 100644 --- a/lib/ansible/modules/network/nxos/nxos_snapshot.py +++ b/lib/ansible/modules/network/nxos/nxos_snapshot.py @@ -397,12 +397,27 @@ def main(): if not module.check_mode: if action == 'compare': result['commands'] = [] + + if module.params['path'] and comparison_results_file: + snapshot1 = module.params['snapshot1'] + snapshot2 = module.params['snapshot2'] + compare_option = module.params['compare_option'] + command = 'show snapshot compare {0} {1} {2}'.format(snapshot1, snapshot2, compare_option) + content = execute_show_command(command, module)[0] + if content: + write_on_file(content, comparison_results_file, module) else: if action_results: load_config(module, action_results) result['commands'] = action_results result['changed'] = True + if action == 'create' and module.params['path']: + command = 'show snapshot | include {}'.format(module.params['snapshot_name']) + content = execute_show_command(command, module)[0] + if content: + write_on_file(content, module.params['snapshot_name'], module) + module.exit_json(**result) if __name__ == '__main__':