OpenContrail Virtual Environment Auto-Provisioning Script

Quickly setup a virtual environment on top of OpenContrail/OpenStack

(This script is not used to install OpenContrail ! – It installs a virtual environment on top of OpenContrail)

In order to quickly setup a virtual environment on top of OpenContrail/OpenStack, I enhanced an existing OpenContrail config script allowing to read a JSON file describing the environment to be setup.

The script uses the OpenContrail/OpenStack services client APIs which must be installed.

As of now the script supports:

– adding images
– creating aggregation zones
– creating flavors
– creating tenants/projects
– creating/assigning users and roles to tenants/projects
– creating networks, ipams, policies and floating pools
– creating bgp peers
– booting vms using the created objects from above

This example creates:

– a public Cirros image
– two aggregation zones (with one host per zone)
– two tenants
– one policy per tenant
– one ipam per tenant
– two private networks per tenant
– one floating public network per tenant
– two vms per tenant (one in each network and part of one aggregation zone)

Network, IPAM and policy object definitions are not specific to a tenant. Different tenants can use the same object definitions in order to instiate a tenant dedicated object (e.g. net1 & 2, pol1, ipam1 definitions are used by both tenants).

VM object definitions are specific to a tenant.

As of now there isn’t much failure handling. The script checks for the existence of the objects and continues if they already exist, however it doesn’t do any logical checks on the JSON fie.

For the future I plan to support service instances and templates as well as more specific policies. As said initial intention was to quickly spawn a base environment on which then can be fine-tuned.

Usage:

./orchestrator add configurator usecase2.json

Sample usage2.json:
 
 {
 "images":
 [
 {
 "name": "Cirros 0.3.2-2",
 "path": "/root/cirros-0.3.2-x86_64-disk.img",
 "disk_format": "qcow2",
 "container": "bare",
 "public": "True"
 }
 ],
 "networks":
 [
 {
 "name": "net1",
 "cidr": "192.168.1.0/24"
 },
 {
 "name": "net2",
 "cidr": "192.168.2.0/24"
 },
 {
 "name": "public1",
 "cidr": "172.16.1.0/24"
 },
 {
 "name": "public2",
 "cidr": "172.16.2.0/24"
 }
 ],
 "aggregates":
 [
 {
 "name": "zone1",
 "hosts":
 [
 {
 "name": "compute1"
 }
 ]
 },
 {
 "name": "zone2",
 "hosts":
 [
 {
 "name": "compute2"
 }
 ]
 }
 ],
 "policies":
 [
 {
 "name": "pol1"
 }
 ],
 "floating_pools":
 [
 {
 "name": "fp1"
 },
 {
 "name": "fp2"
 }
 ],
 "ipams":
 [
 {
 "name": "ipam1"
 }
 ],
 "flavors":
 [
 {
 "name": "nano",
 "ram": "64",
 "disk": "0",
 "vcpu": "1"
 }
 ],
 "tenants":
 [
 {
 "name": "tenant1",
 "user":
 [
 {
 "name": "admin",
 "group": "admin",
 "password": "admin"
 }
 ],
 "networks":
 [
 {
 "name": "net1",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "0",
 "fp": "0"
 },
 {
 "name": "net2",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "0",
 "fp": "0"
 },
 {
 "name": "public1",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "64512:10001",
 "fp": "fp1"
 }
 ]
 },
 {
 "name": "tenant2",
 "user":
 [
 {
 "name": "admin",
 "group": "admin",
 "password": "admin"
 }
 ],
 "networks":
 [
 {
 "name": "net1",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "0",
 "fp": "0"
 },
 {
 "name": "net2",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "0",
 "fp": "0"
 },
 {
 "name": "public2",
 "ipam": "ipam1",
 "policy": "pol1",
 "route-target": "64512:10002",
 "fp": "fp2"
 }
 ]
 }
 ],
 "vms":
 [
 {
 "name": "i1-tenant2",
 "networks":
 [
 {
 "name": "net1"
 }
 ],
 "floating":
 [
 {
 "name": "fp2",
 "nic": "net1"
 }
 ],
 "image": "Cirros 0.3.2-2",
 "flavor": "nano",
 "tenant": "tenant2",
 "zone": "zone1"
 },
 {
 "name": "i2-tenant2",
 "networks":
 [
 {
 "name": "net2"
 }
 ],
 "floating":
 [
 {
 "name": "fp2",
 "nic": "net2"
 }
 ],
 "image": "Cirros 0.3.2-2",
 "flavor": "nano",
 "tenant": "tenant2",
 "zone": "zone2"
 },
 {
 "name": "i1-tenant1",
 "networks":
 [
 {
 "name": "net1"
 }
 ],
 "floating":
 [
 {
 "name": "fp1",
 "nic": "net1"
 }
 ],
 "image": "Cirros 0.3.2-2",
 "flavor": "nano",
 "tenant": "tenant1",
 "zone": "zone1"
 },
 {
 "name": "i2-tenant1",
 "networks":
 [
 {
 "name": "net2"
 }
 ],
 "floating":
 [
 {
 "name": "fp1",
 "nic": "net2"
 }
 ],
 "image": "Cirros 0.3.2-2",
 "flavor": "nano",
 "tenant": "tenant1",
 "zone": "zone2"
 }
 ],
 "bgp_router":
 [
 {
 "name": "dcgw1",
 "ip": "192.168.18.13",
 "asn": "64512",
 "type": "other"
 }
 ]
 }

Attachmentsorch-agent.tar