https://github.com/hellt/brvirt
brvirt displays bridges and enclosed interfaces along with corresponding KVM Virtual Machines names and virsh domain ids.
https://github.com/hellt/brvirt
Last synced: 8 months ago
JSON representation
brvirt displays bridges and enclosed interfaces along with corresponding KVM Virtual Machines names and virsh domain ids.
- Host: GitHub
- URL: https://github.com/hellt/brvirt
- Owner: hellt
- License: mit
- Created: 2016-12-28T13:45:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T06:33:07.000Z (over 9 years ago)
- Last Synced: 2025-03-25T18:40:35.634Z (about 1 year ago)
- Language: Python
- Homepage: http://noshut.ru/2016/12/brvirt-when-brctl-meets-virsh/
- Size: 3.91 KB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# About brvirt
`brvirt` displays bridges and enclosed interfaces along with corresponding
KVM Virtual Machines names and virsh domain ids.
It answers one simple question:
**How to determine which virtual interface belongs to which virtual
machine and what bridge it is in?"**

# Requirements
The script is compatible with `python2.7` and `python3+`.
- `brvirt` uses `virsh` tool to list VM properties and virtual network interfaces. To install `virsh` use:
```
# on Debian-based distros:
sudo apt-get install libvirt-bin
# on RHEL based:
sudo yum install libvirt
```
- Apart from virsh, the script relies on [tabulate](https://bitbucket.org/astanin/python-tabulate) python package to render console tables:
```shell
TABULATE_INSTALL=lib-only pip install tabulate
```
# Usage
As simple as `python brvirt.py`
will produce the following output which combines `brctl` and `virsh domiflist` commands output:
```
(brvirt) [root@leo ~]# python brvirt.py
+----------+---------------+-----------+-------------+--------------------+
| Bridge | Interface | VM name | Domain ID | Int. MAC address |
|----------+---------------+-----------+-------------+--------------------|
| br0 | eno1 | | | 28:80:23:90:ea:28 |
| | vnet0 | cobbler | 8 | 52:54:00:5a:a9:2c |
| | vnet4 | nuage-dns | 4 | 52:54:00:db:45:92 |
| br1 | eno2 | | | 28:80:23:90:ea:29 |
| | vnet1 | cobbler | 8 | 52:54:00:9b:c2:dc |
| br999 | eno2.999@eno2 | | | 28:80:23:90:ea:29 |
+----------+---------------+-----------+-------------+--------------------+
```