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>pull/4420/head
parent
b3273223db
commit
e308176f3e
|
@ -397,12 +397,27 @@ def main():
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
if action == 'compare':
|
if action == 'compare':
|
||||||
result['commands'] = []
|
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:
|
else:
|
||||||
if action_results:
|
if action_results:
|
||||||
load_config(module, action_results)
|
load_config(module, action_results)
|
||||||
result['commands'] = action_results
|
result['commands'] = action_results
|
||||||
result['changed'] = True
|
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)
|
module.exit_json(**result)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue