blob: 7a20c64afb9353ba5a03702be67bc3458ff0b726 [file] [log] [blame]
armando-migliaccio05952e32014-01-05 07:59:06 -08001# VMware NSX
2# ----------
3
4# This third-party addition can be used to configure connectivity between a DevStack instance
5# and an NSX Gateway in dev/test environments. In order to use this correctly, the following
6# env variables need to be set (e.g. in your localrc file):
7#
8# * enable_service vmware_nsx --> to execute this third-party addition
9# * PUBLIC_BRIDGE --> bridge used for external connectivity, typically br-ex
10# * NSX_GATEWAY_NETWORK_INTERFACE --> interface used to communicate with the NSX Gateway
taturielloe7f071b2014-10-15 05:09:45 -070011# * NSX_GATEWAY_NETWORK_CIDR --> CIDR to configure $PUBLIC_BRIDGE, e.g. 172.24.4.211/24
armando-migliaccio05952e32014-01-05 07:59:06 -080012
13# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -050014NSX3_XTRACE=$(set +o | grep xtrace)
armando-migliaccio05952e32014-01-05 07:59:06 -080015set +o xtrace
16
17# This is the interface that connects the Devstack instance
18# to an network that allows it to talk to the gateway for
19# testing purposes
20NSX_GATEWAY_NETWORK_INTERFACE=${NSX_GATEWAY_NETWORK_INTERFACE:-eth2}
21# Re-declare floating range as it's needed also in stop_vmware_nsx, which
22# is invoked by unstack.sh
23FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
24
Ian Wienandaee18c72014-02-21 15:35:08 +110025function configure_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080026 :
27}
28
Ian Wienandaee18c72014-02-21 15:35:08 +110029function init_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080030 if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
31 NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
taturielloe7f071b2014-10-15 05:09:45 -070032 echo "The IP address to set on $PUBLIC_BRIDGE was not specified. "
armando-migliaccio05952e32014-01-05 07:59:06 -080033 echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
34 fi
35 # Make sure the interface is up, but not configured
36 sudo ip link set $NSX_GATEWAY_NETWORK_INTERFACE up
37 # Save and then flush the IP addresses on the interface
38 addresses=$(ip addr show dev $NSX_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
39 sudo ip addr flush $NSX_GATEWAY_NETWORK_INTERFACE
40 # Use the PUBLIC Bridge to route traffic to the NSX gateway
41 # NOTE(armando-migliaccio): if running in a nested environment this will work
42 # only with mac learning enabled, portsecurity and security profiles disabled
43 # The public bridge might not exist for the NSX plugin if Q_USE_DEBUG_COMMAND is off
44 # Try to create it anyway
taturielloe7f071b2014-10-15 05:09:45 -070045 sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE
46 sudo ovs-vsctl --may-exist add-port $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_INTERFACE
armando-migliaccio05952e32014-01-05 07:59:06 -080047 nsx_gw_net_if_mac=$(ip link show $NSX_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
48 sudo ip link set address $nsx_gw_net_if_mac dev $PUBLIC_BRIDGE
49 for address in $addresses; do
50 sudo ip addr add dev $PUBLIC_BRIDGE $address
51 done
52 sudo ip addr add dev $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_CIDR
taturielloe7f071b2014-10-15 05:09:45 -070053 sudo ip link set $PUBLIC_BRIDGE up
armando-migliaccio05952e32014-01-05 07:59:06 -080054}
55
Ian Wienandaee18c72014-02-21 15:35:08 +110056function install_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080057 :
58}
59
Ian Wienandaee18c72014-02-21 15:35:08 +110060function start_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080061 :
62}
63
Ian Wienandaee18c72014-02-21 15:35:08 +110064function stop_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080065 if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
66 NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
taturielloe7f071b2014-10-15 05:09:45 -070067 echo "The IP address expected on $PUBLIC_BRIDGE was not specified. "
armando-migliaccio05952e32014-01-05 07:59:06 -080068 echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
69 fi
70 sudo ip addr del $NSX_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
71 # Save and then flush remaining addresses on the interface
72 addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
73 sudo ip addr flush $PUBLIC_BRIDGE
74 # Try to detach physical interface from PUBLIC_BRIDGE
75 sudo ovs-vsctl del-port $NSX_GATEWAY_NETWORK_INTERFACE
76 # Restore addresses on NSX_GATEWAY_NETWORK_INTERFACE
77 for address in $addresses; do
78 sudo ip addr add dev $NSX_GATEWAY_NETWORK_INTERFACE $address
79 done
80}
81
Ian Wienandaee18c72014-02-21 15:35:08 +110082function check_vmware_nsx {
armando-migliacciodb20cd52014-01-05 07:41:30 -080083 neutron-check-nsx-config $NEUTRON_CONF_DIR/plugins/vmware/nsx.ini
armando-migliaccioef1e0802014-01-02 16:33:53 -080084}
85
armando-migliaccio05952e32014-01-05 07:59:06 -080086# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -050087$NSX3_XTRACE