blob: a24392cd4db130e6f8e0a903743e6e2053e11e39 [file] [log] [blame]
armando-migliacciocabc60c2013-05-09 11:33:16 -07001# Nicira NVP
2# ----------
3
4# This third-party addition can be used to configure connectivity between a DevStack instance
5# and an NVP 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 nicira --> to execute this third-party addition
9# * PUBLIC_BRIDGE --> bridge used for external connectivity, typically br-ex
10# * NVP_GATEWAY_NETWORK_INTERFACE --> interface used to communicate with the NVP Gateway
11# * NVP_GATEWAY_NETWORK_CIDR --> CIDR to configure br-ex, e.g. 172.24.4.211/24
12
13# Save trace setting
14MY_XTRACE=$(set +o | grep xtrace)
15set +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
20NVP_GATEWAY_NETWORK_INTERFACE=${NVP_GATEWAY_NETWORK_INTERFACE:-eth2}
Salvatore Orlando9732b572013-09-21 01:17:06 +020021# Re-declare floating range as it's needed also in stop_nicira, which
22# is invoked by unstack.sh
Salvatore Orlando90234ac2013-11-25 05:44:10 -080023FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
armando-migliacciocabc60c2013-05-09 11:33:16 -070024
25function configure_nicira() {
26 :
27}
28
29function init_nicira() {
Salvatore Orlando9732b572013-09-21 01:17:06 +020030 if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
31 NVP_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 "$NVP_GATEWAY_NETWORK_CIDR
34 fi
armando-migliacciocabc60c2013-05-09 11:33:16 -070035 # Make sure the interface is up, but not configured
armando-migliaccio19a47a42013-12-10 07:41:26 -080036 sudo ip link set $NVP_GATEWAY_NETWORK_INTERFACE up
Salvatore Orlando9732b572013-09-21 01:17:06 +020037 # Save and then flush the IP addresses on the interface
38 addresses=$(ip addr show dev $NVP_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
armando-migliacciocabc60c2013-05-09 11:33:16 -070039 sudo ip addr flush $NVP_GATEWAY_NETWORK_INTERFACE
40 # Use the PUBLIC Bridge to route traffic to the NVP 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
Salvatore Orlando9732b572013-09-21 01:17:06 +020043 # The public bridge might not exist for the NVP 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
armando-migliacciocabc60c2013-05-09 11:33:16 -070046 sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_INTERFACE
47 nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
armando-migliaccio19a47a42013-12-10 07:41:26 -080048 sudo ip link set address $nvp_gw_net_if_mac dev $PUBLIC_BRIDGE
Salvatore Orlando9732b572013-09-21 01:17:06 +020049 for address in $addresses; do
50 sudo ip addr add dev $PUBLIC_BRIDGE $address
51 done
52 sudo ip addr add dev $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_CIDR
armando-migliacciocabc60c2013-05-09 11:33:16 -070053}
54
55function install_nicira() {
56 :
57}
58
59function start_nicira() {
60 :
61}
62
63function stop_nicira() {
Salvatore Orlando9732b572013-09-21 01:17:06 +020064 if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
65 NVP_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
66 echo "The IP address expected on br-ex was not specified. "
67 echo "Defaulting to "$NVP_GATEWAY_NETWORK_CIDR
68 fi
69 sudo ip addr del $NVP_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 $NVP_GATEWAY_NETWORK_INTERFACE
75 # Restore addresses on NVP_GATEWAY_NETWORK_INTERFACE
76 for address in $addresses; do
77 sudo ip addr add dev $NVP_GATEWAY_NETWORK_INTERFACE $address
78 done
armando-migliacciocabc60c2013-05-09 11:33:16 -070079}
80
81# Restore xtrace
82$MY_XTRACE