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
diff --git a/lib/neutron_plugins/services/l3 b/lib/neutron_plugins/services/l3
index a5a6c81..55597a6 100644
--- a/lib/neutron_plugins/services/l3
+++ b/lib/neutron_plugins/services/l3
@@ -175,9 +175,7 @@
fi
fi
- AUTO_ALLOCATE_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'auto-allocated-topology' | get_field 1)
- SUBNETPOOL_EXT=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list | grep 'subnet_allocation' | get_field 1)
- if is_service_enabled q-l3; then
+ if is_networking_extension_supported "router" && is_networking_extension_supported "external-net"; then
# Create a router, and add the private subnet as one of its interfaces
if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
# create a tenant-owned router.
@@ -189,10 +187,8 @@
die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
fi
- # if the extension is available, then mark the external
- # network as default, and provision default subnetpools
EXTERNAL_NETWORK_FLAGS="--router:external"
- if [[ -n $AUTO_ALLOCATE_EXT && -n $SUBNETPOOL_EXT ]]; then
+ if is_networking_extension_supported "auto-allocated-topology" && is_networking_extension_supported "subnet_allocation"; then
EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default"
if [[ "$IP_VERSION" =~ 4.* ]]; then
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 @@
fi
return 1
}
+
+function is_networking_extension_supported {
+ local extension=$1
+ # TODO(sc68cal) cache this instead of calling every time
+ EXT_LIST=$(neutron --os-cloud devstack-admin --os-region "$REGION_NAME" ext-list -c alias -f value)
+ [[ $EXT_LIST =~ $extension ]] && return 0
+}
diff --git a/lib/tempest b/lib/tempest
index d4d8cf2..8cae4d9 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -240,8 +240,7 @@
# the public network (for floating ip access) is only available
# if the extension is enabled.
- EXTERNAL_NETWORK_EXT=$(neutron ext-list | grep 'external-net' | get_field 1)
- if [[ -n $EXTERNAL_NETWORK_EXT ]]; then
+ if is_networking_extension_supported 'external-net'; then
public_network_id=$(neutron net-list | grep $PUBLIC_NETWORK_NAME | \
awk '{print $2}')
fi