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:
-
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.
-
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.
-
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:
- Unconfigure Ethernet interfaces to default settings.
- Reconfigure Ethernet interfaces with initial configurations.
- Verifications:
- Retrieve interface information and save the state in a snapshot.
- Verify that the Ethernet interface is down.
- Retrieve interface information again and compare snapshots to ensure consistency.
- Actions:
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 ofshow access-lists
commands.Verify_InterfacesAccounting
: Parses output ofshow interfaces accounting
commands.Verify_IpOspfDatabaseExternal
: Parses output ofshow ip ospf database external
command.
Full Lists of Triggers and Verifications:
- List of Available Triggers (opens in a new tab)
- List of Available Verifications (opens in a new tab)
Further Resources:
-
Creating New Triggers and Verifications:
- Learn how to write new triggers and verifications to enhance testing capabilities.
- Refer to the documentation (opens in a new tab) for detailed instructions.
-
Datafiles for Triggers and Verifications:
- Explore trigger and verification datafiles for additional insights and customization options.
- Refer to the documentation (opens in a new tab) for more information.
By leveraging pyATS triggers and verifications, network engineers can streamline automation tasks, validate network configurations, and ensure network reliability with ease.