blob: 7a765707755128e22c3864f671550f7ca36abda1 [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
11# * NSX_GATEWAY_NETWORK_CIDR --> CIDR to configure br-ex, e.g. 172.24.4.211/24
12
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#*/}
32 echo "The IP address to set on br-ex was not specified. "
33 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
45 sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
46 sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_INTERFACE
47 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
53}
54
Ian Wienandaee18c72014-02-21 15:35:08 +110055function install_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080056 :
57}
58
Ian Wienandaee18c72014-02-21 15:35:08 +110059function start_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080060 :
61}
62
Ian Wienandaee18c72014-02-21 15:35:08 +110063function stop_vmware_nsx {
armando-migliaccio05952e32014-01-05 07:59:06 -080064 if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
65 NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
66 echo "The IP address expected on br-ex was not specified. "
67 echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
68 fi
69 sudo ip addr del $NSX_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
70 # Save and then flush remaining addresses on the interface
71 addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
72 sudo ip addr flush $PUBLIC_BRIDGE
73 # Try to detach physical interface from PUBLIC_BRIDGE
74 sudo ovs-vsctl del-port $NSX_GATEWAY_NETWORK_INTERFACE
75 # Restore addresses on NSX_GATEWAY_NETWORK_INTERFACE
76 for address in $addresses; do
77 sudo ip addr add dev $NSX_GATEWAY_NETWORK_INTERFACE $address
78 done
79}
80
Ian Wienandaee18c72014-02-21 15:35:08 +110081function check_vmware_nsx {
armando-migliacciodb20cd52014-01-05 07:41:30 -080082 neutron-check-nsx-config $NEUTRON_CONF_DIR/plugins/vmware/nsx.ini
armando-migliaccioef1e0802014-01-02 16:33:53 -080083}
84
armando-migliaccio05952e32014-01-05 07:59:06 -080085# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -050086$NSX3_XTRACE