Skip to content

Instantly share code, notes, and snippets.

@ajayhn
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajayhn/2297979b619315f583ad to your computer and use it in GitHub Desktop.
Save ajayhn/2297979b619315f583ad to your computer and use it in GitHub Desktop.
Script to create 5000 VMs in 5000 Networks
#!/bin/bash
set -x
#mgmt_netid=$(neutron net-create mgmtnet | grep " id " | awk '{ print $4 }')
#neutron subnet-create --name mgmtsubnet $mgmt_netid 10.10.0.0/16
mgmt_netid=$(neutron net-show mgmtnet | grep " id " | awk '{ print $4 }')
for ((i=1501; i<4501; i=i+2)); do
netid1=$(neutron net-create scalenet$i | grep " id " | awk '{ print $4 }')
netid2=$(neutron net-create scalenet$(expr $i + 1) | grep " id " | awk '{ print $4 }')
snid1=$(neutron subnet-create --name scalesn$i $netid1 1.1.1.0/24 | grep " id " | awk '{ print $4 }')
snid2=$(neutron subnet-create --name scalesn$(expr $i + 1) $netid2 2.2.2.0/24 | grep " id " | awk '{ print $4 }')
rid=$(neutron router-create scalertr$i-$(expr $i + 1) | grep " id " | awk '{ print $4 }')
neutron router-interface-add $rid $snid1
neutron router-interface-add $rid $snid2
mpid=$(neutron port-create --name scalemgmtport$i $mgmt_netid | grep " id " | awk '{ print $4 }')
npid=$(neutron port-create --name scaleport$i $netid1 | grep " id " | awk '{ print $4 }')
#nova --debug boot --flavor 102 --availability-zone kvm-az --image TestVM_2Intf --nic port-id=${mpid} --nic port-id=${npid} scalevm${i}
sleep 3
mpid=$(neutron port-create --name scalemgmtport$(expr $i + 1) $mgmt_netid | grep " id " | awk '{ print $4 }')
npid=$(neutron port-create --name scaleport$(expr $i + 1) $netid2 | grep " id " | awk '{ print $4 }')
#nova --debug boot --flavor 102 --availability-zone kvm-az --image TestVM_2Intf --nic port-id=${mpid} --nic port-id=${npid} scalevm$(expr $i + 1)
sleep 3
#nova boot --flavor 101 --image TestVM_2Intf --nic net-id=$mgmt_netid --nic net-id=$netid1 scalevm${i} --availability-zone kvm-az
#sleep 8
#nova boot --flavor 101 --image TestVM_2Intf --nic net-id=$mgmt_netid --nic net-id=$netid2 scalevm$(expr $i + 1) --availability-zone kvm-az
#sleep 8
done
#nova list | grep scalevm | awk '{ print $2 }' | xargs nova delete
#for p in $(neutron port-list | grep scalemgmtport | awk '{ print $2 }'); do neutron port-delete $p; done
#for p in $(neutron port-list | grep scaleport | awk '{ print $2 }'); do neutron port-delete $p; done
#for r in $(neutron router-list | grep scalertr | awk '{ print $2 }'); do for x in $(neutron router-port-list $r | grep subnet_id | awk '{ print $9 }' | sed -e 's/"//g' -e 's/,//'); do neutron router-interface-delete $r $x; done; done
#for x in $(neutron net-list | grep scalenet | awk '{ print $2 }'); do neutron net-delete $x; done
#for x in $(neutron router-list | grep scalertr | awk '{ print $2 }'); do neutron router-delete $x; done
#neutron net-delete mgmtnet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment