fix write_on_file nxos_snapshot (#30545)

* fix write_on_file nxos_snapshot

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* some more logic

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-09-20 10:06:38 +05:30 committed by GitHub
parent b3273223db
commit e308176f3e

View file

@ -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__':