Browse code

Merge "Neutron: check if a plugin has the l3 API extension"

Jenkins authored on 2016/06/07 22:54:33
Showing 2 changed files
... ...
@@ -174,9 +174,7 @@ function create_neutron_initial_network {
174 174
         fi
175 175
     fi
176 176
 
177
-    AUTO_ALLOCATE_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'auto-allocated-topology' | get_field 1)
178
-    SUBNETPOOL_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'subnet_allocation' | get_field 1)
179
-    if is_service_enabled q-l3; then
177
+    if is_networking_extension_supported "router" && is_networking_extension_supported "external-net"; then
180 178
         # Create a router, and add the private subnet as one of its interfaces
181 179
         if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
182 180
             # create a tenant-owned router.
... ...
@@ -188,10 +186,8 @@ function create_neutron_initial_network {
188 188
             die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
189 189
         fi
190 190
 
191
-        # if the extension is available, then mark the external
192
-        # network as default, and provision default subnetpools
193 191
         EXTERNAL_NETWORK_FLAGS="--router:external"
194
-        if [[ -n $AUTO_ALLOCATE_EXT && -n $SUBNETPOOL_EXT ]]; then
192
+        if is_networking_extension_supported "auto-allocated-topology" && is_networking_extension_supported "subnet_allocation"; then
195 193
             EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default"
196 194
             if [[ "$IP_VERSION" =~ 4.* ]]; then
197 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)
... ...
@@ -363,3 +359,10 @@ function is_provider_network {
363 363
     fi
364 364
     return 1
365 365
 }
366
+
367
+function is_networking_extension_supported {
368
+    local extension=$1
369
+    # TODO(sc68cal) cache this instead of calling every time
370
+    EXT_LIST=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list -c alias -f value)
371
+    [[ $EXT_LIST =~ $extension ]] && return 0
372
+}
... ...
@@ -240,8 +240,7 @@ function configure_tempest {
240 240
 
241 241
     # the public network (for floating ip access) is only available
242 242
     # if the extension is enabled.
243
-    EXTERNAL_NETWORK_EXT=$(neutron ext-list | grep 'external-net' | get_field 1)
244
-    if [[ -n $EXTERNAL_NETWORK_EXT ]]; then
243
+    if is_networking_extension_supported 'external-net'; then
245 244
         public_network_id=$(neutron net-list | grep $PUBLIC_NETWORK_NAME | \
246 245
             awk '{print $2}')
247 246
     fi