virlutils
A collection of utilities for interacting with Cisco VIRL 1.x or Cisco Modeling Labs (CML) v2.0+.
This document describes the new version of virlutils (aka cmlutils) that works with Cisco Modeling Labs v2.0 and higher. Documentation for working with VIRL/CML 1.x is available here.
virl up / cml up
virl
(or cml
) is a devops style cli which supports the most common VIRL/CML operations. Adding new ones is easy...
Usage: cml [OPTIONS] COMMAND [ARGS]...
Options:
--debug / --no-debug Print any debugging output.
--help Show this message and exit.
Commands:
clear clear the current lab ID
cluster display and manage CML cluster details
cockpit opens the Cockpit UI
command send a command or config to a node (requires pyATS)
console console for node
definitions manage image and node definitions
down stop a lab
extract extract configurations from all nodes in a lab
generate generate inv file for various tools
id get the current lab title and ID
license work with product licensing
ls lists running labs and optionally those in the cache
nodes get node list for the current lab
pull pull topology.yaml from repo
rm remove a lab
save save lab to a local yaml file
search list topologies available via github
ssh ssh to a node
start start a node
stop stop a node
telnet telnet to a node
ui opens the Workbench for the current lab
up start a lab
use use lab launched elsewhere
version version information
wipe wipe a lab or nodes within a lab
Prerequisites
- Python 3.7+ (tested with Python 3.7, 3.8, and 3.9)
Installation
1.Clone this repo
git clone https://github.com/CiscoDevNet/virlutils
cd virlutils
2.Either (2a) use pip, or (2b) use setup.py
2a. Use pip
pip install cmlutils
Or
pip install virlutils
2b. Use setup.py
python3 -m venv venv
source venv/bin/activate
python setup.py install
Configuration
There really isn't much to configure, just set your CML credentials. There are a few different ways to accomplish this, pick whichever one works best for you. The options listed below are in the preferred
order.
.virlrc in working directory
Add a .virlrc to the working directory, this will always be checked first and is useful when you want to override one or more parameters for a particular project directory.
The contents would look something like this.
VIRL_HOST=specialvirlserver.foo.com
environment variables
You can also add them as environment variables. This is useful if you want to override the global VIRL settings.
export VIRL_HOST=192.0.2.100
export VIRL_USERNAME=admin
export VIRL_PASSWORD=admin123
.virlrc in your home directory
Configure VIRL credentials globally by putting them in ~/.virlrc the formatting
VIRL_USERNAME=netadmins
VIRL_PASSWORD=cancodetoo!
Other configuration options
In addition to basic credentials, the following configuration options are supported using any of the methods mentioned previously
-
VIRL_TELNET_COMMAND
- allows the user to customize the telnet command that is called. This command will be passed the host/ip information from the running simulationExample:
export VIRL_TELNET_COMMAND="mytelnet {host}"
-
VIRL_SSH_COMMAND
- allows the user to customize the ssh command that is called. This command will be passed the host/ip as well as the username from the running simulationExample:
export VIRL_SSH_COMMAND="myssh {username}@{host}"
-
CML_VERIFY_CERT
- The path to a PEM-encoded certificate file to use to verify the CML controller VM's SSL certificate. If you do not wish to verify the certificate, set this to "False"Example:
export CML_VERIFY_CERT=/etc/certs/ca_bundle.pem
-
CML_CONSOLE_COMMAND
- allows the user to customize the SSH command that is called.This command will be passed the CML controller VM IP, the console path of the node, and the CML controller username (note: you may have to force a TTY allocation in your SSH command)
Example:
export CML_CONSOLE_COMMAND="myssh {user}@{host} {console}"
-
CML2_PLUS
- If set in the config or in the environment then virlutils will assume the server is a CML 2+ server and not try and automatically guess its version. If omitted, then virutils will attempt to automatically determine the CML/VIRL server versionExample:
export CML2_PLUS="yes"
-
CML_PLUGIN_PATH
- A delimiter-separated list of directories in which to find cmlutils plugins. See the plugin documentation for more details. By default, theplugins
directory in the current.virl
directory will be searched.Example:
export CML_PLUGIN_PATH="~/cmlutils/plugins:/opt/cmlutils/plugins"
Why so many choices??!?
Understanding the precedence allows you to do some pretty cool things.
Assume the following directory structure...
.
โโโ dev
โย ย โโโ .virlrc
โย ย โโโ topology.yaml
โโโ prod
โย ย โโโ .virlrc
โย ย โโโ topology.yaml
โโโ test
โโโ .virlrc
โโโ topology.yaml
This allows three major benefits.
- you can easily use different credentials/servers for various environments
- you can customize your lab .yaml files to include different tags, different node configurations, etc.
- you have a badass workflow.
$ cml ls
Labs on Server
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
| | | | | | | |
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
$ cd ../test
$ cml ls
Labs on Server
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
โ 7c2cf3 โ Small Branch Test โ โ STARTED โ 9 โ 8 โ 23 โ
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
$ cd ../prod
$ cml ls
Running Simulations
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
โ 7c2cf3 โ Small Branch Prod โ โ STARTED โ 9 โ 8 โ 23 โ
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
Usage / Workflows
Basic Workflow
in the absence of better documentation, here's a sample workflow
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml ls
Labs on Server
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
โ 02f6c6 โ CCIE Enterprise Infrastructure โ โ DEFINED_ON_CORE โ 54 โ 67 โ 216 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 332eab โ Branch Test โ โ DEFINED_ON_CORE โ 6 โ 5 โ 15 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 7c2cf3 โ Small Branch โ โ STOPPED โ 9 โ 8 โ 23 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ e5afaf โ Dynamic Split Tunnel โ โ STOPPED โ 10 โ 9 โ 36 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 66defd โ Lab at Tue 14:45 PM โ โ STOPPED โ 2 โ 1 โ 6 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ bc518e โ Lab at Wed 21:39 PM โ โ STOPPED โ 9 โ 1 โ 26 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 0e1bb2 โ DFN โ German Research Network โ DEFINED_ON_CORE โ 51 โ 80 โ 211 โ
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml id
Small Branch (ID: 7c2cf3)
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml up
Lab Small Branch (ID: 7c2cf3) is already set as the current lab
Starting lab Small Branch (ID: 7c2cf3)
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml ls
Labs on Server
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
โ 02f6c6 โ CCIE Enterprise Infrastructure โ โ DEFINED_ON_CORE โ 54 โ 67 โ 216 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 332eab โ Branch Test โ โ DEFINED_ON_CORE โ 6 โ 5 โ 15 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 7c2cf3 โ Small Branch โ โ STARTED โ 9 โ 8 โ 23 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ e5afaf โ Dynamic Split Tunnel โ โ STOPPED โ 10 โ 9 โ 36 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 66defd โ Lab at Tue 14:45 PM โ โ STOPPED โ 2 โ 1 โ 6 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ bc518e โ Lab at Wed 21:39 PM โ โ STOPPED โ 9 โ 1 โ 26 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 0e1bb2 โ DFN โ German Research Network โ DEFINED_ON_CORE โ 51 โ 80 โ 211 โ
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml nodes
Here is a list of nodes in this lab
โโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโ
โ ID โ Label โ Type โ State โ Wiped? โ L3 Address(es) โ
โโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโก
โ n0 โ branch-rtr โ csr1000v โ BOOTED โ False โ 192.168.10.219 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n1 โ Internet โ external_connector โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n2 โ branch-sw โ iosvl2 โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n3 โ client-desktop โ desktop โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n4 โ WAN Link 1 โ wan_emulator โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n5 โ rtr-2 โ iosv โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n8 โ ext-conn-1 โ external_connector โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n6 โ trex-0 โ trex โ BOOTED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n7 โ VLAN 10 โ external_connector โ BOOTED โ False โ โ
โโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml console branch-rtr
[email protected]'s password:
Connecting to console for
Connected to terminalserver.
Escape character is '^]'.
branch-rtr#
branch-rtr#
branch-rtr#
branch-rtr#
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml down
Shutting down lab Small Branch (ID: 7c2cf3).....
SUCCESS
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml ls
Labs on Server
โโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโ
โ ID โ Title โ Description โ Status โ Nodes โ Links โ Interfaces โ
โโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโโโโโก
โ 02f6c6 โ CCIE Enterprise Infrastructure โ โ DEFINED_ON_CORE โ 54 โ 67 โ 216 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 332eab โ Branch Test โ โ DEFINED_ON_CORE โ 6 โ 5 โ 15 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 7c2cf3 โ Small Branch โ โ STOPPED โ 9 โ 8 โ 23 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ e5afaf โ Dynamic Split Tunnel โ โ STOPPED โ 10 โ 9 โ 36 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 66defd โ Lab at Tue 14:45 PM โ โ STOPPED โ 2 โ 1 โ 6 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ bc518e โ Lab at Wed 21:39 PM โ โ STOPPED โ 9 โ 1 โ 26 โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 0e1bb2 โ DFN โ German Research Network โ DEFINED_ON_CORE โ 51 โ 80 โ 211 โ
โโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml use --lab-name "Small Branch"
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml nodes
Here is a list of nodes in this lab
โโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโ
โ ID โ Label โ Type โ State โ Wiped? โ L3 Address(es) โ
โโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโชโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโก
โ n0 โ branch-rtr โ csr1000v โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n1 โ Internet โ external_connector โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n2 โ branch-sw โ iosvl2 โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n3 โ client-desktop โ desktop โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n4 โ WAN Link 1 โ wan_emulator โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n5 โ rtr-2 โ iosv โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n8 โ ext-conn-1 โ external_connector โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n6 โ trex-0 โ trex โ STOPPED โ False โ โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ n7 โ VLAN 10 โ external_connector โ STOPPED โ False โ โ
โโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโ
Inventory Generation
virlutils will generate inventories for various management systems
pyATS Testbed Generation
quickly turn your simulations into a testbed file that can be used for pyATS/Genie
cml generate pyats
Command and Config Execution
Using the same pyATS framework, virlutils
can execute CLI EXEC-level (e.g., "show") commands as well as configuration commands on nodes within a lab. These nodes do not have to be externally reachable or have any IP connectivity. This is a great way to test operational aspects of a completely isolated topology. Before using the command
command you must install pyATS. You can install pyATS by running pip install pyats
.
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml command "branch-rtr" "show version"
Cisco IOS XE Software, Version 16.11.01b
Cisco IOS Software [Gibraltar], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.11.1b, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
...
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml command --config "branch-rtr" "snmp-server community notpublic"
Ansible Inventory Generation
quickly turn your simulations into an inventory file that can be used to run your playbooks against. Both INI and YAML(default) formats are supported by the tool.
Usage: cml generate ansible [OPTIONS]
generate ansible inventory
Options:
-o, --output TEXT output File name
--style [ini|yaml] output format (default is yaml)
--help Show this message and exit.
The ansible group membership can be controlled by adding the "ansible_group" tag to nodes in your CML labs. Multiple "ansible_group" tags can be assigned to a single node, and that node will be placed into each Ansible inventory group.
nodes:
- id: n0
label: branch-rtr
node_definition: csr1000v
tags:
- ansible_group=mygroup
would result in the following inventory entry
all:
children:
mygroup:
hosts:
branch-router:
ansible_host: 192.0.2.1
NOTE: if the ansible_group tag is not specified for a node, that node will not be included during inventory generation. Additionally, CML needs to know each node's management IP address before it will be placed into the inventory file
Cisco Network Services Orchestrator
You can add/update Network Services Orchestrator with your VIRL simulation.
Usage
Usage: cml generate nso [OPTIONS]
generate nso inventory
Options:
-o, --output TEXT just dump the payload to file without sending
--syncfrom / --no-syncfrom Perform sync-from after updating devices
--help Show this message and exit.
output
Updating NSO....
Enter NSO IP/Hostname: localhost
Enter NSO username: admin
Enter NSO password:
Successfully added CML devices to NSO
NOTE: NSO environment is also attempted to be determined using the following environment variables
- NSO_HOST
- NSO_USERNAME
- NSO_PASSWORD
NSO Configuration Example
export NSO_HOST=localhost
export NSO_USERNAME=admin
export NSO_PASSWORD=admin
Tab Completions
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
โ cml l<tab>
license ls
You can activate VIRL autocompletions by executing the following command
eval "$(_VIRL_COMPLETE=bash_source virl)"
To do the same for the cml
command, do the following
eval "$(_CML_COMPLETE=bash_source cml)"
zsh users may need to run the following prior
autoload bashcompinit
bashcompinit
And then the following to properly enable completions for zsh
eval "$(_VIRL_COMPLETE=zsh_source virl)"
eval "$(_CML_COMPLETE=zsh_source cml)"
Local Development
If you have an idea for a feature you would like to see, we gladly accept pull requests. To get started developing, simply run the following..
git clone https://github.com/CiscoDevNet/virlutils
cd virlutils
python setup.py develop
Linting
We use flake 8 to lint our code. Please keep the repository clean by running:
flake8
Testing
We have some testing implemented, but would love to have better coverage. If you
add a feature, or just feel like writing tests please update the appropriate files
in the tests
folder.
To run the tests in the tests
folder, you can simply run make test
from
the project root.