Browse code

Merge "Add limited support for Quantum+OVS on XS/XCP."

Jenkins authored on 2013/01/16 06:10:19
Showing 2 changed files
... ...
@@ -212,6 +212,10 @@ function create_nova_conf_quantum() {
212 212
 
213 213
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
214 214
         NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
215
+        if [ "$VIRT_DRIVER" = 'xenserver' ]; then
216
+            add_nova_opt "xenapi_vif_driver=nova.virt.xenapi.vif.XenAPIOpenVswitchDriver"
217
+            add_nova_opt "xenapi_ovs_integration_bridge=$FLAT_NETWORK_BRIDGE"
218
+        fi
215 219
     elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
216 220
         NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"}
217 221
     elif [[ "$Q_PLUGIN" = "ryu" ]]; then
... ...
@@ -536,6 +540,11 @@ function _configure_quantum_metadata_agent() {
536 536
 # _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
537 537
 # It is called when q-agt is enabled.
538 538
 function _configure_quantum_plugin_agent() {
539
+
540
+    # Specify the default root helper prior to agent configuration to
541
+    # ensure that an agent's configuration can override the default.
542
+    iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
543
+
539 544
     # Configure agent for plugin
540 545
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
541 546
         _configure_quantum_plugin_agent_openvswitch
... ...
@@ -544,8 +553,6 @@ function _configure_quantum_plugin_agent() {
544 544
     elif [[ "$Q_PLUGIN" = "ryu" ]]; then
545 545
         _configure_quantum_plugin_agent_ryu
546 546
     fi
547
-
548
-    iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
549 547
 }
550 548
 
551 549
 function _configure_quantum_plugin_agent_linuxbridge() {
... ...
@@ -593,6 +600,41 @@ function _configure_quantum_plugin_agent_openvswitch() {
593 593
         iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
594 594
     fi
595 595
     AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
596
+
597
+    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
598
+        # Nova will always be installed along with quantum for a domU
599
+        # devstack install, so it should be safe to rely on nova.conf
600
+        # for xenapi configuration.
601
+        Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-dom0 $NOVA_CONF"
602
+        # Under XS/XCP, the ovs agent needs to target the dom0
603
+        # integration bridge.  This is enabled by using a root wrapper
604
+        # that executes commands on dom0 via a XenAPI plugin.
605
+        iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
606
+
607
+        # FLAT_NETWORK_BRIDGE is the dom0 integration bridge.  To
608
+        # ensure the bridge lacks direct connectivity, set
609
+        # VM_VLAN=-1;VM_DEV=invalid in localrc
610
+        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
611
+
612
+        # The ovs agent needs to ensure that the ports associated with
613
+        # a given network share the same local vlan tag.  On
614
+        # single-node XS/XCP, this requires monitoring both the dom0
615
+        # bridge, where VM's are attached, and the domU bridge, where
616
+        # dhcp servers are attached.
617
+        if is_service_enabled q-dhcp; then
618
+            iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
619
+            # DomU will use the regular rootwrap
620
+            iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
621
+            # Plug the vm interface into the domU integration bridge.
622
+            sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
623
+            sudo ip link set $OVS_BRIDGE up
624
+            # Assign the VM IP only if it has been set explicitly
625
+            if [[ "$VM_IP" != "" ]]; then
626
+                sudo ip addr add $VM_IP dev $OVS_BRIDGE
627
+            fi
628
+            sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
629
+        fi
630
+    fi
596 631
 }
597 632
 
598 633
 function _configure_quantum_plugin_agent_ryu() {
... ...
@@ -68,6 +68,19 @@ if [ ! -d $XAPI_PLUGIN_DIR ]; then
68 68
     XAPI_PLUGIN_DIR=/usr/lib/xcp/plugins/
69 69
 fi
70 70
 cp -pr ./nova/*/plugins/xenserver/xenapi/etc/xapi.d/plugins/* $XAPI_PLUGIN_DIR
71
+
72
+# Install the netwrap xapi plugin to support agent control of dom0 networking
73
+if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then
74
+    if [ -f ./quantum ]; then
75
+        rm -rf ./quantum
76
+    fi
77
+    # get quantum
78
+    QUANTUM_ZIPBALL_URL=${QUANTUM_ZIPBALL_URL:-$(echo $QUANTUM_REPO | sed "s:\.git$::;s:$:/zipball/$QUANTUM_BRANCH:g")}
79
+    wget $QUANTUM_ZIPBALL_URL -O quantum-zipball --no-check-certificate
80
+    unzip -o quantum-zipball  -d ./quantum
81
+    cp -pr ./quantum/*/quantum/plugins/openvswitch/agent/xenapi/etc/xapi.d/plugins/* $XAPI_PLUGIN_DIR
82
+fi
83
+
71 84
 chmod a+x ${XAPI_PLUGIN_DIR}*
72 85
 
73 86
 mkdir -p /boot/guest