Andy Bavier | 8cca347 | 2015-04-15 16:55:38 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 2 | |
Andy Bavier | 8cca347 | 2015-04-15 16:55:38 -0400 | [diff] [blame] | 3 | source ~/admin-openrc.sh |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 4 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 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 | } |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 13 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 14 | function create-subnet { |
| 15 | NAME=$1 |
| 16 | CIDR=$2 |
| 17 | GW=$3 |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 18 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 19 | neutron subnet-show $NAME-net 2>&1 > /dev/null |
| 20 | if [ "$?" -ne 0 ] |
| 21 | then |
Andy Bavier | 000adf1 | 2015-09-17 16:21:39 -0400 | [diff] [blame] | 22 | neutron subnet-create $NAME-net --name $NAME-net $CIDR --gateway=$GW --disable-dhcp |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 23 | fi |
| 24 | } |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 25 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 26 | function create-subnet-no-gateway { |
| 27 | NAME=$1 |
| 28 | CIDR=$2 |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 29 | |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 30 | neutron subnet-show $NAME-net 2>&1 > /dev/null |
| 31 | if [ "$?" -ne 0 ] |
| 32 | then |
Andy Bavier | 000adf1 | 2015-09-17 16:21:39 -0400 | [diff] [blame] | 33 | neutron subnet-create $NAME-net --name $NAME-net $CIDR --no-gateway --disable-dhcp |
Andy Bavier | cccf27b | 2015-08-17 14:48:29 -0400 | [diff] [blame] | 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 |