LinuxCommandLibrary

pyats-shell

Launch pyATS interactive shell for test automation

TLDR

Open pyATS shell with a defined Testbed file

$ pyats shell --testbed-file [path/to/testbed.yaml]
copy

Open pyATS shell with a defined Pickle file
$ pyats shell --pickle-file [path/to/pickle.file]
copy

Open pyATS with IPython disabled
$ pyats shell --no-ipython
copy

SYNOPSIS

pyats-shell [OPTIONS] [ARGUMENTS]

PARAMETERS

--testbed-file <file>, -t <file>
    Specifies the YAML testbed file to load into the shell. This file defines network devices, their types, credentials, and connection details.

--script-file <file>
    Loads an external Python script into the shell's namespace at startup. This allows functions, classes, and variables defined in the script to be directly accessible and used interactively.

--no-connect
    Prevents the shell from automatically connecting to devices defined in the loaded testbed upon startup. Connections must then be initiated manually within the shell, for example, by calling device.connect().

--log-level <level>
    Sets the logging verbosity level for pyATS operations within the shell. Common levels include DEBUG, INFO, WARNING, ERROR, and CRITICAL.

--console-log
    Enables logging output directly to the console during interactive sessions, providing real-time feedback on pyATS actions.

--help
    Displays a comprehensive help message for the pyats-shell command and exits.

--version
    Shows the current pyATS shell version information and exits.

DESCRIPTION

The pyats-shell command provides an interactive Python shell environment specifically designed for the Cisco pyATS (Python Automation Test System) framework. It is extensively used for network device automation, testing, and debugging. When launched, it can automatically load specified testbed configurations, making testbed objects, device instances, and pyATS APIs readily available for interactive manipulation. This enables engineers to directly interact with network devices, execute pyATS functions (like connecting, learning, executing commands, configuring), and debug test scripts in a live environment. It's an indispensable tool for developing, verifying, and troubleshooting pyATS-based network automation solutions.

CAVEATS

The pyats-shell command is part of the pyATS framework and requires a working pyATS installation. It is specifically tailored for network automation and interaction with devices managed by pyATS, and is not a general-purpose Linux shell. Its effectiveness heavily relies on having correctly configured testbed files and network access to the devices.
Proficiency in Python and familiarity with pyATS API concepts are often necessary for effective use.

INTERACTIVE USAGE

Once inside the pyats-shell, users can directly access loaded testbed objects (e.g., testbed.devices['my_device']) and call methods on them. For instance, device.connect() to establish a connection, device.learn('os') to gather operating system information, or device.execute('show version') to run CLI commands. This interactive capability makes it a powerful tool for rapid prototyping, troubleshooting, and ad-hoc device interaction.

IMPORTANCE OF TESTBED FILES

A well-structured testbed file (typically a YAML file) is fundamental for leveraging the full power of pyats-shell. It defines the network topology, including device names, types, operating systems, connection protocols, credentials, and other essential details. Without a properly configured testbed, the shell's ability to interact with network devices is severely limited, as it lacks the necessary information to establish connections or identify targets.

HISTORY

The pyATS (Python Automation Test System) framework, including the pyats-shell component, was initially developed by Cisco for internal use to automate testing and validation of network devices and software. Recognizing its broad utility, Cisco later open-sourced pyATS, making it available to the wider network automation community. The pyats-shell was conceived to provide an intuitive, interactive environment, allowing engineers to rapidly prototype, debug, and execute pyATS functionalities against live networks, significantly streamlining the development and testing workflow for network automation engineers.

SEE ALSO

pyats(1), pyats run(1), pyats clean(1), pyats parse(1), python(1)

Copied to clipboard