Automated virtual network generation in golang utilising QEMU virtulisation and KVM hardware acceleration
- Command line based application
- Automated network virtualisation with KVM and QEMU
- YAML-defined network-host topology configuration
- Create, run and manage multiple deployment topologies
- Data persistence
- RestApi server mode for remote connection.
- Log management
- Supported on Linux only
Install KVM and Qemu
sudo apt install -v qemu libvirt-client libvirt-dev cloud-utils
sudo pacman -S qemu libvirt cloud-utils
Create custom topologies with yaml templates. Simply add networks, hosts and then assign networks to hosts as per the default.yaml example:
---
# Deploymnet Configuration
deployment:
name: default
# Network Configuration
networks:
- name: br0
netaddr: "20.0.0.1"
dhcplower: "20.0.0.2"
dhcpupper: "20.0.0.254"
netmask: "255.255.255.0"
type: "nat"
#Hosts Configuration
hosts:
- name: master1
image: ubuntu
ram: 2048
cpus: 2
hd: "10G"
username: dev
password: ved
networks:
- br0
- name: master2
image: ubuntu
ram: 2048
cpus: 2
hd: "10G"
username: dev
password: ved
networks:
- br0
# Clone repository
$ git clone https://github.com/Kenjasim/vngen.git
$ cd vngen
# Build application binaries
$ go build -o vngen cmd/vngen/vngen.go
# Add vngen application to PATH
$ mv vngen /usr/local/bin
sudo vngen build </path/to/template> # default.yaml
sudo vngen start [deployment|host] <name>
sudo vngen stop [deployment|host] <name>
sudo vngen restart [deployment|host] <name>
sudo vngen destroy [deployment|host] <name>
You can display hosts, networks, and IPs
sudo vngen get hosts
sudo vngen get networks
sudo vngen get ips
[i] Getting hosts
Name VMState Image RAM CPU Storage Deployment
master1 off ubuntu 2048 2 10G default
master2 off ubuntu 2048 2 10G default
[i] Getting networks
Name Type IP DHCP Range Deployment
br0 nat 20.0.0.1 20.0.0.2 - 20.0.0.254 default
[i] Getting ips
Name Interface MacAddr IPs Deployment
master1 vnet0 52:54:00:2b:76:8f 20.0.0.141 default
master2 vnet1 52:54:00:ed:90:f9 20.0.0.88 default
The RestAPI Server enables remote access to the application either through AVN's client mode, or via direct http (localhost), https (remote) requests.
To launch the server just run the command on the binary
sudo vngen api
# Or you can specify the port
sudo go run cmd/vngen/vngen.go api -p 30675
You need to send a PUT
request with a jsonified version of a YAML template file, an example can be seen below:
{
"deployment": {
"name": "default"
},
"networks": [
{
"name": "br0",
"netaddr": "20.0.0.1",
"dhcplower": "20.0.0.2",
"dhcpupper": "20.0.0.254",
"netmask": "255.255.255.0",
"type": "nat"
}
],
"hosts": [
{
"name": "master1",
"image": "ubuntu",
"ram": 2048,
"cpus": 2,
"hd": "10G",
"username": "dev",
"password": "ved",
"networks": [
"br0"
]
},
{
"name": "master2",
"image": "ubuntu",
"ram": 2048,
"cpus": 2,
"hd": "10G",
"username": "dev",
"password": "ved",
"networks": [
"br0"
]
}
]
}
You can then pass this to the endpoint as a post request with the header set as application/json
http://localhost:8000/build
These 4 commands follow the same trend, all must be sent as POST
requests and all have a simmilar structure.
http://localhost:8000/<start|stop|restart|destroy>/<deployment|host>/[name]
http://localhost:8000/start/deployment/default
To get a list of all defined hosts or networks you can use this URL endpoint:
http://localhost:8000/hosts
http://localhost:8000/networks
To get more details about one host you can use:
http://localhost:8000/details/[name]
Finally, to get the IP of a host you can use:
http://localhost:8000/details/[name]/ipv4
These should all be run as GET
requests