Domain 3 of 4 · Chapter 4 of 6

Change Validation with pyATS

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing Designing, Deploying and Managing Network Automation Systems premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • The pre, post, diff pattern
  • The testbed: how pyATS reaches the device
  • Structured state: parse() and learn()
  • Diffing structured state, and why volatile fields vanish
  • Scripting it: AEtest testcases and jobs
  • Exam-pattern recognition

Capturing and validating state: parse vs learn vs AEtest job

Approachpyats parsepyats learnAEtest + job
ScopeOne show commandA whole feature (several commands)Many features plus explicit checks
OutputStructured dict (JSON)Ops object / snapshot filesPass/fail report + archive
VerdictNone; you read itNone until you diff two snapshotsBuilt-in pass/fail per Testcase
Python neededNo (CLI) or device.parse()No (CLI) or device.learn()Yes for the testscript, run via CLI
Best forQuick look at one valueBefore/after change validationRepeatable, gated CI validation

Decision tree

1. Gate a CI pipeline?need a pass / fail verdictAEtest testscriptrun by pyats run jobyesno2. Whole feature,before vs after?pyats learn pre/ + post/then pyats diffyesno3. One command'sstructured output?pyats parse "<show cmd>"structured JSONyesAlways: set the testbed os correctlywrong os selects the wrong parser or raises ParserNotFound

Cheat sheet

  • Testbed YAML structure
  • device.connect() opens the session
  • Keep testbed credentials out of git
  • The os key selects plugins
  • learn() returns a structured Ops object
  • Diff(pre, post) validates a change
  • Structured diff masks volatile fields
  • learn('config') snapshots running config
  • Excluding known-dynamic keys
  • parse() returns a structured dict
  • parse() is granular, learn() is feature-wide
  • Parsers are indexed by command and os
  • AEtest script sections
  • Asserting on parsed structure
  • Job files orchestrate testscripts
  • pyats learn snapshots to files
  • pyats diff compares two snapshots
  • pyats parse from the shell
  • The end-to-end CLI validation flow

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. pyATS on DevNet — stateful validation with learn and diff
  2. pyATS & Genie — Example Solutions (CLI learn/diff, run job)
  3. pyATS — Connection to Devices (testbed, os key, credentials)
  4. pyATS & Genie — Parsing Device Output (parse, ParserNotFound)
  5. pyATS & Genie — API reference (Diff exclude, AEtest)