Tools for working with VIRL. This is a loose collection of scripts that maybe useful when working with VIRL. Some in Python, some in Bash and even one for Windows. Here's a brief list of the scripts and what they are supposed to do. YMMV :)
For some of the tools it is required / useful to have a specific environment set and that the virl user is member of the libvirtd group:
sudo usermod -a -G libvirtd virl
echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >>.bashrc
logout and login again to make those changes effective.
capture.batThis is a Windows script that takes a tap interface name as input. It will then fire up putty to connect to your VIRL host, start a tcpdump on the given interface and then will feed the output of the tcpdump into a local copy of Wireshark. Prerequisites to make this work (and some values like paths to executables or IP addresses may have to be changed in the capture.bat file itself)- Putty installed (and the accompanying plink.exe)
- Wireshark installed
- known VIRL host IP address
- known tap interface name from where to capture packets. The tap interfaces must follow the following scheme 'tap00000000-00' where the digits are hex digits. See also
list.pyto identify those tap interfaces on the VIRL host.
capture.shThe corresponding Mac / Un*x shell script to do the same thing, namely start a tcpdump process on the VIRL host on a given tap interface, feed the packets into a named pipe. Wireshark needs to be started manually and it has to setup a named pipe interface via 'Capture -> Options', then 'Manage Interfaces', then on the 'Pipe' tab create a 'New' pipe interface pointing to the named pipe that has been created by the script.con.shconnects a Telnet session to the console of a router VM on the local VIRL host. It sets the escape sequence to Ctrl-\ instead of the default Ctrl-]. See alsoports.pyto identify the right port.ipv4.shshows all local interfaces on the VIRL host that have an IPv4 address attached.link.pyneeds a MAC address as a parameter and 'up' or 'down', e.g. from running 'show interface gi0/0' in a VM. This will enable or disable the given interface on the VM, like connecting or disconnecting the cable to the router interface. Note: Interface state is not reflected in XRv.list.pylists all interfaces of all running nodes / VMs of the user. The username must be given as a parameter to the script. The tap interfaces listed in the right column can be used to capture traffic, seecapture.batandcapture.sh.ports.pyshows all ports (VNC and Console information) of all running instances on a VIRL host. It also includes the Instance name of the libvirt instance which can be manipulated viavirshminion-key-reset.shusing the provided minion key file as a parameter (example AABBCCDD.virl.info.pem) this script will reset the minion key / configuration on the system.salt-test.pyhelps with troubleshooting Salt key related issues.user.shdefine required libvirtd environment variable for virsh.
Showing all interfaces of the user guest:
virl@virl-sandbox:~$ ./virl-utils/list.py guest
+-------------------+----------+--------+-------------------------+----------------+
| Project | Topology | Node | Link | Interface |
+-------------------+----------+--------+-------------------------+----------------+
| Sample_Topologies | Single | iosv-2 | Multipoint Connection-1 | tap2cff6fb2-5e |
| | | iosv-2 | Management Network | tap3dca55b5-f5 |
| | | iosv-2 | snat-1 | tap6dbe122c-d2 |
| | | iosv-3 | Management Network | tap603b92de-2b |
| | | iosv-3 | Multipoint Connection-1 | tapb419d5d7-43 |
| | | iosv-4 | Management Network | tap1473bb05-c8 |
| | | iosv-4 | Multipoint Connection-1 | tap9fdfb633-d6 |
| | | linux | Multipoint Connection-1 | tap27fed9a3-cb |
| | | linux | flat-1 | tap2d7a90b9-b6 |
| | | linux | Management Network | tap8f62596c-2c |
+-------------------+----------+--------+-------------------------+----------------+
virl@virl-sandbox:~$
Displaying ports of running simulations:
virl@virl-sandbox:~$ virl-utils/ports.py
+-------+-------------+----------+------+---------+-------------------+
| User | Topology | Node | VNC | Console | Instance Name |
+-------+-------------+----------+------+---------+-------------------+
| guest | eugene | iosxrv-1 | 5900 | 17000 | instance-0000002b |
| guest | eugene | iosxrv-2 | 5902 | 17003 | instance-0000002c |
| guest | eugene | iosxrv-3 | 5901 | 17006 | instance-0000002d |
| guest | eugene | iosxrv-4 | 5903 | 17009 | instance-0000002e |
| guest | germany-ers | iosv-1 | 5907 | 17018 | instance-00000032 |
| guest | germany-ers | iosv-2 | 5908 | 17020 | instance-00000033 |
| guest | germany-ers | iosv-3 | 5909 | 17022 | instance-00000034 |
| guest | germany-ers | iosv-4 | 5910 | 17024 | instance-00000035 |
| guest | germany-ers | iosv-5 | 5911 | 17026 | instance-00000036 |
| guest | germany-ers | iosv-6 | 5912 | 17028 | instance-00000037 |
| guest | topology | iosv-1 | 5904 | 17012 | instance-0000002f |
| guest | topology | iosv-2 | 5905 | 17014 | instance-00000030 |
| guest | topology | iosv-3 | 5906 | 17016 | instance-00000031 |
+-------+-------------+----------+------+---------+-------------------+
Enabling / disabling an interface for a given MAC address:
virl@virl-sandbox:~$ ./virl-utils/link.py fa16.3e3d.0092 down
Node Name for MAC 'fa:16:3e:3d:00:92':
</guest/endpoint>-<Sample_Topologies@single-T2IT_U>-<iosv-2>-<guest>
Domain Name: 'instance-00000001'
Interface updated!
virl@virl-sandbox:~$ ./virl-utils/link.py fa16.3e3d.0092 up
Node Name for MAC 'fa:16:3e:3d:00:92':
</guest/endpoint>-<Sample_Topologies@single-T2IT_U>-<iosv-2>-<guest>
Domain Name: 'instance-00000001'
Interface updated!
virl@virl-sandbox:~$