Powered by Genie
And the pyATS framework
Featuring
Welcome!
Magic Carpet is an infrastructure as code and network automation tool that transforms CLI command and REST API data, using the Cisco Genie parsers, the Cisco pyATS Python library, and Python to automatically generate, at scale, better documentation from the output; send #chatbots; #voicebots; even #phonebots!
A Nice JSON file (command_output.json)
A Nice YAML file (command_output.yaml)
A CSV spreadsheet (command_output.csv)
A Markdown file (command_output.md)
An HTML page (comand_output.html)
An interactive HTML Mind Map (command_output_mind_map.html)
Instant messages to WebEx, Slack, Discord, and others
Text-to-Speech, in over 200 languages, creating customized MP3 audio files in a human voice
Phone calls to any phone number in the world
Instantly. With the push of a button.
The main Genie documentation guide:
https://developer.cisco.com/docs/genie-docs/
The main pyATS documentation guide:
https://developer.cisco.com/docs/pyats/
The Cisco's Test Automation Solution
The Cisco Test Automation GitHub repository
https://github.com/CiscoTestAutomation
Here are the pyATS documentation guides on Testbed files and Device Connectivity:
Testbed and Topology Information: https://pubhub.devnetcloud.com/media/pyats/docs/topology/index.html
Device Connection: https://pubhub.devnetcloud.com/media/pyats-getting-started/docs/quickstart/manageconnections.html
Testbed File Example: https://pubhub.devnetcloud.com/media/pyats/docs/topology/example.html
Device Connections: https://developer.cisco.com/docs/pyats/#!connection-to-devices
Secret Strings (how I encrypted the enable secret in my testbed file): https://pubhub.devnetcloud.com/media/pyats/docs/utilities/secret_strings.html
Requirements (instructions below)
Virtual Environment
We recommend running Magic Carpet in a Python virtual environment while testing or developing. This will help keep your host system clean and allow you to have multiple environments to try new things. If you are not using a virtual environment, start at the download/clone step below.
You will also need Python 3, pip, and venv installed on your host system.
In your project directory, create your virtual environment
python3 -m venv env
Activate (use) your new virtual environment (Linux):
source env/bin/activate
Download or clone the Magic Carpet repository:
git clone https://github.com/automateyournetwork/magic_carpet
Install pyATS, Rich, and Markmap into your virtual environment:
pip install pyats[full]
pip install rich
sudo apt update
sudo apt install npm
npm install markmap-lib -g
If you run into any installation issues with pyATS, please see the installation guide here: https://pubhub.devnetcloud.com/media/pyats-getting-started/docs/install/installpyATS.html
You're now ready to fly!
When you are finished with your pyATS session, enter the deactivate
command to exit the python virtual environment.
How to Update the testbed/testbed.yaml
file to reflect your devices:
Devices:
4500: <-- Update to your router hostname
alias: <-- Update our alias; this can be the hostname or any friendly name you want
type: <-- This should be "router" for L3 routers with ARP tables and VRFs and such
platform: <-- Your Catalyst IOS-XE Platform
username: <-- Your Cisco device username
password: <-- Your Enable Secret; It is strongly recommended to follow the "Secret Strings" link to encrypt your secrets
ip: <-- The management IP address of your router
Copy & Paste and make each device unique to scale this up to many routers
Devices:
3850: <-- Update to your switch hostname
9300: <-- Update to your switch hostname
alias: <-- Update our alias; this can be the hostname or any friendly name you want
type: <-- This should be "switch" for L2 switches without ARP tables or VRFs but features like PoE
platform: <-- Your Catalyst IOS-XE Platform
username: <-- Your Cisco device username
password: <-- Your Enable Secret; It is strongly recommended to follow the "Secret Strings" link to encrypt your secrets
ip: <-- The management IP address of your router
Copy & Paste and make each device unique to scale this up to many routers
Ensure SSH connectivity at from your host's CLI, and run the pyATS job:
Cisco IOS-XE:
pyats run job IOS_XE_magic_carpet_job.py --testbed-file testbed/testbed.yaml
JunOS 17 / 18 / 19:
pyats run job JUNOS_magic_carpet_job.py --testbed-file testbed/testbed_juniper.yaml
F5 BIG-IP:
pyton3 F5_magic_carpet.py
First - you will get onto the Magic Carpet
Next - Genie Magic
Finally - We escape the Cave of Wonders with the network data
cd Cave_of_Wonders
ls
Explore your Wonders!
Here is an example of just one of the Wonders you will find - the show ip route command!
Here is what a Global Routing Table looks like in JSON:
The same routing table, but in YAML:
The JSON and YAML are incredible representations of the routing table and can be used for futher pyATS testing or data modeling.
"Business-ready" documentation includes the incredibly powerful and versitile Comma-Separated Values (csv) spreadsheet format.
Markdown, the format this README file is written in, can also be used to express the data in a lightweight format that renders nicely in modern browsers.
What about a full-blown HTML Webpage? Magic Carpet also creates at least one of these per command
Which renders nicely like this in your browser
Another HTML page, an interactive Mind Map, is also created from the Markdown file!
To View the pyATS log in a Web Browser Locally
pyats logs view
To launch a Python Web Server and make the Cave of Wonders available in a browser, where you can view the HTML pages:
Launch local web server available on the same host:
cd Cave_of_Wonders
pushd; python3 -m http.server --bind 127.0.0.1 8080; popd;
Launch Web Browser and visit
Launch local web server available to remote hosts:
cd Cave_of_Wonders
pushd; python3 -m http.server --bind {{ your client IP }} 8080; popd;
Launch Web Browser and visit
http://{{ your client IP }}/:8080
To View the log in a Web Browser Remotely
pyats logs view --host 0.0.0.0 --port 8080 -v
Cisco IOS-XE:
show access lists
show access session
show authentication sessions
show cdp neighbors details
show etherchannel summary
show interfaces status
show interfaces trunk
show inventory
show ip arp
show ip arp vrf {{ vrf }}
show ip interface brief
show ip ospf neighbor detail
show ip route
show ip route vrf {{ vrf }}
show issu state detail
* 4500X IOS-XE in VSS
show mac address-table
show ntp associations
show version
show vrf
JunOS:
show_system_information
F5 BIG-IP
mgmt/tm/ltm/virtual
Tested on:
Cisco:
Cisco Catalyst 4500X-16 03.11.03a.E
Cisco Catalyst 9300-48UXM Gibraltar
Cisco Catalyst 9200-24P 16.12.03 and 17.03.02a
Cisco Catalyst 3850-12X48U Gibraltar 16.12.04
Cisco IOSv
Juniper:
JunOS 17, 18, 19
F5:
i2600 REST API