Git Product home page Git Product logo

tcli's Introduction

TCLI – TextFSM Device CLI

This is not an officially supported Google product

Overview

TCLI is a client interface for issuing commands to any number of devices which supports batch and interactive modes and multiple display formats.

Handy for performing, troubleshooting, and generating reports from arbitrarily large numbers of live devices.

Cautions and Caveats

Empowers users to run commands across potentially large sets of devices with very few restrictions – please use wisely and cautiously.

Does not support commands that are multi-part, or have non-discrete responses (e.g. the ping command).

Note
You can still use commands like ping count 5 127.0.0.1 or monitor traffic brief count 2 that do not require a Ctrl + C to terminate.

Documentation

Setup

TCLI requires some setup but can be run straight out of the box using some fictitious devices and a limited set of commands that produce canned output:

Devices

  • device_a
  • device_b
  • device_c

Commands

  • show version
  • show vlan

To try TCLI, execute the main.py script in the parent directory.

python3 main.py

To use it for your environment it will need an additional library to call your device accessor system and also needs to retrieve a device list from what system you are using to inventory those devices.

The "canned" example has been included as the default inventory_csv.py to illustrate how to do this. Please refer to the comments at the start of that file for instructions on customizing your environment.

We hope that contributors will submit libraries for some of the more popular open source device accessor methods – notch, rancid and inventory systems – DNS, SQL.

Once setup for your environment, then the Power Users guide will get you up and running fast!
TCLI Power Users Guide

The structured format for device output is enable via TextFSM. Follow the instructions below to create new templates to display output in CSV or other structured formats.
TextTableFSM

There are open source template repositories such as ntc-templates that provide structured output for many common commands.

Before contributing

If you are not a Google employee, our lawyers insist that you sign a Contributor Licence Agreement (CLA).

If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an individual CLA. Individual CLAs can be signed electronically. If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA. The Google CLA is based on Apache's. Note that unlike some projects (notably GNU projects), we do not require a transfer of copyright. You still own the patch.

Unfortunately, even the smallest patch needs a CLA.

tcli's People

Contributors

astiliano avatar banz04 avatar bnjf avatar harro avatar matthosch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tcli's Issues

Group records with common header fields

If using a structured display format such as 'csv' then records are stored until the record header changes. At which point the table is flushed to output.

Alternative would be to store all records indexed by header content and then print once all command responses are received. This would minimise number of tables and ensure that like rows are grouped together into the smallest set of common tables.

Autocomplete could work better

Target device auto completion is achieved via the textfsm template selection process:

https://github.com/google/textfsm/blob/master/testdata/default_index

Autocomplete works across the set of candidate 'Commands'. We reuse the template matching logic for the autocompletion (even if we are not making use of the template to displaying the data), hence we get it for free, and we avoid having to know anything about the target device. As soon as the template selection is exhausted, or we hit a regexp entry like .* then the autocomplete dries up. This is by design.

If we assume a regexp in default_index represents a single argument, then it should be possible to resume command completion.
So entries like

show .* optical
show .* detail

Would give valid completions for:

show xe-0-0-0

Attribute discovery for filtering

Attributes that can be matched against can be inspected by either using tab completion on the /attributes command or by viewing the inventory output (/inventory).

These are static in the config but should ideally be derived from the the header line of the index file.

Unittests are not independant

The order of tests matters, with some tests failing if the order is changed. As pytest does not isolate the environment between tests, some state can persist and influence the result of subsequent tests.

Initialising flags should be done each time and care should be taken when modifying/mocking of imports - as these may persist across suites(?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.