Devnet
pyATS
11 Triggers and Verifications

Understanding pyATS Triggers and Verifications

The pyATS Libraries (formerly Genie) offer a comprehensive set of tools for network automation and testing, including modules for triggers and verifications. These modules allow network engineers to automate testing tasks efficiently. Let's delve deeper into pyATS triggers and verifications, their functionalities, and how to leverage them for network automation:

Key Concepts:

  1. Triggers: Actions or sequences of actions that bring about changes in device state or configuration. Triggers can include additions, removals, or modifications of configurations, repairs to protocols or interfaces, high-availability events, etc.

  2. Verifications: Executions of commands to retrieve the current state of a device. These verifications check for unexpected changes and compare device states before and after triggers are applied.

  3. Testcases: Collections of triggers and their associated verifications, along with optional setup and cleanup procedures. A testcase typically includes at least one trigger.

Usage in Testcases:

  • Testcase Execution Flow: Triggers perform actions on devices, followed by verifications to check if the desired changes have taken effect.

  • Reusable Testcases: Triggers and verifications can be considered reusable testcases. They can be embedded within Python scripts and invoked as Python libraries, enabling easy integration and reusability.

Example Scenario: Resetting an Ethernet Interface

  • Trigger: TriggerUnconfigConfigEthernetInterface
    • Actions:
      1. Unconfigure Ethernet interfaces to default settings.
      2. Reconfigure Ethernet interfaces with initial configurations.
    • Verifications:
      1. Retrieve interface information and save the state in a snapshot.
      2. Verify that the Ethernet interface is down.
      3. Retrieve interface information again and compare snapshots to ensure consistency.

Available Triggers and Verifications:

Sample Triggers:

  • TriggerClearCountersInterfaceAll: Clears counters on all interfaces.
  • TriggerShutNoShutEthernetInterface: Shuts and unshuts dynamically learned Ethernet interfaces.
  • TriggerSwitchover: Performs a switchover on a device.

Sample Verifications:

  • Verify_AccessLists: Parses output of show access-lists commands.
  • Verify_InterfacesAccounting: Parses output of show interfaces accounting commands.
  • Verify_IpOspfDatabaseExternal: Parses output of show ip ospf database external command.

Full Lists of Triggers and Verifications:

Further Resources:

  • Creating New Triggers and Verifications:

  • Datafiles for Triggers and Verifications:

By leveraging pyATS triggers and verifications, network engineers can streamline automation tasks, validate network configurations, and ensure network reliability with ease.