Neutron implemented an extension to allow users to automatically
provision a basic network topology to connect their instances.
One of the requirements for this feature is to be able to mark
an external network to be the one to be used for external
connectivity. Another requirement is subnetpools, which are
used to determine the IP space to allocate for private tenant
networks.
This patch codifies these requirements. The provisioning
needs to be made conditional based on the extensions
needed for this to work correctly.
Partially-implements: blueprint get-me-a-network
Change-Id: I43ce5d65e754f131f7ca1ce2088a397d266cf821
... | ... |
@@ -73,6 +73,16 @@ PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.1} |
73 | 73 |
PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"} |
74 | 74 |
PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"} |
75 | 75 |
|
76 |
+# Subnetpool defaults |
|
77 |
+SUBNETPOOL_NAME=${SUBNETPOOL_NAME:-"shared-default-subnetpool"} |
|
78 |
+ |
|
79 |
+SUBNETPOOL_PREFIX_V4=${SUBNETPOOL_PREFIX_V4:-10.0.0.0/24} |
|
80 |
+SUBNETPOOL_PREFIX_V6=${SUBNETPOOL_PREFIX_V6:-2001:db8:8000::/48} |
|
81 |
+ |
|
82 |
+SUBNETPOOL_SIZE_V4=${SUBNETPOOL_SIZE_V4:-26} |
|
83 |
+SUBNETPOOL_SIZE_V6=${SUBNETPOOL_SIZE_V6:-64} |
|
84 |
+ |
|
85 |
+ |
|
76 | 86 |
if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then |
77 | 87 |
Q_PROTOCOL="https" |
78 | 88 |
fi |
... | ... |
@@ -580,6 +590,8 @@ function create_neutron_initial_network { |
580 | 580 |
fi |
581 | 581 |
fi |
582 | 582 |
|
583 |
+ AUTO_ALLOCATE_EXT=$(neutron ext-list | grep 'auto-allocated-topology' | get_field 1) |
|
584 |
+ SUBNETPOOL_EXT=$(neutron ext-list | grep 'subnet_allocation' | get_field 1) |
|
583 | 585 |
if [[ "$Q_L3_ENABLED" == "True" ]]; then |
584 | 586 |
# Create a router, and add the private subnet as one of its interfaces |
585 | 587 |
if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then |
... | ... |
@@ -592,11 +604,23 @@ function create_neutron_initial_network { |
592 | 592 |
die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME" |
593 | 593 |
fi |
594 | 594 |
|
595 |
+ # if the extension is available, then mark the external |
|
596 |
+ # network as default, and provision default subnetpools |
|
597 |
+ EXTERNAL_NETWORK_FLAGS="--router:external" |
|
598 |
+ if [[ -n $AUTO_ALLOCATE_EXT && -n $SUBNETPOOL_EXT ]]; then |
|
599 |
+ EXTERNAL_NETWORK_FLAGS="$EXTERNAL_NETWORK_FLAGS --is-default" |
|
600 |
+ if [[ "$IP_VERSION" =~ 4.* ]]; then |
|
601 |
+ SUBNETPOOL_V4_ID=$(neutron subnetpool-create $SUBNETPOOL_NAME --default-prefixlen $SUBNETPOOL_SIZE_V4 --pool-prefix $SUBNETPOOL_PREFIX_V4 --shared --is-default=True | grep ' id ' | get_field 2) |
|
602 |
+ fi |
|
603 |
+ if [[ "$IP_VERSION" =~ .*6 ]]; then |
|
604 |
+ SUBNETPOOL_V6_ID=$(neutron subnetpool-create $SUBNETPOOL_NAME --default-prefixlen $SUBNETPOOL_SIZE_V6 --pool-prefix $SUBNETPOOL_PREFIX_V6 --shared --is-default=True | grep ' id ' | get_field 2) |
|
605 |
+ fi |
|
606 |
+ fi |
|
595 | 607 |
# Create an external network, and a subnet. Configure the external network as router gw |
596 | 608 |
if [ "$Q_USE_PROVIDERNET_FOR_PUBLIC" = "True" ]; then |
597 |
- EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True --provider:network_type=flat --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} | grep ' id ' | get_field 2) |
|
609 |
+ EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- $EXTERNAL_NETWORK_FLAGS --provider:network_type=flat --provider:physical_network=${PUBLIC_PHYSICAL_NETWORK} | grep ' id ' | get_field 2) |
|
598 | 610 |
else |
599 |
- EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2) |
|
611 |
+ EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- $EXTERNAL_NETWORK_FLAGS | grep ' id ' | get_field 2) |
|
600 | 612 |
fi |
601 | 613 |
die_if_not_set $LINENO EXT_NET_ID "Failure creating EXT_NET_ID for $PUBLIC_NETWORK_NAME" |
602 | 614 |
|