Browse code

Merge "ofagent: Support physical_interface_mappings"

Jenkins authored on 2014/10/18 01:09:46
Showing 3 changed files
... ...
@@ -148,16 +148,31 @@ PROVIDER_SUBNET_NAME=${PROVIDER_SUBNET_NAME:-"provider_net"}
148 148
 # If Q_USE_PROVIDERNET_FOR_PUBLIC=True, use a flat provider network
149 149
 # for external interface of neutron l3-agent.  In that case,
150 150
 # PUBLIC_PHYSICAL_NETWORK specifies provider:physical_network value
151
-# used for the network.  In case of openvswitch agent, you should
152
-# add the corresponding entry to your OVS_BRIDGE_MAPPINGS.
151
+# used for the network.  In case of ofagent, you should add the
152
+# corresponding entry to your OFAGENT_PHYSICAL_INTERFACE_MAPPINGS.
153
+# For openvswitch agent, you should add the corresponding entry to
154
+# your OVS_BRIDGE_MAPPINGS.
153 155
 #
154
-# eg.
156
+# eg.  (ofagent)
157
+#    Q_USE_PROVIDERNET_FOR_PUBLIC=True
158
+#    Q_USE_PUBLIC_VETH=True
159
+#    PUBLIC_PHYSICAL_NETWORK=public
160
+#    OFAGENT_PHYSICAL_INTERFACE_MAPPINGS=public:veth-pub-int
161
+#
162
+# eg.  (openvswitch agent)
155 163
 #    Q_USE_PROVIDERNET_FOR_PUBLIC=True
156 164
 #    PUBLIC_PHYSICAL_NETWORK=public
157 165
 #    OVS_BRIDGE_MAPPINGS=public:br-ex
158 166
 Q_USE_PROVIDERNET_FOR_PUBLIC=${Q_USE_PROVIDERNET_FOR_PUBLIC:-False}
159 167
 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK:-public}
160 168
 
169
+# If Q_USE_PUBLIC_VETH=True, create and use a veth pair instead of
170
+# PUBLIC_BRIDGE.  This is intended to be used with
171
+# Q_USE_PROVIDERNET_FOR_PUBLIC=True.
172
+Q_USE_PUBLIC_VETH=${Q_USE_PUBLIC_VETH:-False}
173
+Q_PUBLIC_VETH_EX=${Q_PUBLIC_VETH_EX:-veth-pub-ex}
174
+Q_PUBLIC_VETH_INT=${Q_PUBLIC_VETH_INT:-veth-pub-int}
175
+
161 176
 # The next two variables are configured by plugin
162 177
 # e.g.  _configure_neutron_l3_agent or lib/neutron_plugins/*
163 178
 #
... ...
@@ -543,12 +558,20 @@ function create_neutron_initial_network {
543 543
         if is_service_enabled q-l3; then
544 544
             # logic is specific to using the l3-agent for l3
545 545
             if is_neutron_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
546
-                # Disable in-band as we are going to use local port
547
-                # to communicate with VMs
548
-                sudo ovs-vsctl set Bridge $PUBLIC_BRIDGE other_config:disable-in-band=true
546
+                local ext_gw_interface
547
+
548
+                if [[ "$Q_USE_PUBLIC_VETH" = "True" ]]; then
549
+                    ext_gw_interface=$Q_PUBLIC_VETH_EX
550
+                else
551
+                    # Disable in-band as we are going to use local port
552
+                    # to communicate with VMs
553
+                    sudo ovs-vsctl set Bridge $PUBLIC_BRIDGE \
554
+                        other_config:disable-in-band=true
555
+                    ext_gw_interface=$PUBLIC_BRIDGE
556
+                fi
549 557
                 CIDR_LEN=${FLOATING_RANGE#*/}
550
-                sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
551
-                sudo ip link set $PUBLIC_BRIDGE up
558
+                sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $ext_gw_interface
559
+                sudo ip link set $ext_gw_interface up
552 560
                 ROUTER_GW_IP=`neutron port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
553 561
                 die_if_not_set $LINENO ROUTER_GW_IP "Failure retrieving ROUTER_GW_IP"
554 562
                 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
... ...
@@ -77,6 +77,10 @@ function neutron_plugin_configure_plugin_agent {
77 77
     if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
78 78
         iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
79 79
     fi
80
+    if [[ "$OFAGENT_PHYSICAL_INTERFACE_MAPPINGS" != "" ]]; then
81
+        iniset /$Q_PLUGIN_CONF_FILE agent physical_interface_mappings \
82
+            $OFAGENT_PHYSICAL_INTERFACE_MAPPINGS
83
+    fi
80 84
     AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ofagent-agent"
81 85
 
82 86
     iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES
... ...
@@ -79,11 +79,20 @@ function _neutron_ovs_base_configure_l3_agent {
79 79
     fi
80 80
 
81 81
     neutron-ovs-cleanup
82
-    # --no-wait causes a race condition if $PUBLIC_BRIDGE is not up when ip addr flush is called
83
-    sudo ovs-vsctl -- --may-exist add-br $PUBLIC_BRIDGE
84
-    sudo ovs-vsctl br-set-external-id $PUBLIC_BRIDGE bridge-id $PUBLIC_BRIDGE
85
-    # ensure no IP is configured on the public bridge
86
-    sudo ip addr flush dev $PUBLIC_BRIDGE
82
+    if [[ "$Q_USE_PUBLIC_VETH" = "True" ]]; then
83
+        ip link show $Q_PUBLIC_VETH_INT > /dev/null 2>&1 ||
84
+        sudo ip link add $Q_PUBLIC_VETH_INT type veth \
85
+            peer name $Q_PUBLIC_VETH_EX
86
+        sudo ip link set $Q_PUBLIC_VETH_INT up
87
+        sudo ip link set $Q_PUBLIC_VETH_EX up
88
+        sudo ip addr flush dev $Q_PUBLIC_VETH_EX
89
+    else
90
+        # --no-wait causes a race condition if $PUBLIC_BRIDGE is not up when ip addr flush is called
91
+        sudo ovs-vsctl -- --may-exist add-br $PUBLIC_BRIDGE
92
+        sudo ovs-vsctl br-set-external-id $PUBLIC_BRIDGE bridge-id $PUBLIC_BRIDGE
93
+        # ensure no IP is configured on the public bridge
94
+        sudo ip addr flush dev $PUBLIC_BRIDGE
95
+    fi
87 96
 }
88 97
 
89 98
 function _neutron_ovs_base_configure_nova_vif_driver {