Skip to main content

A python tool to deploy topology defined in a json config

Project description

topology-deployer

Python tool to deploy topologies from the defined json config files.

Table of Contents

  1. Prerequisites
  2. Network
    1. Management Network
    2. Custom NAT Network
    3. Isolated Network
  3. Virtual Manchines
  4. JSON Topology Config
    1. JSON Network Config
    2. JSON Virtual Machine Config

Prerequisites

Required Packages

sudo apt-get install -y bridge-utils libvirt-clients libvirt-daemon qemu qemu-kvm libvirt-dev libvirt-daemon-system libguestfs-tools virt-manager libosinfo-bin iptables-persistent python3-dev python3-pip

Add user to appropriate groups

sudo usermod -a -G libvirt $USER
sudo usermod -a -G libvirt-qemu $USER

Networks

  1. Management network
  2. Custom NAT network
  3. Isolated network

Libvirt implicitly installs a default NAT network. However libvirt's NAT network automatically inserts iptables rules whether you want them or not — in an order that is difficult to control — unless you disable the default network completely

Disbale libvirt's default network. We will create a Custom NAT Network.

virsh net-destroy default
virsh net-autostart --disable default

Management Network

This is a libvirt managed host only network used for SSH connections. During creation of VM, one of the network should be connected to virtual bridge for the management network.

Custom NAT Network

To overcome the challenges of libvirt's NAT network, we will create a Custom NAT network using four main components: a dummy network interface, a virtual bridge, some iptables rules, and dnsmasq.

Isolated Network

Isolated Network are completely private to guest systems. All the guests on same isolated network will be able to communicate to each other

Virtual Machines

For our topology we will create virtual machines using libvirt. There are 2 pre-defined flavors for VMs, which will have configured memory, vcpus and disk size. This can be overriden from the json config if required.

PE Virtual Machine

  1. Memory : 16G
  2. vCPUs : 8
  3. Disk : 80G

CE Virtual Machine

  1. Memory : 8G
  2. vCPUs : 4
  3. Disk : 40G

JSON Topology Config

The json config to define topologies comprises of 2 sections.

  1. Networks
  2. Virtual Machines

JSON Network Config

The JSON network object comprises of array of required type of networks. A network object skeleton is shown below

{
    "networks" : {
        "nat" : [],
        "isolated" : [],
        "management" : []
    }
}

Add NAT network in JSON network object

For nat network, name and subnet4 are mandatory fields. subnet6 is optional in case you need v6 network in your topology. To have multiple NAT networks, you can add multiple objects in the networks.nat json object.

{
    "networks" : {
        "nat" : [{
            "name" : "",
            "subnet4" : "",
            "subnet6" : ""
        }]
    }
}

Add Management network in JSON network object

For management network, name and subnet4 are mandatory fields. Currently we do not support v6 management network. To have multiple NAT networks, you can add multiple objects in the networks.management json object.

{
    "networks" : {
        "management" : [{
            "name" : "",
            "subnet4" : ""
        }]
    }
}

Add Isolated network in JSON network object

For isolated network, name is mandatory fields. To have multiple NAT networks, you can add multiple objects in the networks.isolated json object.

{
    "networks" : {
        "isolated" : [{
            "name" : ""
        }]
    }
}

JSON Virtual Machine Config

The vms object is array of multiple vm objects. For the vm object on the JSON config, name, flavor, vnc_port and networks are mandatory fields. You can optionally use ram, vcpus and disk to override the defaults for the flavor. A vms object skeleton is shown below

{
    "vms" : [{
        "name" : "",
        "flavor" : "",
        "vnc_port" : "",
        "networks" : {
            "<nw_name1>" : {
                "v4" : ""
            },
            "<nw_name2>" : {
                "v4" : "",
                "v6" : ""
            }
        }
    }]
}

To define networks for the vm, you have to use the network name as key and provide v4 address. You can also add a v6 address if the network type is NAT.

Sample Topology Configurations

A two PE and two CE topology

|-------|      |---------|                |---------|      |-------|
|  CE1  |======|   PE1   |================|   PE2   |======|  CE2  |
|       |======|         |================|         |======|       |
|-------|      |---------|                |---------|      |-------|

Topology Config : 2PE-CE.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

topology-deployer-0.0.1.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

topology_deployer-0.0.1-py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page