Merge "Clean usage of project_id in the Neutron's L3 service module"
This commit is contained in:
commit
14779fc992
@ -147,10 +147,6 @@ function _neutron_get_ext_gw_interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create_neutron_initial_network {
|
function create_neutron_initial_network {
|
||||||
local project_id
|
|
||||||
project_id=$(openstack project list | grep " demo " | get_field 1)
|
|
||||||
die_if_not_set $LINENO project_id "Failure retrieving project_id for demo"
|
|
||||||
|
|
||||||
# Allow drivers that need to create an initial network to do so here
|
# Allow drivers that need to create an initial network to do so here
|
||||||
if type -p neutron_plugin_create_initial_network_profile > /dev/null; then
|
if type -p neutron_plugin_create_initial_network_profile > /dev/null; then
|
||||||
neutron_plugin_create_initial_network_profile $PHYSICAL_NETWORK
|
neutron_plugin_create_initial_network_profile $PHYSICAL_NETWORK
|
||||||
@ -171,14 +167,14 @@ function create_neutron_initial_network {
|
|||||||
die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK"
|
die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK"
|
||||||
die_if_not_set $LINENO PROVIDER_NETWORK_TYPE "You must specify the PROVIDER_NETWORK_TYPE"
|
die_if_not_set $LINENO PROVIDER_NETWORK_TYPE "You must specify the PROVIDER_NETWORK_TYPE"
|
||||||
NET_ID=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" network create $PHYSICAL_NETWORK --provider-network-type $PROVIDER_NETWORK_TYPE --provider-physical-network "$PHYSICAL_NETWORK" ${SEGMENTATION_ID:+--provider-segment $SEGMENTATION_ID} --share | grep ' id ' | get_field 2)
|
NET_ID=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" network create $PHYSICAL_NETWORK --provider-network-type $PROVIDER_NETWORK_TYPE --provider-physical-network "$PHYSICAL_NETWORK" ${SEGMENTATION_ID:+--provider-segment $SEGMENTATION_ID} --share | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $project_id"
|
die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK"
|
||||||
|
|
||||||
if [[ "$IP_VERSION" =~ 4.* ]]; then
|
if [[ "$IP_VERSION" =~ 4.* ]]; then
|
||||||
if [ -z $SUBNETPOOL_V4_ID ]; then
|
if [ -z $SUBNETPOOL_V4_ID ]; then
|
||||||
fixed_range_v4=$FIXED_RANGE
|
fixed_range_v4=$FIXED_RANGE
|
||||||
fi
|
fi
|
||||||
SUBNET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" subnet create --ip-version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} $PROVIDER_SUBNET_NAME --gateway $NETWORK_GATEWAY ${SUBNETPOOL_V4_ID:+--subnet-pool $SUBNETPOOL_V4_ID} --network $NET_ID ${fixed_range_v4:+--subnet-range $fixed_range_v4} | grep ' id ' | get_field 2)
|
SUBNET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" subnet create --ip-version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} $PROVIDER_SUBNET_NAME --gateway $NETWORK_GATEWAY ${SUBNETPOOL_V4_ID:+--subnet-pool $SUBNETPOOL_V4_ID} --network $NET_ID ${fixed_range_v4:+--subnet-range $fixed_range_v4} | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $PROVIDER_SUBNET_NAME $project_id"
|
die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $PROVIDER_SUBNET_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$IP_VERSION" =~ .*6 ]]; then
|
if [[ "$IP_VERSION" =~ .*6 ]]; then
|
||||||
@ -188,7 +184,7 @@ function create_neutron_initial_network {
|
|||||||
fixed_range_v6=$IPV6_PROVIDER_FIXED_RANGE
|
fixed_range_v6=$IPV6_PROVIDER_FIXED_RANGE
|
||||||
fi
|
fi
|
||||||
IPV6_SUBNET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" subnet create --ip-version 6 --gateway $IPV6_PROVIDER_NETWORK_GATEWAY $IPV6_PROVIDER_SUBNET_NAME ${SUBNETPOOL_V6_ID:+--subnet-pool $SUBNETPOOL_V6_ID} --network $NET_ID ${fixed_range_v6:+--subnet-range $fixed_range_v6} | grep ' id ' | get_field 2)
|
IPV6_SUBNET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" subnet create --ip-version 6 --gateway $IPV6_PROVIDER_NETWORK_GATEWAY $IPV6_PROVIDER_SUBNET_NAME ${SUBNETPOOL_V6_ID:+--subnet-pool $SUBNETPOOL_V6_ID} --network $NET_ID ${fixed_range_v6:+--subnet-range $fixed_range_v6} | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO IPV6_SUBNET_ID "Failure creating IPV6_SUBNET_ID for $IPV6_PROVIDER_SUBNET_NAME $project_id"
|
die_if_not_set $LINENO IPV6_SUBNET_ID "Failure creating IPV6_SUBNET_ID for $IPV6_PROVIDER_SUBNET_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $Q_AGENT == "openvswitch" ]]; then
|
if [[ $Q_AGENT == "openvswitch" ]]; then
|
||||||
@ -198,16 +194,16 @@ function create_neutron_initial_network {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
NET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" network create "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
|
NET_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" network create "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PRIVATE_NETWORK_NAME $project_id"
|
die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PRIVATE_NETWORK_NAME"
|
||||||
|
|
||||||
if [[ "$IP_VERSION" =~ 4.* ]]; then
|
if [[ "$IP_VERSION" =~ 4.* ]]; then
|
||||||
# Create IPv4 private subnet
|
# Create IPv4 private subnet
|
||||||
SUBNET_ID=$(_neutron_create_private_subnet_v4 $project_id)
|
SUBNET_ID=$(_neutron_create_private_subnet_v4)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$IP_VERSION" =~ .*6 ]]; then
|
if [[ "$IP_VERSION" =~ .*6 ]]; then
|
||||||
# Create IPv6 private subnet
|
# Create IPv6 private subnet
|
||||||
IPV6_SUBNET_ID=$(_neutron_create_private_subnet_v6 $project_id)
|
IPV6_SUBNET_ID=$(_neutron_create_private_subnet_v6)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -216,11 +212,11 @@ function create_neutron_initial_network {
|
|||||||
if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
|
if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
|
||||||
# create a tenant-owned router.
|
# create a tenant-owned router.
|
||||||
ROUTER_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" router create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
|
ROUTER_ID=$(openstack --os-cloud devstack --os-region "$REGION_NAME" router create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $project_id $Q_ROUTER_NAME"
|
die_if_not_set $LINENO ROUTER_ID "Failure creating router $Q_ROUTER_NAME"
|
||||||
else
|
else
|
||||||
# Plugin only supports creating a single router, which should be admin owned.
|
# Plugin only supports creating a single router, which should be admin owned.
|
||||||
ROUTER_ID=$(openstack --os-cloud devstack-admin --os-region "$REGION_NAME" router create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
|
ROUTER_ID=$(openstack --os-cloud devstack-admin --os-region "$REGION_NAME" router create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
|
die_if_not_set $LINENO ROUTER_ID "Failure creating router $Q_ROUTER_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EXTERNAL_NETWORK_FLAGS="--external"
|
EXTERNAL_NETWORK_FLAGS="--external"
|
||||||
@ -249,7 +245,6 @@ function create_neutron_initial_network {
|
|||||||
|
|
||||||
# Create private IPv4 subnet
|
# Create private IPv4 subnet
|
||||||
function _neutron_create_private_subnet_v4 {
|
function _neutron_create_private_subnet_v4 {
|
||||||
local project_id=$1
|
|
||||||
if [ -z $SUBNETPOOL_V4_ID ]; then
|
if [ -z $SUBNETPOOL_V4_ID ]; then
|
||||||
fixed_range_v4=$FIXED_RANGE
|
fixed_range_v4=$FIXED_RANGE
|
||||||
fi
|
fi
|
||||||
@ -263,13 +258,12 @@ function _neutron_create_private_subnet_v4 {
|
|||||||
subnet_params+="--network $NET_ID $PRIVATE_SUBNET_NAME"
|
subnet_params+="--network $NET_ID $PRIVATE_SUBNET_NAME"
|
||||||
local subnet_id
|
local subnet_id
|
||||||
subnet_id=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" subnet create $subnet_params | grep ' id ' | get_field 2)
|
subnet_id=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" subnet create $subnet_params | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO subnet_id "Failure creating private IPv4 subnet for $project_id"
|
die_if_not_set $LINENO subnet_id "Failure creating private IPv4 subnet"
|
||||||
echo $subnet_id
|
echo $subnet_id
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create private IPv6 subnet
|
# Create private IPv6 subnet
|
||||||
function _neutron_create_private_subnet_v6 {
|
function _neutron_create_private_subnet_v6 {
|
||||||
local project_id=$1
|
|
||||||
die_if_not_set $LINENO IPV6_RA_MODE "IPV6 RA Mode not set"
|
die_if_not_set $LINENO IPV6_RA_MODE "IPV6 RA Mode not set"
|
||||||
die_if_not_set $LINENO IPV6_ADDRESS_MODE "IPV6 Address Mode not set"
|
die_if_not_set $LINENO IPV6_ADDRESS_MODE "IPV6 Address Mode not set"
|
||||||
local ipv6_modes="--ipv6-ra-mode $IPV6_RA_MODE --ipv6-address-mode $IPV6_ADDRESS_MODE"
|
local ipv6_modes="--ipv6-ra-mode $IPV6_RA_MODE --ipv6-address-mode $IPV6_ADDRESS_MODE"
|
||||||
@ -285,7 +279,7 @@ function _neutron_create_private_subnet_v6 {
|
|||||||
subnet_params+="$ipv6_modes --network $NET_ID $IPV6_PRIVATE_SUBNET_NAME "
|
subnet_params+="$ipv6_modes --network $NET_ID $IPV6_PRIVATE_SUBNET_NAME "
|
||||||
local ipv6_subnet_id
|
local ipv6_subnet_id
|
||||||
ipv6_subnet_id=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" subnet create $subnet_params | grep ' id ' | get_field 2)
|
ipv6_subnet_id=$(openstack --os-cloud devstack-admin-demo --os-region "$REGION_NAME" subnet create $subnet_params | grep ' id ' | get_field 2)
|
||||||
die_if_not_set $LINENO ipv6_subnet_id "Failure creating private IPv6 subnet for $project_id"
|
die_if_not_set $LINENO ipv6_subnet_id "Failure creating private IPv6 subnet"
|
||||||
echo $ipv6_subnet_id
|
echo $ipv6_subnet_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user