Browse code

Merge "Make the Neutron l3 plugin use the subnetpools"

Jenkins authored on 2016/09/27 00:01:16
Showing 1 changed files
... ...
@@ -167,6 +167,15 @@ function create_neutron_initial_network {
167 167
         neutron_plugin_create_initial_network_profile $PHYSICAL_NETWORK
168 168
     fi
169 169
 
170
+    if is_networking_extension_supported "auto-allocated-topology"; then
171
+        if [[ "$IP_VERSION" =~ 4.* ]]; then
172
+            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)
173
+        fi
174
+        if [[ "$IP_VERSION" =~ .*6 ]]; then
175
+            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)
176
+        fi
177
+    fi
178
+
170 179
     if is_provider_network; then
171 180
         die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK"
172 181
         die_if_not_set $LINENO PROVIDER_NETWORK_TYPE "You must specify the PROVIDER_NETWORK_TYPE"
... ...
@@ -174,14 +183,20 @@ function create_neutron_initial_network {
174 174
         die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $project_id"
175 175
 
176 176
         if [[ "$IP_VERSION" =~ 4.* ]]; then
177
-            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)
177
+            if [ -z $SUBNETPOOL_V4_ID ]; then
178
+                fixed_range_v4=$FIXED_RANGE
179
+            fi
180
+            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 ${SUBNETPOOL_V4_ID:+--subnetpool $SUBNETPOOL_V4_ID} $NET_ID $fixed_range_v4 | grep ' id ' | get_field 2)
178 181
             die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $PROVIDER_SUBNET_NAME $project_id"
179 182
         fi
180 183
 
181 184
         if [[ "$IP_VERSION" =~ .*6 ]]; then
182 185
             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"
183 186
             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"
184
-            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)
187
+            if [ -z $SUBNETPOOL_V6_ID ]; then
188
+                fixed_range_v6=$IPV6_PROVIDER_FIXED_RANGE
189
+            fi
190
+            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 ${SUBNETPOOL_V6_ID:+--subnetpool $SUBNETPOOL_V6_ID} $NET_ID $fixed_range_v6 | grep 'id' | get_field 2)
185 191
             die_if_not_set $LINENO SUBNET_V6_ID "Failure creating SUBNET_V6_ID for $IPV6_PROVIDER_SUBNET_NAME $project_id"
186 192
         fi
187 193
 
... ...
@@ -218,14 +233,8 @@ function create_neutron_initial_network {
218 218
         fi
219 219
 
220 220
         EXTERNAL_NETWORK_FLAGS="--router:external"
221
-        if is_networking_extension_supported "auto-allocated-topology" && is_networking_extension_supported "subnet_allocation"; then
221
+        if is_networking_extension_supported "auto-allocated-topology"; then
222 222
             EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default"
223
-            if [[ "$IP_VERSION" =~ 4.* ]]; then
224
-                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)
225
-            fi
226
-            if [[ "$IP_VERSION" =~ .*6 ]]; then
227
-                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)
228
-            fi
229 223
         fi
230 224
         # Create an external network, and a subnet. Configure the external network as router gw
231 225
         if [ "$Q_USE_PROVIDERNET_FOR_PUBLIC" = "True" ]; then
