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

Fix(eos_snapshot): eos snapshot produces incorrect json and yaml output #2426

Merged

Conversation

carlbuchmann
Copy link
Member

@carlbuchmann carlbuchmann commented Jan 16, 2023

Change Summary

  • Fix issue in json and yaml templates to loop over commands
  • Collect commands in json format when json or yaml output is selected to generate accurate output data
  • Add delegate to localhost to applicable task to increase performance.

Related Issue(s)

Fixes #2394

Component(s) name

arista.avd.eos_snapshot

Proposed changes

  • For loop with loop.index in json and yaml templates
  • Added new task to gather commands in json format
  • Added delegate_to: localhost to all applicable task

In my testing with ATD environment, even though we collect commands twice, because of delegate_to: localhost we improve overall performance:

Before:

Monday 16 January 2023  20:00:18 +0000 (0:00:02.692)       0:01:01.214 ******** 
=============================================================================== 
eos_snapshot ----------------------------------------------------------- 60.25s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
total ------------------------------------------------------------------ 60.25s
Monday 16 January 2023  20:00:18 +0000 (0:00:02.692)       0:01:01.213 ******** 
=============================================================================== 
arista.avd.eos_snapshot : save collected commands in text files --------------------- 14.33s
arista.avd.eos_snapshot : save collected commands in md files ----------------------- 14.32s
arista.avd.eos_snapshot : run show commands on remote EOS devices ------------------- 11.88s
arista.avd.eos_snapshot : generate table of content report --------------------------- 3.16s
arista.avd.eos_snapshot : Create output directory for each EOS device ---------------- 2.80s
arista.avd.eos_snapshot : Assembling md_fragments ------------------------------------ 2.79s
arista.avd.eos_snapshot : Delete md_fragments directory for each EOS device ---------- 2.69s
arista.avd.eos_snapshot : Create md_fragments directory for each EOS device ---------- 2.64s
arista.avd.eos_snapshot : Generate yaml report for fabric ---------------------------- 1.40s
arista.avd.eos_snapshot : Generate json report for fabric ---------------------------- 1.38s
arista.avd.eos_snapshot : Create required output directories if not present ---------- 0.56s
arista.avd.eos_snapshot : Generate markdown report for fabric ------------------------ 0.28s
Playbook run took 0 days, 0 hours, 1 minutes, 1 seconds

After:

Monday 16 January 2023  19:50:00 +0000 (0:00:00.763)       0:00:44.578 ******** 
=============================================================================== 
eos_snapshot ----------------------------------------------------------- 43.63s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
total ------------------------------------------------------------------ 43.63s
Monday 16 January 2023  19:50:00 +0000 (0:00:00.763)       0:00:44.577 ******** 
=============================================================================== 
arista.avd.eos_snapshot : run show commands on remote EOS devices ------------------- 11.89s
arista.avd.eos_snapshot : run show commands on remote EOS devices with json output -- 10.22s
arista.avd.eos_snapshot : save collected commands in text files ---------------------- 6.49s
arista.avd.eos_snapshot : save collected commands in md files ------------------------ 5.91s
arista.avd.eos_snapshot : Generate json report for fabric ---------------------------- 1.58s
arista.avd.eos_snapshot : Generate yaml report for fabric ---------------------------- 1.52s
arista.avd.eos_snapshot : generate table of content report --------------------------- 1.27s
arista.avd.eos_snapshot : Assembling md_fragments ------------------------------------ 0.85s
arista.avd.eos_snapshot : Create md_fragments directory for each EOS device ---------- 0.77s
arista.avd.eos_snapshot : Delete md_fragments directory for each EOS device ---------- 0.76s
arista.avd.eos_snapshot : Create output directory for each EOS device ---------------- 0.69s
arista.avd.eos_snapshot : Create required output directories if not present ---------- 0.48s
arista.avd.eos_snapshot : Generate markdown report for fabric ------------------------ 0.26s
Playbook run took 0 days, 0 hours, 0 minutes, 44 seconds

went from 60 seconds to 45 seconds to complete the playbook.

How to test

Tested with ATD environment

Checklist

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

+ delegate to localhost
Copy link
Contributor

@JulioPDX JulioPDX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested within ATD and some random commands, seems to work great. Thank you for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eos_snapshot renders yaml and json outputs incorrectly.
3 participants