devstack/lib/neutron_thirdparty/nicira
Salvatore Orlando 9732b57e3d 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
2013-10-09 02:36:32 -07:00

83 lines
3.4 KiB
Plaintext

# Nicira NVP
# ----------
# This third-party addition can be used to configure connectivity between a DevStack instance
# and an NVP Gateway in dev/test environments. In order to use this correctly, the following
# env variables need to be set (e.g. in your localrc file):
#
# * enable_service nicira --> to execute this third-party addition
# * PUBLIC_BRIDGE --> bridge used for external connectivity, typically br-ex
# * NVP_GATEWAY_NETWORK_INTERFACE --> interface used to communicate with the NVP Gateway
# * NVP_GATEWAY_NETWORK_CIDR --> CIDR to configure br-ex, e.g. 172.24.4.211/24
# Save trace setting
MY_XTRACE=$(set +o | grep xtrace)
set +o xtrace
# This is the interface that connects the Devstack instance
# to an network that allows it to talk to the gateway for
# testing purposes
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 init_nicira() {
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
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
# Use the PUBLIC Bridge to route traffic to the NVP gateway
# NOTE(armando-migliaccio): if running in a nested environment this will work
# 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
nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
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 start_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
$MY_XTRACE