Created
March 30, 2015 02:56
-
-
Save ajayhn/40ef4730737d32bee04f to your computer and use it in GitHub Desktop.
scale-setup-script-contrail_neutron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root@ci-upgrade-scale-prototype:~# vi scale-setup-script-contrail.py | |
| #!/usr/bin/python | |
| import os | |
| import uuid | |
| from vnc_api import vnc_api | |
| lib = vnc_api.VncApi('admin', 'secret123', 'scale-project-2', '127.0.0.1', '8082', '/') | |
| proj_obj = lib.project_read(fq_name=['default-domain', 'scale-project-2']) | |
| ipam_obj = lib.network_ipam_read(fq_name=['default-domain', 'default-project', | |
| 'default-network-ipam']) | |
| for idx in range(3000): | |
| vn_obj = vnc_api.VirtualNetwork('sp-net%s' %(str(idx+1)), proj_obj) | |
| vn_obj.uuid = str(uuid.uuid4()) | |
| pfx = '1.1.1.0' | |
| pfx_len = 24 | |
| default_gw = '1.1.1.1' | |
| subnet_vnc = vnc_api.IpamSubnetType(subnet=vnc_api.SubnetType(pfx, pfx_len), | |
| default_gateway=default_gw, | |
| enable_dhcp=True, | |
| dns_nameservers=None, | |
| addr_from_start=True, | |
| subnet_uuid=str(uuid.uuid4())) | |
| vnsn_data = vnc_api.VnSubnetsType([subnet_vnc]) | |
| vn_obj.add_network_ipam(ipam_obj, vnsn_data) | |
| lib.virtual_network_create(vn_obj) | |
| port_obj = vnc_api.VirtualMachineInterface('sp-port%s' %(str(idx+1)), | |
| parent_obj=proj_obj) | |
| port_obj.uuid = str(uuid.uuid4()) | |
| port_obj.add_virtual_network(vn_obj) | |
| lib.virtual_machine_interface_create(port_obj) | |
| iip_id = str(uuid.uuid4()) | |
| iip_obj = vnc_api.InstanceIp(name=iip_id) | |
| iip_obj.uuid = iip_id | |
| iip_obj.add_virtual_network(vn_obj) | |
| iip_obj.add_virtual_machine_interface(port_obj) | |
| lib.instance_ip_create(iip_obj) | |
| root@ci-upgrade-scale-prototype:~# more scale-setup-script-neutron.sh | |
| #!/bin/bash | |
| par_stride=1 | |
| for ((i=1; i<1001; i+=${par_stride})); do | |
| for ((par=0; par<${par_stride}; par++)); do | |
| net_num=$(expr ${i} + ${par}) | |
| (net_id=$(neutron net-create sp-net${net_num} | grep " id " | awk '{ print $4 }'); \ | |
| sn_id=$(neutron subnet-create ${net_id} 1.1.1.0/24); \ | |
| port_id=$(neutron port-create --name sp-port${net_num} ${net_id} | grep " id " | awk '{ print $4 }'); \ | |
| ) #& | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment