Comment 2 for bug 1419175

Revision history for this message
Zengfa Gao (zfgao) wrote : Re: DVR qrouter created without OVS qr device

Here is the script I run several times, I saw it happens once a while:

neutron net-create zengfa-net
netzengfaid=$(neutron net-list | awk '{if($4=="'zengfa-net'"){print $2;}}')
neutron subnet-create zengfa-net 10.100.100.0/24 --name zengfa-subnet
subnetzengfaid=$(neutron subnet-list | awk '{if($4=="'zengfa-subnet'"){print $2;}}')
neutron router-create zengfa-router
routerzengfaid=$(neutron router-list | awk '{if($4=="'zengfa-router'"){print $2;}}')

exnetid=$(neutron net-list | awk '{if($4=="'ext-net'"){print $2;}}')
for i in `seq 1 10`; do
    #boot vm, and create floating ip
    nova boot --image cirros --flavor m1.tiny --nic net-id=$netzengfaid cirroszengfa${i}
    cirroszengfaid[i]=$(nova list | awk '{if($4=="'cirroszengfa${i}'"){print $2;}}')
    output=$(neutron floatingip-create $exnetid)
    echo $output
    floatipid[i]=$(echo "$output" | awk '{if($2=="id"){print $4;}}')
    floatip[i]=$(echo "$output" | awk '{if($2=="floating_ip_address"){print $4;}}')a
done

# Setup router
neutron router-gateway-set $routerzengfaid $exnetid
neutron router-interface-add zengfa-router $subnetzengfaid
#wait for VM to be running
sleep 30

for i in `seq 1 10`; do
    cirrosfix=$(nova list | awk '{if($4=="'cirroszengfa${i}'"){print $12;}}')
    cirrosfixip=${cirrosfix#*=}
    output=$(neutron port-list | grep ${cirrosfixip})
    echo $output
    portid=$(echo "$output" | awk '{print $2;}')
    neutron floatingip-associate --fixed-ip-address $cirrosfixip ${floatipid[i]} $portid
    neutron floatingip-delete ${floatipid[i]}
    nova delete ${cirroszengfaid[i]}
done

neutron router-interface-delete zengfa-router $subnetzengfaid
neutron router-gateway-clear zengfa-router $netzengfaid
neutron router-delete zengfa-router
neutron subnet-delete $subnetzengfaid
neutron net-delete $netzengfaid