Skip to content

Instantly share code, notes, and snippets.

@dougbtv
Created November 9, 2016 18:24
Show Gist options
  • Save dougbtv/046b8a706d03d2737b4048c45d92a70b to your computer and use it in GitHub Desktop.
Save dougbtv/046b8a706d03d2737b4048c45d92a70b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Definitions....
EXTERNAL_SUBNET_NAME=ext-net
INTERNAL_SUBNET_NAME=int
ROUTER_NAME=router1
POOL_START=100
POOL_END=120
INTERNAL_CIDR=30.0.0.0/24
DNS_SERVERS=8.8.8.8
echo "Get undercloud subnet..."
source stackrc
subnet_cidr=$(neutron subnet-list | grep -P "\d" | perl -p -i -e 's|^.+\s([\d\.]+/\d+)\s.+$|$1|')
subnet_class_c=$(echo $subnet_cidr | perl -p -i -e 's|^(.+)\..+$|$1|')
echo "Create overcloud external subnet"
source ~/overcloudrc
neutron net-create $EXTERNAL_SUBNET_NAME --router:external --provider:physical_network datacentre --provider:network_type flat
neutron subnet-create $EXTERNAL_SUBNET_NAME --name ext-subnet --allocation-pool start=$subnet_class_c.$POOL_START,end=$subnet_class_c.$POOL_END --disable-dhcp --gateway $subnet_class_c.1 $subnet_cidr
neutron router-create $ROUTER_NAME
neutron router-gateway-set $ROUTER_NAME $EXTERNAL_SUBNET_NAME
echo "Create overcloud internal (openshift) subnet"
neutron net-create $INTERNAL_SUBNET_NAME
neutron subnet-create $INTERNAL_SUBNET_NAME $INTERNAL_CIDR --dns_nameservers list=true $DNS_SERVERS
internal_subnet_id=$(neutron subnet-list | grep $INTERNAL_CIDR | awk '{print $2}')
neutron router-interface-add $ROUTER_NAME $internal_subnet_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment