Browse code

Neutron: check if a plugin has the l3 API extension

If a plugin has the L3 API extension available, issue the L3 API
extension calls that creates routers and networks

Change-Id: I77e269ce0025054bcf2a2f4156124f2921ba2d59

Sean M. Collins authored on 2016/05/18 23:38:51
Showing 2 changed files
... ...
@@ -175,9 +175,7 @@ function create_neutron_initial_network {
175 175
         fi
176 176
     fi
177 177
 
178
-    AUTO_ALLOCATE_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'auto-allocated-topology' | get_field 1)
179
-    SUBNETPOOL_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'subnet_allocation' | get_field 1)
180
-    if is_service_enabled q-l3; then
178
+    if is_networking_extension_supported "router" && is_networking_extension_supported "external-net"; then
181 179
         # Create a router, and add the private subnet as one of its interfaces
182 180
         if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
183 181
             # create a tenant-owned router.
... ...
@@ -189,10 +187,8 @@ function create_neutron_initial_network {
189 189
             die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
190 190
         fi
191 191
 
192
-        # if the extension is available, then mark the external
193
-        # network as default, and provision default subnetpools
194 192
         EXTERNAL_NETWORK_FLAGS="--router:external"
195
-        if [[ -n $AUTO_ALLOCATE_EXT && -n $SUBNETPOOL_EXT ]]; then
193
+        if is_networking_extension_supported "auto-allocated-topology" && is_networking_extension_supported "subnet_allocation"; then
196 194
             EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default"
197 195
             if [[ "$IP_VERSION" =~ 4.* ]]; then
198 196
                 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)
... ...
@@ -364,3 +360,10 @@ function is_provider_network {
364 364
     fi
365 365
     return 1
366 366
 }
367
+
368
+function is_networking_extension_supported {
369
+    local extension=$1
370
+    # TODO(sc68cal) cache this instead of calling every time
371
+    EXT_LIST=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list -c alias -f value)
372
+    [[ $EXT_LIST =~ $extension ]] && return 0
373
+}
... ...
@@ -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