nsx-v3: Configure interface and route to external network
This patch adds the ability for the devstack script to configure an interface with routes to the devstack created external network. In order, to use this one must set the NSX_GATEWAY_NETWORK_INTERFACE to be the interface that is connected to the same network as the uplink to the nsx gateway. Change-Id: I866916c368904df86b26a061d313aa79abbeb35b
This commit is contained in:
parent
56be50105f
commit
db39d46a89
@ -20,6 +20,12 @@
|
|||||||
# Neutron VMware NSX plugin
|
# Neutron VMware NSX plugin
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
|
||||||
|
# The interface which has connectivity to the NSX Gateway uplink
|
||||||
|
NSX_GATEWAY_NETWORK_INTERFACE=${NSX_GATEWAY_NETWORK_INTERFACE:-}
|
||||||
|
|
||||||
|
|
||||||
# Save trace setting
|
# Save trace setting
|
||||||
NSX_XTRACE=$(set +o | grep xtrace)
|
NSX_XTRACE=$(set +o | grep xtrace)
|
||||||
set +o xtrace
|
set +o xtrace
|
||||||
@ -127,5 +133,63 @@ function neutron_plugin_check_adv_test_requirements {
|
|||||||
is_service_enabled q-dhcp && return 0
|
is_service_enabled q-dhcp && return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function init_vmware_nsx_v3 {
|
||||||
|
if ! is_set NSX_GATEWAY_NETWORK_INTERFACE; then
|
||||||
|
echo "NSX_GATEWAY_NETWORK_INTERFACE not set not configuring routes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
|
||||||
|
NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
|
||||||
|
echo "The IP address to set on $PUBLIC_BRIDGE was not specified. "
|
||||||
|
echo "Defaulting to $NSX_GATEWAY_NETWORK_CIDR"
|
||||||
|
fi
|
||||||
|
# Make sure the interface is up, but not configured
|
||||||
|
sudo ip link set $NSX_GATEWAY_NETWORK_INTERFACE up
|
||||||
|
# Save and then flush the IP addresses on the interface
|
||||||
|
addresses=$(ip addr show dev $NSX_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
|
||||||
|
sudo ip addr flush $NSX_GATEWAY_NETWORK_INTERFACE
|
||||||
|
# Use the PUBLIC Bridge to route traffic to the NSX 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 NSX plugin if Q_USE_DEBUG_COMMAND is off
|
||||||
|
# Try to create it anyway
|
||||||
|
sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE
|
||||||
|
sudo ovs-vsctl --may-exist add-port $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_INTERFACE
|
||||||
|
# Flush all existing addresses on public bridge
|
||||||
|
sudo ip addr flush dev $PUBLIC_BRIDGE
|
||||||
|
nsx_gw_net_if_mac=$(ip link show $NSX_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
|
||||||
|
sudo ip link set address $nsx_gw_net_if_mac dev $PUBLIC_BRIDGE
|
||||||
|
for address in $addresses; do
|
||||||
|
sudo ip addr add dev $PUBLIC_BRIDGE $address
|
||||||
|
done
|
||||||
|
sudo ip addr add dev $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_CIDR
|
||||||
|
sudo ip link set $PUBLIC_BRIDGE up
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_vmware_nsx_v3 {
|
||||||
|
if ! is_set NSX_GATEWAY_NETWORK_INTERFACE; then
|
||||||
|
echo "NSX_GATEWAY_NETWORK_INTERFACE was not configured."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
|
||||||
|
NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
|
||||||
|
echo "The IP address expected on $PUBLIC_BRIDGE was not specified. "
|
||||||
|
echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
|
||||||
|
fi
|
||||||
|
sudo ip addr del $NSX_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 $NSX_GATEWAY_NETWORK_INTERFACE
|
||||||
|
# Restore addresses on NSX_GATEWAY_NETWORK_INTERFACE
|
||||||
|
for address in $addresses; do
|
||||||
|
sudo ip addr add dev $NSX_GATEWAY_NETWORK_INTERFACE $address
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Restore xtrace
|
# Restore xtrace
|
||||||
$NSX_XTRACE
|
$NSX_XTRACE
|
||||||
|
@ -39,7 +39,10 @@ elif [[ $Q_PLUGIN == 'vmware_nsx' ]]; then
|
|||||||
fi
|
fi
|
||||||
elif [[ $Q_PLUGIN == 'vmware_nsx_v3' ]]; then
|
elif [[ $Q_PLUGIN == 'vmware_nsx_v3' ]]; then
|
||||||
source $dir/lib/vmware_nsx_v3
|
source $dir/lib/vmware_nsx_v3
|
||||||
if [[ "$1" == "unstack" ]]; then
|
if [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||||
|
init_vmware_nsx_v3
|
||||||
|
elif [[ "$1" == "unstack" ]]; then
|
||||||
|
stop_vmware_nsx
|
||||||
NSX_MANAGER=${NSX_MANAGERS:-$NSX_MANAGER}
|
NSX_MANAGER=${NSX_MANAGERS:-$NSX_MANAGER}
|
||||||
IFS=','
|
IFS=','
|
||||||
NSX_MANAGER=($NSX_MANAGER)
|
NSX_MANAGER=($NSX_MANAGER)
|
||||||
|
Loading…
Reference in New Issue
Block a user