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.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

topology_deployer-0.0.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file topology-deployer-0.0.2.tar.gz.

File metadata

  • Download URL: topology-deployer-0.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for topology-deployer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ad2c4e4bfb003b2bea54c0561ed049bce5d087e1088d35dab03fc0229b26b659
MD5 34cec4f905f35b2945fa7a312722fb50
BLAKE2b-256 98cb9f0aee82a4e3eb53a2281213dab342a785682b0b30e4ee7114bcd6ca9d19

See more details on using hashes here.

File details

Details for the file topology_deployer-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for topology_deployer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b628ec60732b2000accd1effcbd3692abaf7d317f759053a7fe8a2c35cd690
MD5 d048ac9dbbe99e4a59b2011c2e99d234
BLAKE2b-256 470ebacd8001f236c75dec61c769dcaaef23669743a5b1f2ca6b9fd4712e9d04

See more details on using hashes here.

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