A collection of utilities for interacting with Cisco Modeling Labs (CML) v2.6+.
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
groups manage groups
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
tmux console to all nodes using tmux
ui opens the Workbench for the current lab
up start a lab
use use lab launched elsewhere
users manage users
version version information
wipe wipe a lab or nodes within a lab
- Python 3.8+ (tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12)
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
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.
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
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
Configure VIRL credentials globally by putting them in ~/.virlrc the formatting
VIRL_USERNAME=netadmins
VIRL_PASSWORD=cancodetoo!
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}"
-
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"
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 β Owner β Status β Nodes β Links β Interfaces β
βββββββββββββββββͺβββββββββββββββββββββββββͺββββββββββββββββͺβββββββββββͺβββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β β β β β β β β β
βββββββββββββββββ§βββββββββββββββββββββββββ§ββββββββββββββββ§βββββββββββ§βββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
$ cd ../test
$ cml ls
Labs on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββββββββββββ€βββββββββββ€ββββββββββββββββββ€ββββββββββ€ββββββββββ€βββββββββββββββ
β ID β Title β Description β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺββββββββββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β f25b3881-0d19-4a6d-816f-36d1c663f930 β Multi Platform Network β A sample network built with IOS XE, NX- β labuser β STOPPED β 14 β 32 β 101 β
β β β OS, IOS XR, and ASA devices. Includes β β β β β β
β β β Linux hosts. β β β β β β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§ββββββββββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
$ cd ../prod
$ cml ls
Labs on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββββββββββββ€βββββββββββ€ββββββββββββββββββ€ββββββββββ€ββββββββββ€βββββββββββββββ
β ID β Title β Description β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺββββββββββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β 0fdea012-83b4-4545-8747-c7b8037e5a96 β Multi Platform Network β A sample network built with IOS XE, NX- β labuser β STARTED β 14 β 32 β 101 β
β β β OS, IOS XR, and ASA devices. Includes β β β β β β
β β β Linux hosts. β β β β β β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§ββββββββββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
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 β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺββββββββββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β 35c5393b-6037-4c96-86d4-33f96e53a615 β CCIE Enterprise Infrastructure β β labuser β DEFINED_ON_CORE β 54 β 67 β 216β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β a5fa67e3-44b9-4b26-8a50-58d471766280 β Branch Test β β labuser β STOPPED β 6 β 5 β 17 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 931b20a1-f0be-4c9f-b7ef-4db96ee77135 β Small Branch β A small branch network built with CSR1kvβ labuser β STOPPED β 14 β 32 β 101 β
β β β IOSv, IOSvL2. The devices are managed byβ β β β β β
β β β NSO. β β β β β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe β Dynamic Split Tunnel β β labuser β STOPPED β 7 β 9 β 37 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 86ef940d-58e8-49d9-b154-22ec714add62 β Lab at Tue 14:45 PM β β labuser β STOPPED β 3 β 2 β 14 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β ba9a1282-048f-4914-a419-59c8027afa6a β DFN β German Research Network β labuser β STARTED β 51 β 80 β 211 β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§ββββββββββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml use --lab-name "Small Branch"
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml id
Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135)
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml up
Lab Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135) is already set as the current lab
Starting lab Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135)
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml ls
Labs on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββββββββββββ€βββββββββββ€ββββββββββββββββββ€ββββββββββ€ββββββββββ€βββββββββββββββ
β ID β Title β Description β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺββββββββββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β 35c5393b-6037-4c96-86d4-33f96e53a615 β CCIE Enterprise Infrastructure β β labuser β DEFINED_ON_CORE β 54 β 67 β 216β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β a5fa67e3-44b9-4b26-8a50-58d471766280 β Branch Test β β labuser β STOPPED β 6 β 5 β 17 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 931b20a1-f0be-4c9f-b7ef-4db96ee77135 β Small Branch β A small branch network built with CSR1kvβ labuser β STARTED β 14 β 32 β 101 β
β β β IOSv, IOSvL2. The devices are managed byβ β β β β β
β β β NSO. β β β β β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe β Dynamic Split Tunnel β β labuser β STOPPED β 7 β 9 β 37 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 86ef940d-58e8-49d9-b154-22ec714add62 β Lab at Tue 14:45 PM β β labuser β STOPPED β 3 β 2 β 14 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β ba9a1282-048f-4914-a419-59c8027afa6a β DFN β German Research Network β labuser β STARTED β 51 β 80 β 211 β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§ββββββββββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml nodes
Here is a list of nodes in this lab
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββ€ββββββββββββββββββ€βββββββββββ€βββββββββββββββββββββββββββββββββββββββ
β ID β Label β Type β Compute Node β State β Wiped? β L3 Address(es) β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββͺββββββββββββββββββͺβββββββββββͺβββββββββββββββββββββββββββββββββββββββ‘
β 32135ea1-d6f4-4ae5-94cb-8dfa14c0b758 β Internet β external_connector β compute-01 β BOOTED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β e6ed74ef-62bf-4f4c-8fe8-a44fb3bc74c4 β branch-rtr β csr1000v β compute-01 β BOOTED β False β 192.168.10.129 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β a01784b1-d11f-4c52-907b-b6ac92d3b8f1 β branch-sw β iosvl2 β compute-01 β BOOTED β False β 192.168.10.143 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β 84625ab4-53dd-4ff4-8cd1-2a2ef94edc02 β nso-0 β nso_ubuntu β compute-01 β BOOTED β False β 2001:db8:dead:beef:5054:ff:fe11:a168 β
β β β β β β β fe80::5054:ff:fe11:a168 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β 579a9e46-3433-4645-9bad-c84106d9cd54 β remote-rtr β iosv β compute-01 β BOOTED β False β 192.168.10.137 β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββ§ββββββββββββββββββ§βββββββββββ§βββββββββββββββββββββββββββββββββββββββ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml console branch-rtr
admin@192.168.10.214'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: 931b20a1-f0be-4c9f-b7ef-4db96ee77135).....
SUCCESS
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml ls
Labs on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββββββββββββ€βββββββββββ€ββββββββββββββββββ€ββββββββββ€ββββββββββ€βββββββββββββββ
β ID β Title β Description β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺββββββββββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β 35c5393b-6037-4c96-86d4-33f96e53a615 β CCIE Enterprise Infrastructure β β labuser β DEFINED_ON_CORE β 54 β 67 β 216β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β a5fa67e3-44b9-4b26-8a50-58d471766280 β Branch Test β β labuser β STOPPED β 6 β 5 β 17 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 931b20a1-f0be-4c9f-b7ef-4db96ee77135 β Small Branch β A small branch network built with CSR1kvβ labuser β STOPPED β 14 β 32 β 101 β
β β β IOSv, IOSvL2. The devices are managed byβ β β β β β
β β β NSO. β β β β β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe β Dynamic Split Tunnel β β labuser β STOPPED β 7 β 9 β 37 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 86ef940d-58e8-49d9-b154-22ec714add62 β Lab at Tue 14:45 PM β β labuser β STOPPED β 3 β 2 β 14 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β ba9a1282-048f-4914-a419-59c8027afa6a β DFN β German Research Network β labuser β STARTED β 51 β 80 β 211 β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§ββββββββββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
β cml nodes
Here is a list of nodes in this lab
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββ€ββββββββββββββββββ€βββββββββββ€βββββββββββββββββββββββββββββββββββββββ
β ID β Label β Type β Compute Node β State β Wiped? β L3 Address(es) β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββͺββββββββββββββββββͺβββββββββββͺβββββββββββββββββββββββββββββββββββββββ‘
β 32135ea1-d6f4-4ae5-94cb-8dfa14c0b758 β Internet β external_connector β compute-01 β STOPPED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β e6ed74ef-62bf-4f4c-8fe8-a44fb3bc74c4 β branch-rtr β csr1000v β compute-01 β STOPPED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β a01784b1-d11f-4c52-907b-b6ac92d3b8f1 β branch-sw β iosvl2 β compute-01 β STOPPED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β 84625ab4-53dd-4ff4-8cd1-2a2ef94edc02 β nso-0 β nso_ubuntu β compute-01 β STOPPED β False β β
β β β β β β β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β 579a9e46-3433-4645-9bad-c84106d9cd54 β remote-rtr β iosv β compute-01 β STOPPED β False β β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββ§ββββββββββββββββββ§βββββββββββ§βββββββββββββββββββββββββββββββββββββββ
If you are a tmux
user you can console to all nodes with the following command:
β― cml tmux --help
Usage: cml tmux [OPTIONS]
console to all nodes using tmux
Options:
--group [panes|windows] 'panes': group all nodes in one window, 'windows':
one node per window [default: panes]
--help Show this message and exit.
β― cml nodes
Here is a list of nodes in this lab
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββββββ€βββββββββββββββββ€ββββββββββ€βββββββββββ€βββββββββββββββββββ
β ID β Label β Type β Compute Node β State β Wiped? β L3 Address(es) β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββͺββββββββββͺβββββββββββͺβββββββββββββββββββ‘
β 5fdb38b6-7ff7-4792-b685-5eeaa41d8865 β c8v-2 β cat8000v β cml-01 β BOOTED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββΌβββββββββββΌβββββββββββββββββββ€
β 7bdedc4a-a196-4ad0-b1f3-888cf77eee8b β c8v-1 β cat8000v β cml-01 β BOOTED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββΌβββββββββββΌβββββββββββββββββββ€
β ab3ee63d-109d-424e-a2c0-7581a61b1d1d β unmanaged-switch-0 β unmanaged_switch β cml-01 β BOOTED β False β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββΌββββββββββΌβββββββββββΌβββββββββββββββββββ€
β 9a068ec0-0565-44a0-bf16-8e4690108ac9 β ext-conn-0 β external_connector β cml-01 β BOOTED β False β β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββββββ§βββββββββββββββββ§ββββββββββ§βββββββββββ§βββββββββββββββββββ
This will create a new tmux session with title "lab name + first 4 lab id chars" (e.g. PPK-c93a
).
By default, the nodes will be grouped into one window (cml tmux --group panes
),
β― printf '\033]2;%s\033\\' 'c8v-2'
β― ssh -t admin@cml-01 open /PPK/c8v-2/0
admin@cml-01's password:
Connecting to console for c8v-2
Connected to CML terminalserver.
Escape character is '^]'.
c8v2#
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β― printf '\033]2;%s\033\\' 'c8v-1'
β― ssh -t admin@cml-01 open /PPK/c8v-1/0
admin@cml-01's password:
Connecting to console for c8v-1
Connected to CML terminalserver.
Escape character is '^]'.
c8v1#
PPK-c93a >> 1 > ssh > < 20:20
Note: the command
printf '\033]2;%s\033\\' 'c8v-2'
is used to set the pane's title see: tmux man
if you prefer having one connection per window, use: cml tmux --group windows
.
β― ssh -t admin@cml-01 open /PPK/c8v-2/0
admin@cml-01's password:
Connecting to console for c8v-2
Connected to CML terminalserver.
Escape character is '^]'.
c8v2#
PPK-c93a >> 1 > c8v-2 >> 2 > c8v-1 > < 20:32
virlutils will generate inventories for various management systems
quickly turn your simulations into a testbed file that can be used for pyATS/Genie
cml generate pyats
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"
The cml up
command can convert EVE-NG labs to CML labs on the fly (".unl" to ".yaml" conversion) if you install the
eve2cml Python package. With that library package, a command such as
cml up -f my-lab.unl
will convert my-lab.unl
to my-lab.yaml
in the same directory and import it into CML.
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
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
You can manage users and groups too!
To manage users you can use the cml users
command
β― cml users
Usage: cml users [OPTIONS] COMMAND [ARGS]...
manage users
Options:
--help Show this message and exit.
Commands:
create Create one or more users (e.g., user1 user2)
delete Delete one or more users (e.g., user1 user2)
ls List all users on the server.
update Update one or more users (e.g., user1 user2)
To list users
β― cml users ls
ββββββββββββββ€ββββββββββββββββββ€ββββββββββββββ€ββββββββββ€βββββββββββββ€βββββββββββββββββββββββββ
β Username β Administrator β Full Name β Email β Groups β Labs β
ββββββββββββββͺββββββββββββββββββͺββββββββββββββͺββββββββββͺβββββββββββββͺβββββββββββββββββββββββββ‘
β admin β True β β β users β BGP β
β β β β β superusers β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β john β False β Uncle John β β users β OSPF β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β chuck β False β Uncle Chuck β β β β
ββββββββββββββ§ββββββββββββββββββ§ββββββββββββββ§ββββββββββ§βββββββββββββ§βββββββββββββββββββββββββ
By default, user IDs are not shown, to display them use the --verbose
or -v
flag:
β― cml users ls --verbose
Users on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββ€ββββββββββββββββββ€ββββββββββββββ€ββββββββββ€βββββββββββββ€βββββββββββββββββββββββββ
β ID β Username β Administrator β Full Name β Email β Groups β Labs β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββͺββββββββββββββββββͺββββββββββββββͺββββββββββͺβββββββββββββͺβββββββββββββββββββββββββ‘
β 00000000-0000-4000-a000-000000000000 β admin β True β β β users β BGP β
β β β β β β superusers β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β 9e4e75b4-aaab-47af-9edb-9364460a81ae β john β False β Uncle John β β users β OSPF β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β dcc96fe1-8cba-4227-9aa6-b41d5ff91e3a β chuck β True β Uncle Chuck β β β β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββ§ββββββββββββββββββ§ββββββββββββββ§ββββββββββ§βββββββββββββ§βββββββββββββββββββββββββ
You can create one or multiple users. For each user, you will be prompted for the password and confirmation. Optionally, you can grant admin privileges and add the users to one or more groups.
β― cml users create alice bob --admin --group users --superusers
Enter alice's password:
Re-Enter alice's password:
User alice successfully created
Enter bob's password:
Re-Enter bob's password:
User bob successfully created
β― cml users ls
ββββββββββββββ€ββββββββββββββββββ€ββββββββββββββ€ββββββββββ€βββββββββββββ€βββββββββββββββββββββββββ
β Username β Administrator β Full Name β Email β Groups β Labs β
ββββββββββββββͺββββββββββββββββββͺββββββββββββββͺββββββββββͺβββββββββββββͺβββββββββββββββββββββββββ‘
β admin β True β β β users β BGP β
β β β β β superusers β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β john β False β Uncle John β β users β OSPF β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β chuck β False β Uncle Chuck β β β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β alice β True β β β users β β
β β β β β superusers β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β bob β True β β β users β β
β β β β β superusers β β
ββββββββββββββ§ββββββββββββββββββ§ββββββββββββββ§ββββββββββ§βββββββββββββ§βββββββββββββββββββββββββ
You can also update one or more existing users (e.g. removing admin privileges)
β― cml users update alice bob --no-admin --remove-from-all-groups
User alice successfully updated
User bob successfully updated
β― cml users ls
ββββββββββββββ€ββββββββββββββββββ€ββββββββββββββ€ββββββββββ€βββββββββββββ€βββββββββββββββββββββββββ
β Username β Administrator β Full Name β Email β Groups β Labs β
ββββββββββββββͺββββββββββββββββββͺββββββββββββββͺββββββββββͺβββββββββββββͺβββββββββββββββββββββββββ‘
β admin β True β β β users β BGP β
β β β β β superusers β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β john β False β Uncle John β β users β OSPF β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β chuck β False β Uncle Chuck β β β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β alice β False β β β β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β bob β False β β β β β
ββββββββββββββ§ββββββββββββββββββ§ββββββββββββββ§ββββββββββ§βββββββββββββ§βββββββββββββββββββββββββ
Check the cli help for more options.
To delete one or multiple users.
β― cml users delete alice bob
User alice successfully deleted
User bob successfully deleted
β― cml users ls
ββββββββββββββ€ββββββββββββββββββ€ββββββββββββββ€ββββββββββ€βββββββββββββ€βββββββββββββββββββββββββ
β Username β Administrator β Full Name β Email β Groups β Labs β
ββββββββββββββͺββββββββββββββββββͺββββββββββββββͺββββββββββͺβββββββββββββͺβββββββββββββββββββββββββ‘
β admin β True β β β users β BGP β
β β β β β superusers β β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β john β False β Uncle John β β users β OSPF β
ββββββββββββββΌββββββββββββββββββΌββββββββββββββΌββββββββββΌβββββββββββββΌβββββββββββββββββββββββββ€
β chuck β False β Uncle Chuck β β β β
ββββββββββββββ§ββββββββββββββββββ§ββββββββββββββ§ββββββββββ§βββββββββββββ§βββββββββββββββββββββββββ
To manage groups you can use the cml groups
command
β― cml groups --help
Usage: cml groups [OPTIONS] COMMAND [ARGS]...
manage groups
Options:
--help Show this message and exit.
Commands:
create Create one or more groups (e.g., group1 group2)
delete Delete one or more groups (e.g., group1 group2)
ls List all groups on the server
update Update one or more groups (e.g., group1 group2)
To list groups
β― cml groups ls
Groups on Server
ββββββββββββββ€ββββββββββββββββ€ββββββββββ€βββββββββββββββββββββββββββββββββββββ
β Name β Description β Users β Labs β
ββββββββββββββͺββββββββββββββββͺββββββββββͺβββββββββββββββββββββββββββββββββββββ‘
β users β All Users β admin β netbox (read_only) β
β β β john β Multi Platform Network (read_only) β
β β β β BFD (read_only) β
ββββββββββββββΌββββββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β superusers β Superusers β admin β β
ββββββββββββββ§ββββββββββββββββ§ββββββββββ§βββββββββββββββββββββββββββββββββββββ
You can create one or more groups and assign them to multiple labs or members.
β― cml ls
Labs on Server
ββββββββββββββββββββββββββββββββββββββββ€βββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββββββββββββ€βββββββββββ€βββββββββββ€ββββββββββ€ββββββββββ€βββββββββββββββ
β ID β Title β Description β Owner β Status β Nodes β Links β Interfaces β
ββββββββββββββββββββββββββββββββββββββββͺβββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββͺβββββββββββͺβββββββββββͺββββββββββͺββββββββββͺβββββββββββββββ‘
β ba9a1282-048f-4914-a419-59c8027afa6a β Quantum IPsec β β admin β STOPPED β 5 β 4 β 20 β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββΌβββββββββββΌβββββββββββΌββββββββββΌββββββββββΌβββββββββββββββ€
β 0786b045-aa39-4e98-af01-575b22566cf2 β Multi-SA HSRP β β admin β STARTED β 10 β 13 β 47 β
ββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββββββββββββ§ββββββββββββββββββββββββββββββββββββββββββ§βββββββββββ§βββββββββββ§ββββββββββ§ββββββββββ§βββββββββββββββ
β― cml groups create --member alice --member bob --member mike --lab ba9a1282-048f-4914-a419-59c8027afa6a read_only --lab 0786b045-aa39-4e98-af01-575b22566cf2 read_write cryptopals
Group cryptopals successfully created
β― cml groups ls
Groups on Server
ββββββββββββββ€ββββββββββββββββ€ββββββββββ€βββββββββββββββββββββββββββββββββββββ
β Name β Description β Users β Labs β
ββββββββββββββͺββββββββββββββββͺββββββββββͺβββββββββββββββββββββββββββββββββββββ‘
β users β All Users β admin β netbox (read_only) β
β β β john β Multi Platform Network (read_only) β
β β β β BFD (read_only) β
ββββββββββββββΌββββββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β superusers β Superusers β admin β β
ββββββββββββββΌββββββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β cryptopals β β alice β Quantum IPsec (read_only) β
β β β bob β Multi-SA HSRP (read_write) β
β β β mike β β
ββββββββββββββ§ββββββββββββββββ§ββββββββββ§βββββββββββββββββββββββββββββββββββββ
Similarly, you can update one or more groups and assign them to multiple labs or members.
Also, for both cml groups create
and cml groups update
you can assign all labs and/or all users to the groups.
β― cml groups update --add-all-users --add-all-labs read_only users
Group users successfully updated
β― cml groups ls
Groups on Server
ββββββββββββββ€ββββββββββββββββ€βββββββββββ€βββββββββββββββββββββββββββββββββββββ
β Name β Description β Users β Labs β
ββββββββββββββͺββββββββββββββββͺβββββββββββͺβββββββββββββββββββββββββββββββββββββ‘
β users β All Users β admin β netbox (read_only) β
β β β john β Multi Platform Network (read_only) β
β β β alice β BFD (read_only) β
β β β bob β Quantum IPsec (read_only) β
β β β mike β Multi-SA HSRP (read_only) β
ββββββββββββββΌββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β superusers β Superusers β admin β β
ββββββββββββββΌββββββββββββββββΌβββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β cryptopals β β alice β Quantum IPsec (read_only) β
β β β bob β Multi-SA HSRP (read_write) β
β β β mike β β
ββββββββββββββ§ββββββββββββββββ§βββββββββββ§βββββββββββββββββββββββββββββββββββββ
To delete one ore multiple groups
β― cml groups delete superusers cryptopals
Group superusers successfully deleted
Group cryptopals successfully deleted
β― cml groups ls
Groups on Server
ββββββββββ€ββββββββββββββββ€βββββββββββ€βββββββββββββββββββββββββββββββββββββ
β Name β Description β Users β Labs β
ββββββββββͺββββββββββββββββͺβββββββββββͺβββββββββββββββββββββββββββββββββββββ‘
β users β All Users β admin β nso-ha (read_only) β
β β β john β netbox (read_only) β
β β β bob β Multi Platform Network (read_only) β
β β β β BFD (read_only) β
β β β β Vodafone-PT (read_only) β
β β β β fastapi-ubuntu (read_only) β
β β β β upm-quick-test (read_only) β
β β β β Quantum IPsec (read_only) β
β β β β Multi-SA HSRP (read_only) β
ββββββββββ§ββββββββββββββββ§βββββββββββ§βββββββββββββββββββββββββββββββββββββ
[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)"
If you have an idea for a feature you would like to see, we gladly accept pull requests. To get started please review the Contributing Guide