Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | source ~/admin-openrc.sh |
| 4 | |
| 5 | function create-flat-net { |
| 6 | NAME=$1 |
| 7 | neutron net-show $NAME-net 2>&1 > /dev/null |
| 8 | if [ "$?" -ne 0 ] |
| 9 | then |
| 10 | neutron net-create --provider:physical_network=$NAME --provider:network_type=flat --shared $NAME-net |
| 11 | fi |
| 12 | } |
| 13 | |
| 14 | function create-subnet { |
| 15 | NAME=$1 |
| 16 | CIDR=$2 |
| 17 | GW=$3 |
| 18 | |
| 19 | neutron subnet-show $NAME-net 2>&1 > /dev/null |
| 20 | if [ "$?" -ne 0 ] |
| 21 | then |
| 22 | neutron subnet-create $NAME-net --name $NAME-net $CIDR --gateway=$GW --disable-dhcp |
| 23 | fi |
| 24 | } |
| 25 | |
| 26 | function create-subnet-no-gateway { |
| 27 | NAME=$1 |
| 28 | CIDR=$2 |
| 29 | |
| 30 | neutron subnet-show $NAME-net 2>&1 > /dev/null |
| 31 | if [ "$?" -ne 0 ] |
| 32 | then |
| 33 | neutron subnet-create $NAME-net --name $NAME-net $CIDR --no-gateway --disable-dhcp |
| 34 | fi |
| 35 | } |
| 36 | |
| 37 | create-flat-net nat |
| 38 | create-subnet nat 172.16.0.0/16 172.16.0.1 |
| 39 | |
| 40 | create-flat-net ext |