Nicira plugin: do not die if NVP gateway IP is missing
Devstack should not die if the IP and prefix len for establishing a connection to the public network are not provided. In this case, the public gateway IP address used to configure Neutron's public network should be used, together with the prefix length of the public network's CIDR. This patch also ensures $PUBLIC_BRIDGE is created, even if Q_USE_DEBUG_COMMAND is disabled. Finally this patch also adds the teardown operation for restoring the original IP addresses on the interface used for connectivity to the public network implemented on the NVP gateway. Bug #1227750 Change-Id: Ib58738a578c46f2183d503cabfdc6039bfbeb702
This commit is contained in:
parent
e25492e8b0
commit
9732b57e3d
38
lib/neutron_thirdparty/nicira
vendored
38
lib/neutron_thirdparty/nicira
vendored
@ -18,22 +18,38 @@ set +o xtrace
|
|||||||
# to an network that allows it to talk to the gateway for
|
# to an network that allows it to talk to the gateway for
|
||||||
# testing purposes
|
# testing purposes
|
||||||
NVP_GATEWAY_NETWORK_INTERFACE=${NVP_GATEWAY_NETWORK_INTERFACE:-eth2}
|
NVP_GATEWAY_NETWORK_INTERFACE=${NVP_GATEWAY_NETWORK_INTERFACE:-eth2}
|
||||||
|
# Re-declare floating range as it's needed also in stop_nicira, which
|
||||||
|
# is invoked by unstack.sh
|
||||||
|
FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
|
||||||
|
|
||||||
function configure_nicira() {
|
function configure_nicira() {
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_nicira() {
|
function init_nicira() {
|
||||||
die_if_not_set $LINENO NVP_GATEWAY_NETWORK_CIDR "Please, specify CIDR for the gateway network interface."
|
if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
|
||||||
|
NVP_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
|
||||||
|
echo "The IP address to set on br-ex was not specified. "
|
||||||
|
echo "Defaulting to "$NVP_GATEWAY_NETWORK_CIDR
|
||||||
|
fi
|
||||||
# Make sure the interface is up, but not configured
|
# Make sure the interface is up, but not configured
|
||||||
sudo ifconfig $NVP_GATEWAY_NETWORK_INTERFACE up
|
sudo ip link dev $NVP_GATEWAY_NETWORK_INTERFACE set up
|
||||||
|
# Save and then flush the IP addresses on the interface
|
||||||
|
addresses=$(ip addr show dev $NVP_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
|
||||||
sudo ip addr flush $NVP_GATEWAY_NETWORK_INTERFACE
|
sudo ip addr flush $NVP_GATEWAY_NETWORK_INTERFACE
|
||||||
# Use the PUBLIC Bridge to route traffic to the NVP gateway
|
# Use the PUBLIC Bridge to route traffic to the NVP gateway
|
||||||
# NOTE(armando-migliaccio): if running in a nested environment this will work
|
# NOTE(armando-migliaccio): if running in a nested environment this will work
|
||||||
# only with mac learning enabled, portsecurity and security profiles disabled
|
# only with mac learning enabled, portsecurity and security profiles disabled
|
||||||
|
# The public bridge might not exist for the NVP plugin if Q_USE_DEBUG_COMMAND is off
|
||||||
|
# Try to create it anyway
|
||||||
|
sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
|
||||||
sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_INTERFACE
|
sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_INTERFACE
|
||||||
nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
|
nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
|
||||||
sudo ifconfig $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_CIDR hw ether $nvp_gw_net_if_mac
|
sudo ip link dev $PUBLIC_BRIDGE set address $nvp_gw_net_if_mac
|
||||||
|
for address in $addresses; do
|
||||||
|
sudo ip addr add dev $PUBLIC_BRIDGE $address
|
||||||
|
done
|
||||||
|
sudo ip addr add dev $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_CIDR
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_nicira() {
|
function install_nicira() {
|
||||||
@ -45,7 +61,21 @@ function start_nicira() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stop_nicira() {
|
function stop_nicira() {
|
||||||
:
|
if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
|
||||||
|
NVP_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
|
||||||
|
echo "The IP address expected on br-ex was not specified. "
|
||||||
|
echo "Defaulting to "$NVP_GATEWAY_NETWORK_CIDR
|
||||||
|
fi
|
||||||
|
sudo ip addr del $NVP_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
|
||||||
|
# Save and then flush remaining addresses on the interface
|
||||||
|
addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
|
||||||
|
sudo ip addr flush $PUBLIC_BRIDGE
|
||||||
|
# Try to detach physical interface from PUBLIC_BRIDGE
|
||||||
|
sudo ovs-vsctl del-port $NVP_GATEWAY_NETWORK_INTERFACE
|
||||||
|
# Restore addresses on NVP_GATEWAY_NETWORK_INTERFACE
|
||||||
|
for address in $addresses; do
|
||||||
|
sudo ip addr add dev $NVP_GATEWAY_NETWORK_INTERFACE $address
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore xtrace
|
# Restore xtrace
|
||||||
|
Loading…
Reference in New Issue
Block a user