Devnet
pyATS
10 Command Line

Using the pyATS Command Line Interface (CLI)

The pyATS Command Line Interface (CLI), also known as the Genie Command Line Interface (CLI), is a powerful tool within the pyATS Library SDK. It enables network engineers to access and utilize pyATS Library functionality directly from a Linux terminal, without requiring extensive Python knowledge. Let's explore the key features and commands available in the pyATS CLI:

Overview of Key Features:

  1. Simplified Automation: The pyATS CLI simplifies complex network operations and tasks, allowing users to perform actions such as gathering device information, running tests, and generating reports with ease.

  2. Accessible to Non-Programmers: Even users with limited programming experience can leverage the pyATS CLI to automate and manage network tasks effectively.

Available Commands:

1. genie (or pyats)

  • Displays a list of available subcommands and their descriptions.
genie

2. genie diff (or pyats diff)

  • Compares Python data structures generated by genie parse or genie learn.
genie diff

3. genie dnac (or pyats dnac)

  • Communicates with a Cisco DNA Center (DNAC) host through the REST API.
genie dnac

4. genie learn

  • Performs stateful network validation across multiple devices, storing learned data in a structured format.
genie learn

5. genie parse

  • Runs and parses show commands on devices defined in the testbed.
genie parse

6. genie run

  • Executes all pyATS and Genie Python functionality directly from the Linux CLI.
genie run

7. genie shell

  • Loads a testbed YAML file and Pickle file into Genie testbed objects, providing an interactive Python shell.
genie shell

Additional Commands:

- genie create

  • Provides functionality for creating parsers, testbeds, and triggers using the pyATS framework.
genie create

- genie create testbed

  • Creates a testbed YAML file from Excel or CSV files containing device data.
genie create testbed

- genie create parser

  • Generates a template for a new Genie parser, facilitating custom parser creation.
genie create parser

- genie create trigger

  • Generates a template for a new Genie trigger, simplifying custom trigger creation.
genie create trigger

- genie create project

  • Creates a project template using Cookiecutter, including files for testcases.
genie create project --name <project_name>

Example Commands:

  • To compare snapshots of network states:

    genie diff --snapshot1 <snapshot1_path> --snapshot2 <snapshot2_path>
  • To communicate with Cisco DNA Center:

    genie dnac --host <dnac_host> --user <username> --password <password>
  • To perform stateful network validation:

    genie learn --testbed-file <testbed_file>
  • To run and parse show commands:

    genie parse "show version" --testbed-file <testbed_file> --devices <device_name>
  • To execute pyATS and Genie Python functionality:

    genie run --script <script_path>
  • To load a testbed YAML file into an interactive Python shell:

    genie shell --testbed-file <testbed_file>

By leveraging these commands, network engineers can efficiently automate network tasks and perform comprehensive network validation using the pyATS Command Line Interface.