blob: 0f0ed216d0cc5644ff5cba6a42e0202b659bb190 [file] [log] [blame]
Sean M. Collins2a242512016-05-03 09:03:09 -04001#!/bin/bash
2# Subnet IP version
3IP_VERSION=${IP_VERSION:-"4+6"}
4# Validate IP_VERSION
5if [[ $IP_VERSION != "4" ]] && [[ $IP_VERSION != "6" ]] && [[ $IP_VERSION != "4+6" ]]; then
6 die $LINENO "IP_VERSION must be either 4, 6, or 4+6"
7fi
8# Specify if the initial private and external networks should be created
9NEUTRON_CREATE_INITIAL_NETWORKS=${NEUTRON_CREATE_INITIAL_NETWORKS:-True}
10
11## Provider Network Information
12PROVIDER_SUBNET_NAME=${PROVIDER_SUBNET_NAME:-"provider_net"}
13IPV6_PROVIDER_SUBNET_NAME=${IPV6_PROVIDER_SUBNET_NAME:-"provider_net_v6"}
14IPV6_PROVIDER_FIXED_RANGE=${IPV6_PROVIDER_FIXED_RANGE:-}
15IPV6_PROVIDER_NETWORK_GATEWAY=${IPV6_PROVIDER_NETWORK_GATEWAY:-}
16
17PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
18
19# If Q_USE_PUBLIC_VETH=True, create and use a veth pair instead of
20# PUBLIC_BRIDGE. This is intended to be used with
21# Q_USE_PROVIDERNET_FOR_PUBLIC=True.
22Q_USE_PUBLIC_VETH=${Q_USE_PUBLIC_VETH:-False}
23Q_PUBLIC_VETH_EX=${Q_PUBLIC_VETH_EX:-veth-pub-ex}
24Q_PUBLIC_VETH_INT=${Q_PUBLIC_VETH_INT:-veth-pub-int}
25
vsaienkod8942212016-05-13 12:51:30 +030026# The next variable is configured by plugin
Sean M. Collins2a242512016-05-03 09:03:09 -040027# e.g. _configure_neutron_l3_agent or lib/neutron_plugins/*
28#
Sean M. Collins2a242512016-05-03 09:03:09 -040029# L3 routers exist per tenant
30Q_L3_ROUTER_PER_TENANT=${Q_L3_ROUTER_PER_TENANT:-True}
31
32
33# Use flat providernet for public network
34#
35# If Q_USE_PROVIDERNET_FOR_PUBLIC=True, use a flat provider network
36# for external interface of neutron l3-agent. In that case,
37# PUBLIC_PHYSICAL_NETWORK specifies provider:physical_network value
38# used for the network. In case of ofagent, you should add the
39# corresponding entry to your OFAGENT_PHYSICAL_INTERFACE_MAPPINGS.
40# For openvswitch agent, you should add the corresponding entry to
41# your OVS_BRIDGE_MAPPINGS.
42#
43# eg. (ofagent)
44# Q_USE_PROVIDERNET_FOR_PUBLIC=True
45# Q_USE_PUBLIC_VETH=True
46# PUBLIC_PHYSICAL_NETWORK=public
47# OFAGENT_PHYSICAL_INTERFACE_MAPPINGS=public:veth-pub-int
48#
49# eg. (openvswitch agent)
50# Q_USE_PROVIDERNET_FOR_PUBLIC=True
51# PUBLIC_PHYSICAL_NETWORK=public
52# OVS_BRIDGE_MAPPINGS=public:br-ex
53Q_USE_PROVIDERNET_FOR_PUBLIC=${Q_USE_PROVIDERNET_FOR_PUBLIC:-False}
54PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK:-public}
55
56# Generate 40-bit IPv6 Global ID to comply with RFC 4193
57IPV6_GLOBAL_ID=`uuidgen | sed s/-//g | cut -c 23- | sed -e "s/\(..\)\(....\)\(....\)/\1:\2:\3/"`
58
59# IPv6 gateway and subnet defaults, in case they are not customized in localrc
60IPV6_RA_MODE=${IPV6_RA_MODE:-slaac}
61IPV6_ADDRESS_MODE=${IPV6_ADDRESS_MODE:-slaac}
62IPV6_PUBLIC_SUBNET_NAME=${IPV6_PUBLIC_SUBNET_NAME:-ipv6-public-subnet}
63IPV6_PRIVATE_SUBNET_NAME=${IPV6_PRIVATE_SUBNET_NAME:-ipv6-private-subnet}
64FIXED_RANGE_V6=${FIXED_RANGE_V6:-fd$IPV6_GLOBAL_ID::/64}
65IPV6_PRIVATE_NETWORK_GATEWAY=${IPV6_PRIVATE_NETWORK_GATEWAY:-fd$IPV6_GLOBAL_ID::1}
66IPV6_PUBLIC_RANGE=${IPV6_PUBLIC_RANGE:-2001:db8::/64}
67IPV6_PUBLIC_NETWORK_GATEWAY=${IPV6_PUBLIC_NETWORK_GATEWAY:-2001:db8::2}
68IPV6_ROUTER_GW_IP=${IPV6_ROUTER_GW_IP:-2001:db8::1}
69
70# Gateway and subnet defaults, in case they are not customized in localrc
71NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
72PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.1}
73PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
74PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"}
75
76# Subnetpool defaults
77SUBNETPOOL_NAME=${SUBNETPOOL_NAME:-"shared-default-subnetpool"}
78
79SUBNETPOOL_PREFIX_V4=${SUBNETPOOL_PREFIX_V4:-10.0.0.0/8}
80SUBNETPOOL_PREFIX_V6=${SUBNETPOOL_PREFIX_V6:-2001:db8:8000::/48}
81
82SUBNETPOOL_SIZE_V4=${SUBNETPOOL_SIZE_V4:-24}
83SUBNETPOOL_SIZE_V6=${SUBNETPOOL_SIZE_V6:-64}
84
85function _determine_config_l3 {
Angus Leesa1c70f22016-05-31 14:43:14 +100086 local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE"
Sean M. Collins2a242512016-05-03 09:03:09 -040087 echo "$opts"
88}
89
90function _configure_neutron_l3_agent {
Sean M. Collins2a242512016-05-03 09:03:09 -040091
92 cp $NEUTRON_DIR/etc/l3_agent.ini.sample $Q_L3_CONF_FILE
93
Sean M. Collins2a242512016-05-03 09:03:09 -040094 iniset $Q_L3_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sean M. Collinsa2ed0552016-05-11 15:35:10 -040095 iniset $Q_L3_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
Sean M. Collins2a242512016-05-03 09:03:09 -040096 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
Sean M. Collinsa2ed0552016-05-11 15:35:10 -040097 iniset $Q_L3_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND"
Sean M. Collins2a242512016-05-03 09:03:09 -040098 fi
99
100 _neutron_setup_interface_driver $Q_L3_CONF_FILE
101
Stephen Finucane24e29f22016-06-15 14:31:51 +0100102 neutron_plugin_configure_l3_agent $Q_L3_CONF_FILE
Sean M. Collins2a242512016-05-03 09:03:09 -0400103
Sean M. Collinsa2ed0552016-05-11 15:35:10 -0400104 _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True False "inet"
Sean M. Collins2a242512016-05-03 09:03:09 -0400105
106 if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then
Sean M. Collinsa2ed0552016-05-11 15:35:10 -0400107 _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6"
Sean M. Collins2a242512016-05-03 09:03:09 -0400108 fi
109}
110
111# Explicitly set router id in l3 agent configuration
112function _neutron_set_router_id {
113 if [[ "$Q_L3_ROUTER_PER_TENANT" == "False" ]]; then
114 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
115 fi
116}
117
118# Get ext_gw_interface depending on value of Q_USE_PUBLIC_VETH
119function _neutron_get_ext_gw_interface {
120 if [[ "$Q_USE_PUBLIC_VETH" == "True" ]]; then
121 echo $Q_PUBLIC_VETH_EX
122 else
123 # Disable in-band as we are going to use local port
124 # to communicate with VMs
125 sudo ovs-vsctl set Bridge $PUBLIC_BRIDGE \
126 other_config:disable-in-band=true
127 echo $PUBLIC_BRIDGE
128 fi
129}
130
131function create_neutron_initial_network {
132 local project_id
133 project_id=$(openstack project list | grep " demo " | get_field 1)
134 die_if_not_set $LINENO project_id "Failure retrieving project_id for demo"
135
136 # Allow drivers that need to create an initial network to do so here
137 if type -p neutron_plugin_create_initial_network_profile > /dev/null; then
138 neutron_plugin_create_initial_network_profile $PHYSICAL_NETWORK
139 fi
140
141 if is_provider_network; then
142 die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK"
143 die_if_not_set $LINENO PROVIDER_NETWORK_TYPE "You must specify the PROVIDER_NETWORK_TYPE"
144 NET_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" net-create $PHYSICAL_NETWORK --tenant_id $project_id --provider:network_type $PROVIDER_NETWORK_TYPE --provider:physical_network "$PHYSICAL_NETWORK" ${SEGMENTATION_ID:+--provider:segmentation_id $SEGMENTATION_ID} --shared | grep ' id ' | get_field 2)
145 die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $project_id"
146
147 if [[ "$IP_VERSION" =~ 4.* ]]; then
148 SUBNET_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create --tenant_id $project_id --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --name $PROVIDER_SUBNET_NAME --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
149 die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $PROVIDER_SUBNET_NAME $project_id"
150 fi
151
Sean M. Collinse34ec992016-06-07 12:36:50 -0400152 if [[ "$IP_VERSION" =~ .*6 ]]; then
153 die_if_not_set $LINENO IPV6_PROVIDER_FIXED_RANGE "IPV6_PROVIDER_FIXED_RANGE has not been set, but Q_USE_PROVIDERNET_FOR_PUBLIC is true and IP_VERSION includes 6"
154 die_if_not_set $LINENO IPV6_PROVIDER_NETWORK_GATEWAY "IPV6_PROVIDER_NETWORK_GATEWAY has not been set, but Q_USE_PROVIDERNET_FOR_PUBLIC is true and IP_VERSION includes 6"
Sean M. Collins2a242512016-05-03 09:03:09 -0400155 SUBNET_V6_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create --tenant_id $project_id --ip_version 6 --ipv6-address-mode $IPV6_ADDRESS_MODE --gateway $IPV6_PROVIDER_NETWORK_GATEWAY --name $IPV6_PROVIDER_SUBNET_NAME $NET_ID $IPV6_PROVIDER_FIXED_RANGE | grep 'id' | get_field 2)
156 die_if_not_set $LINENO SUBNET_V6_ID "Failure creating SUBNET_V6_ID for $IPV6_PROVIDER_SUBNET_NAME $project_id"
157 fi
158
159 if [[ $Q_AGENT == "openvswitch" ]]; then
160 sudo ip link set $OVS_PHYSICAL_BRIDGE up
161 sudo ip link set br-int up
162 sudo ip link set $PUBLIC_INTERFACE up
163 fi
164 else
165 NET_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" net-create --tenant-id $project_id "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
166 die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PRIVATE_NETWORK_NAME $project_id"
167
168 if [[ "$IP_VERSION" =~ 4.* ]]; then
169 # Create IPv4 private subnet
170 SUBNET_ID=$(_neutron_create_private_subnet_v4 $project_id)
171 fi
172
173 if [[ "$IP_VERSION" =~ .*6 ]]; then
174 # Create IPv6 private subnet
175 IPV6_SUBNET_ID=$(_neutron_create_private_subnet_v6 $project_id)
176 fi
177 fi
178
Sean M. Collinsc35110e2016-05-18 10:38:51 -0400179 if is_networking_extension_supported "router" && is_networking_extension_supported "external-net"; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400180 # Create a router, and add the private subnet as one of its interfaces
181 if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
182 # create a tenant-owned router.
183 ROUTER_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-create --tenant-id $project_id $Q_ROUTER_NAME | grep ' id ' | get_field 2)
184 die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $project_id $Q_ROUTER_NAME"
185 else
186 # Plugin only supports creating a single router, which should be admin owned.
187 ROUTER_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
188 die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
189 fi
190
Sean M. Collins2a242512016-05-03 09:03:09 -0400191 EXTERNAL_NETWORK_FLAGS="--router:external"
Sean M. Collinsc35110e2016-05-18 10:38:51 -0400192 if is_networking_extension_supported "auto-allocated-topology" && is_networking_extension_supported "subnet_allocation"; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400193 EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default"
194 if [[ "$IP_VERSION" =~ 4.* ]]; then
195 SUBNETPOOL_V4_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnetpool-create $SUBNETPOOL_NAME --default-prefixlen $SUBNETPOOL_SIZE_V4 --pool-prefix $SUBNETPOOL_PREFIX_V4 --shared --is-default=True | grep ' id ' | get_field 2)
196 fi
197 if [[ "$IP_VERSION" =~ .*6 ]]; then
198 SUBNETPOOL_V6_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnetpool-create $SUBNETPOOL_NAME --default-prefixlen $SUBNETPOOL_SIZE_V6 --pool-prefix $SUBNETPOOL_PREFIX_V6 --shared --is-default=True | grep ' id ' | get_field 2)
199 fi
200 fi
201 # Create an external network, and a subnet. Configure the external network as router gw
202 if [ "$Q_USE_PROVIDERNET_FOR_PUBLIC" = "True" ]; then
203 EXT_NET_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" net-create "$PUBLIC_NETWORK_NAME" -- $EXTERNAL_NETWORK_FLAGS --provider:network_type=flat --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} | grep ' id ' | get_field 2)
204 else
205 EXT_NET_ID=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" net-create "$PUBLIC_NETWORK_NAME" -- $EXTERNAL_NETWORK_FLAGS | grep ' id ' | get_field 2)
206 fi
207 die_if_not_set $LINENO EXT_NET_ID "Failure creating EXT_NET_ID for $PUBLIC_NETWORK_NAME"
208
209 if [[ "$IP_VERSION" =~ 4.* ]]; then
210 # Configure router for IPv4 public access
211 _neutron_configure_router_v4
212 fi
213
214 if [[ "$IP_VERSION" =~ .*6 ]]; then
215 # Configure router for IPv6 public access
216 _neutron_configure_router_v6
217 fi
218 fi
219}
220
221# Create private IPv4 subnet
222function _neutron_create_private_subnet_v4 {
223 local project_id=$1
224 local subnet_params="--tenant-id $project_id "
225 subnet_params+="--ip_version 4 "
226 subnet_params+="--gateway $NETWORK_GATEWAY "
227 subnet_params+="--name $PRIVATE_SUBNET_NAME "
228 subnet_params+="$NET_ID $FIXED_RANGE"
229 local subnet_id
230 subnet_id=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep ' id ' | get_field 2)
231 die_if_not_set $LINENO subnet_id "Failure creating private IPv4 subnet for $project_id"
232 echo $subnet_id
233}
234
235# Create private IPv6 subnet
236function _neutron_create_private_subnet_v6 {
237 local project_id=$1
238 die_if_not_set $LINENO IPV6_RA_MODE "IPV6 RA Mode not set"
239 die_if_not_set $LINENO IPV6_ADDRESS_MODE "IPV6 Address Mode not set"
240 local ipv6_modes="--ipv6-ra-mode $IPV6_RA_MODE --ipv6-address-mode $IPV6_ADDRESS_MODE"
241 local subnet_params="--tenant-id $project_id "
242 subnet_params+="--ip_version 6 "
243 subnet_params+="--gateway $IPV6_PRIVATE_NETWORK_GATEWAY "
244 subnet_params+="--name $IPV6_PRIVATE_SUBNET_NAME "
245 subnet_params+="$NET_ID $FIXED_RANGE_V6 $ipv6_modes"
246 local ipv6_subnet_id
247 ipv6_subnet_id=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep ' id ' | get_field 2)
248 die_if_not_set $LINENO ipv6_subnet_id "Failure creating private IPv6 subnet for $project_id"
249 echo $ipv6_subnet_id
250}
251
252# Create public IPv4 subnet
253function _neutron_create_public_subnet_v4 {
254 local subnet_params+="--ip_version 4 "
255 subnet_params+="${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} "
256 subnet_params+="--gateway $PUBLIC_NETWORK_GATEWAY "
257 subnet_params+="--name $PUBLIC_SUBNET_NAME "
258 subnet_params+="$EXT_NET_ID $FLOATING_RANGE "
259 subnet_params+="-- --enable_dhcp=False"
260 local id_and_ext_gw_ip
261 id_and_ext_gw_ip=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep -e 'gateway_ip' -e ' id ')
262 die_if_not_set $LINENO id_and_ext_gw_ip "Failure creating public IPv4 subnet"
263 echo $id_and_ext_gw_ip
264}
265
266# Create public IPv6 subnet
267function _neutron_create_public_subnet_v6 {
268 local subnet_params="--ip_version 6 "
269 subnet_params+="--gateway $IPV6_PUBLIC_NETWORK_GATEWAY "
270 subnet_params+="--name $IPV6_PUBLIC_SUBNET_NAME "
271 subnet_params+="$EXT_NET_ID $IPV6_PUBLIC_RANGE "
272 subnet_params+="-- --enable_dhcp=False"
273 local ipv6_id_and_ext_gw_ip
274 ipv6_id_and_ext_gw_ip=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep -e 'gateway_ip' -e ' id ')
275 die_if_not_set $LINENO ipv6_id_and_ext_gw_ip "Failure creating an IPv6 public subnet"
276 echo $ipv6_id_and_ext_gw_ip
277}
278
279# Configure neutron router for IPv4 public access
280function _neutron_configure_router_v4 {
281 neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-interface-add $ROUTER_ID $SUBNET_ID
282 # Create a public subnet on the external network
283 local id_and_ext_gw_ip
284 id_and_ext_gw_ip=$(_neutron_create_public_subnet_v4 $EXT_NET_ID)
285 local ext_gw_ip
286 ext_gw_ip=$(echo $id_and_ext_gw_ip | get_field 2)
287 PUB_SUBNET_ID=$(echo $id_and_ext_gw_ip | get_field 5)
288 # Configure the external network as the default router gateway
289 neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-gateway-set $ROUTER_ID $EXT_NET_ID
290
291 # This logic is specific to using the l3-agent for layer 3
292 if is_service_enabled q-l3; then
293 # Configure and enable public bridge
294 local ext_gw_interface="none"
295 if is_neutron_ovs_base_plugin; then
296 ext_gw_interface=$(_neutron_get_ext_gw_interface)
297 elif [[ "$Q_AGENT" = "linuxbridge" ]]; then
298 # Search for the brq device the neutron router and network for $FIXED_RANGE
299 # will be using.
300 # e.x. brq3592e767-da for NET_ID 3592e767-da66-4bcb-9bec-cdb03cd96102
301 ext_gw_interface=brq${EXT_NET_ID:0:11}
302 fi
303 if [[ "$ext_gw_interface" != "none" ]]; then
304 local cidr_len=${FLOATING_RANGE#*/}
305 local testcmd="ip -o link | grep -q $ext_gw_interface"
306 test_with_retry "$testcmd" "$ext_gw_interface creation failed"
307 if [[ $(ip addr show dev $ext_gw_interface | grep -c $ext_gw_ip) == 0 && ( $Q_USE_PROVIDERNET_FOR_PUBLIC == "False" || $Q_USE_PUBLIC_VETH == "True" ) ]]; then
308 sudo ip addr add $ext_gw_ip/$cidr_len dev $ext_gw_interface
309 sudo ip link set $ext_gw_interface up
310 fi
311 ROUTER_GW_IP=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F'ip_address' '{ print $2 }' | cut -f3 -d\" | tr '\n' ' ')
312 die_if_not_set $LINENO ROUTER_GW_IP "Failure retrieving ROUTER_GW_IP"
313 sudo ip route replace $FIXED_RANGE via $ROUTER_GW_IP
314 fi
315 _neutron_set_router_id
316 fi
317}
318
319# Configure neutron router for IPv6 public access
320function _neutron_configure_router_v6 {
321 neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-interface-add $ROUTER_ID $IPV6_SUBNET_ID
322 # Create a public subnet on the external network
323 local ipv6_id_and_ext_gw_ip
324 ipv6_id_and_ext_gw_ip=$(_neutron_create_public_subnet_v6 $EXT_NET_ID)
325 local ipv6_ext_gw_ip
326 ipv6_ext_gw_ip=$(echo $ipv6_id_and_ext_gw_ip | get_field 2)
327 local ipv6_pub_subnet_id
328 ipv6_pub_subnet_id=$(echo $ipv6_id_and_ext_gw_ip | get_field 5)
329
330 # If the external network has not already been set as the default router
331 # gateway when configuring an IPv4 public subnet, do so now
332 if [[ "$IP_VERSION" == "6" ]]; then
333 neutron --os-cloud devstack-admin --os-region "$REGION_NAME" router-gateway-set $ROUTER_ID $EXT_NET_ID
334 fi
335
336 # This logic is specific to using the l3-agent for layer 3
337 if is_service_enabled q-l3; then
338 # Ensure IPv6 forwarding is enabled on the host
339 sudo sysctl -w net.ipv6.conf.all.forwarding=1
340 # Configure and enable public bridge
341 # Override global IPV6_ROUTER_GW_IP with the true value from neutron
342 IPV6_ROUTER_GW_IP=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" port-list -c fixed_ips | grep $ipv6_pub_subnet_id | awk -F'ip_address' '{ print $2 }' | cut -f3 -d\" | tr '\n' ' ')
343 die_if_not_set $LINENO IPV6_ROUTER_GW_IP "Failure retrieving IPV6_ROUTER_GW_IP"
344
345 if is_neutron_ovs_base_plugin; then
346 local ext_gw_interface
347 ext_gw_interface=$(_neutron_get_ext_gw_interface)
348 local ipv6_cidr_len=${IPV6_PUBLIC_RANGE#*/}
349
350 # Configure interface for public bridge
351 sudo ip -6 addr add $ipv6_ext_gw_ip/$ipv6_cidr_len dev $ext_gw_interface
352 sudo ip -6 route replace $FIXED_RANGE_V6 via $IPV6_ROUTER_GW_IP dev $ext_gw_interface
353 fi
354 _neutron_set_router_id
355 fi
356}
watanabe.isao4f4d95a2016-05-12 20:35:20 +0900357
358function is_provider_network {
vsaienkod8942212016-05-13 12:51:30 +0300359 if [ "$Q_USE_PROVIDER_NETWORKING" == "True" ]; then
watanabe.isao4f4d95a2016-05-12 20:35:20 +0900360 return 0
361 fi
362 return 1
363}
Sean M. Collinsc35110e2016-05-18 10:38:51 -0400364
365function is_networking_extension_supported {
366 local extension=$1
367 # TODO(sc68cal) cache this instead of calling every time
368 EXT_LIST=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list -c alias -f value)
369 [[ $EXT_LIST =~ $extension ]] && return 0
370}