... ...
@@ -250,13 +259,17 @@ function create_neutron_initial_network {
250 250
 # Create private IPv4 subnet
251 251
 function _neutron_create_private_subnet_v4 {
252 252
     local project_id=$1
253
+    if [ -z $SUBNETPOOL_V4_ID ]; then
254
+        fixed_range_v4=$FIXED_RANGE
255
+    fi
253 256
     local subnet_params="--tenant-id $project_id "
254 257
     subnet_params+="--ip_version 4 "
255 258
     if [[ -n "$NETWORK_GATEWAY" ]]; then
256 259
         subnet_params+="--gateway $NETWORK_GATEWAY "
257 260
     fi
258 261
     subnet_params+="--name $PRIVATE_SUBNET_NAME "
259
-    subnet_params+="$NET_ID $FIXED_RANGE"
262
+    subnet_params+="${SUBNETPOOL_V4_ID:+--subnetpool $SUBNETPOOL_V4_ID} "
263
+    subnet_params+="$NET_ID $fixed_range_v4"
260 264
     local subnet_id
261 265
     subnet_id=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep ' id ' | get_field 2)
262 266
     die_if_not_set $LINENO subnet_id "Failure creating private IPv4 subnet for $project_id"
... ...
@@ -269,13 +282,17 @@ function _neutron_create_private_subnet_v6 {
269 269
     die_if_not_set $LINENO IPV6_RA_MODE "IPV6 RA Mode not set"
270 270
     die_if_not_set $LINENO IPV6_ADDRESS_MODE "IPV6 Address Mode not set"
271 271
     local ipv6_modes="--ipv6-ra-mode $IPV6_RA_MODE --ipv6-address-mode $IPV6_ADDRESS_MODE"
272
+    if [ -z $SUBNETPOOL_V6_ID ]; then
273
+        fixed_range_v6=$FIXED_RANGE_V6
274
+    fi
272 275
     local subnet_params="--tenant-id $project_id "
273 276
     subnet_params+="--ip_version 6 "
274 277
     if [[ -n "$IPV6_PRIVATE_NETWORK_GATEWAY" ]]; then
275 278
         subnet_params+="--gateway $IPV6_PRIVATE_NETWORK_GATEWAY "
276 279
     fi
277 280
     subnet_params+="--name $IPV6_PRIVATE_SUBNET_NAME "
278
-    subnet_params+="$NET_ID $FIXED_RANGE_V6 $ipv6_modes"
281
+    subnet_params+="${SUBNETPOOL_V6_ID:+--subnetpool $SUBNETPOOL_V6_ID} "
282
+    subnet_params+="$NET_ID $fixed_range_v6 $ipv6_modes"
279 283
     local ipv6_subnet_id
280 284
     ipv6_subnet_id=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" subnet-create $subnet_params | grep ' id ' | get_field 2)
281 285
     die_if_not_set $LINENO ipv6_subnet_id "Failure creating private IPv6 subnet for $project_id"
... ...
@@ -350,7 +367,11 @@ function _neutron_configure_router_v4 {
350 350
             fi
351 351
             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' ' ')
352 352
             die_if_not_set $LINENO ROUTER_GW_IP "Failure retrieving ROUTER_GW_IP"
353
-            sudo ip route replace  $FIXED_RANGE via $ROUTER_GW_IP
353
+            local replace_range=${SUBNETPOOL_PREFIX_V4}
354
+            if [[ -z "${SUBNETPOOL_V4_ID}" ]]; then
355
+                replace_range=${FIXED_RANGE}
356
+            fi
357
+            sudo ip route replace $replace_range via $ROUTER_GW_IP
354 358
         fi
355 359
         _neutron_set_router_id
356 360
     fi
... ...
@@ -396,7 +417,11 @@ function _neutron_configure_router_v6 {
396 396
 
397 397
             # Configure interface for public bridge
398 398
             sudo ip -6 addr replace $ipv6_ext_gw_ip/$ipv6_cidr_len dev $ext_gw_interface
399
-            sudo ip -6 route replace $FIXED_RANGE_V6 via $IPV6_ROUTER_GW_IP dev $ext_gw_interface
399
+            local replace_range=${SUBNETPOOL_PREFIX_V6}
400
+            if [[ -z "${SUBNETPOOL_V6_ID}" ]]; then
401
+                replace_range=${FIXED_RANGE_V6}
402
+            fi
403
+            sudo ip -6 route replace $replace_range via $IPV6_ROUTER_GW_IP dev $ext_gw_interface
400 404
         fi
401 405
         _neutron_set_router_id
402 406
     fi