Browse code

Merge "xenapi - quantum: L2 agents for dom0 and domU"

Jenkins authored on 2013/06/02 01:30:39
Showing 6 changed files
... ...
@@ -80,7 +80,10 @@ if [ "$VIRT_DRIVER" = 'xenserver' ]; then
80 80
     PUBLIC_INTERFACE_DEFAULT=eth3
81 81
     GUEST_INTERFACE_DEFAULT=eth1
82 82
     # Allow ``build_domU.sh`` to specify the flat network bridge via kernel args
83
-    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u)
83
+    FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
84
+    if is_service_enabled quantum; then
85
+        XEN_INTEGRATION_BRIDGE=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
86
+    fi
84 87
 elif [ "$VIRT_DRIVER" = 'baremetal' ]; then
85 88
     NETWORK_MANAGER=${NETWORK_MANAGER:-FlatManager}
86 89
     PUBLIC_INTERFACE_DEFAULT=eth0
... ...
@@ -386,6 +386,11 @@ function start_quantum_agents() {
386 386
     screen_it q-l3 "cd $QUANTUM_DIR && python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
387 387
     screen_it q-meta "cd $QUANTUM_DIR && python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
388 388
 
389
+    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
390
+        # For XenServer, start an agent for the domU openvswitch
391
+        screen_it q-domua "cd $QUANTUM_DIR && python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE.domU"
392
+    fi
393
+
389 394
     if is_service_enabled q-lbaas; then
390 395
         screen_it q-lbaas "cd $QUANTUM_DIR && python $AGENT_LBAAS_BINARY --config-file $QUANTUM_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME"
391 396
     fi
... ...
@@ -11,7 +11,9 @@ function quantum_plugin_create_nova_conf() {
11 11
     _quantum_ovs_base_configure_nova_vif_driver
12 12
     if [ "$VIRT_DRIVER" = 'xenserver' ]; then
13 13
         iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
14
-        iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $FLAT_NETWORK_BRIDGE
14
+        iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $XEN_INTEGRATION_BRIDGE
15
+        # Disable nova's firewall so that it does not conflict with quantum
16
+        iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
15 17
     fi
16 18
 }
17 19
 
... ...
@@ -71,6 +73,10 @@ function quantum_plugin_configure_plugin_agent() {
71 71
     AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
72 72
 
73 73
     if [ "$VIRT_DRIVER" = 'xenserver' ]; then
74
+        # Make a copy of our config for domU
75
+        sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domu"
76
+
77
+        # Deal with Dom0's L2 Agent:
74 78
         Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
75 79
 
76 80
         # For now, duplicate the xen configuration already found in nova.conf
... ...
@@ -83,29 +89,25 @@ function quantum_plugin_configure_plugin_agent() {
83 83
         # that executes commands on dom0 via a XenAPI plugin.
84 84
         iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
85 85
 
86
-        # FLAT_NETWORK_BRIDGE is the dom0 integration bridge.  To
87
-        # ensure the bridge lacks direct connectivity, set
88
-        # VM_VLAN=-1;VM_DEV=invalid in localrc
89
-        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
90
-
91
-        # The ovs agent needs to ensure that the ports associated with
92
-        # a given network share the same local vlan tag.  On
93
-        # single-node XS/XCP, this requires monitoring both the dom0
94
-        # bridge, where VM's are attached, and the domU bridge, where
95
-        # dhcp servers are attached.
96
-        if is_service_enabled q-dhcp; then
97
-            iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
98
-            # DomU will use the regular rootwrap
99
-            iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
100
-            # Plug the vm interface into the domU integration bridge.
101
-            sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
102
-            sudo ip link set $OVS_BRIDGE up
103
-            # Assign the VM IP only if it has been set explicitly
104
-            if [[ "$VM_IP" != "" ]]; then
105
-                sudo ip addr add $VM_IP dev $OVS_BRIDGE
106
-            fi
107
-            sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
108
-        fi
86
+        # Set "physical" mapping
87
+        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
88
+
89
+        # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
90
+        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE
91
+
92
+        # Set up domU's L2 agent:
93
+
94
+        # Create a bridge "br-$GUEST_INTERFACE_DEFAULT"
95
+        sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT"
96
+        # Add $GUEST_INTERFACE_DEFAULT to that bridge
97
+        sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
98
+
99
+        # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
100
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
101
+        # Set integration bridge to domU's
102
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE
103
+        # Set root wrap
104
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND"
109 105
     fi
110 106
 }
111 107
 
... ...
@@ -123,6 +123,32 @@ function _bridge_exists() {
123 123
     ! [ -z $(xe network-list bridge="$bridge" --minimal) ]
124 124
 }
125 125
 
126
+function _network_uuid() {
127
+    local bridge_or_net_name
128
+    bridge_or_net_name=$1
129
+
130
+    if _bridge_exists "$bridge_or_net_name"; then
131
+        xe network-list bridge="$bridge_or_net_name" --minimal
132
+    else
133
+        xe network-list name-label="$bridge_or_net_name" --minimal
134
+    fi
135
+}
136
+
137
+function add_interface() {
138
+    local vm_name
139
+    local bridge_or_network_name
140
+
141
+    vm_name="$1"
142
+    bridge_or_network_name="$2"
143
+    device_number="$3"
144
+
145
+    local vm
146
+    local net
147
+
148
+    vm=$(xe vm-list name-label="$vm_name" --minimal)
149
+    net=$(_network_uuid "$bridge_or_network_name")
150
+    xe vif-create network-uuid=$net vm-uuid=$vm device=$device_number
151
+}
126 152
 
127 153
 function setup_network() {
128 154
     local bridge_or_net_name
... ...
@@ -71,6 +71,12 @@ setup_network "$VM_BRIDGE_OR_NET_NAME"
71 71
 setup_network "$MGT_BRIDGE_OR_NET_NAME"
72 72
 setup_network "$PUB_BRIDGE_OR_NET_NAME"
73 73
 
74
+# With quantum, one more network is required, which is internal to the
75
+# hypervisor, and used by the VMs
76
+if is_service_enabled quantum; then
77
+    setup_network "$XEN_INT_BRIDGE_OR_NET_NAME"
78
+fi
79
+
74 80
 if parameter_is_specified "FLAT_NETWORK_BRIDGE"; then
75 81
     cat >&2 << EOF
76 82
 ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file
... ...
@@ -195,6 +201,12 @@ if [ -z "$templateuuid" ]; then
195 195
     # create a new VM with the given template
196 196
     # creating the correct VIFs and metadata
197 197
     FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME")
198
+
199
+    KERNEL_PARAMS_FOR_QUANTUM=""
200
+    if is_service_enabled quantum; then
201
+        XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME")
202
+        KERNEL_PARAMS_FOR_QUANTUM="xen_integration_bridge=${XEN_INTEGRATION_BRIDGE}"
203
+    fi
198 204
     $THIS_DIR/scripts/install-os-vpx.sh \
199 205
         -t "$UBUNTU_INST_TEMPLATE_NAME" \
200 206
         -v "$VM_BRIDGE_OR_NET_NAME" \
... ...
@@ -202,7 +214,7 @@ if [ -z "$templateuuid" ]; then
202 202
         -p "$PUB_BRIDGE_OR_NET_NAME" \
203 203
         -l "$GUEST_NAME" \
204 204
         -r "$OSDOMU_MEM_MB" \
205
-        -k "flat_network_bridge=${FLAT_NETWORK_BRIDGE}"
205
+        -k "flat_network_bridge=${FLAT_NETWORK_BRIDGE} ${KERNEL_PARAMS_FOR_QUANTUM}"
206 206
 
207 207
     # wait for install to finish
208 208
     wait_for_VM_to_halt
... ...
@@ -240,11 +252,16 @@ fi
240 240
 #
241 241
 $THIS_DIR/build_xva.sh "$GUEST_NAME"
242 242
 
243
+# Attach a network interface for the integration network (so that the bridge
244
+# is created by XenServer). This is required for Quantum.
245
+if is_service_enabled quantum; then
246
+    add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" "4"
247
+fi
248
+
243 249
 # create a snapshot before the first boot
244 250
 # to allow a quick re-run with the same settings
245 251
 xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT"
246 252
 
247
-
248 253
 #
249 254
 # Run DevStack VM
250 255
 #
... ...
@@ -25,6 +25,7 @@ OSDOMU_VDI_GB=8
25 25
 MGT_BRIDGE_OR_NET_NAME="xenbr0"
26 26
 VM_BRIDGE_OR_NET_NAME="OpenStack VM Network"
27 27
 PUB_BRIDGE_OR_NET_NAME="OpenStack Public Network"
28
+XEN_INT_BRIDGE_OR_NET_NAME="OpenStack VM Integration Network"
28 29
 
29 30
 # VM Password
30 31
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}