Browse code

Support for the ml2 quantum plugin.

Support is added for configuring devstack to use quantum's Modular L2
plugin, ml2. See https://review.openstack.org/#/c/20105/ and the
blueprint for details. Either the openvswitch or linuxbridge L2 agent
can be used with the ml2 plugin (or both in combination on different
nodes). Code configurating devstack for these L2 agents has been moved
into separate files so it can be shared between ml2 and the existing
monolithic plugins.

To use ml2 in devstack, set Q_PLUGIN=ml2 in localrc. By default it
will use the openvswitch L2 agent. To use ml2 with the linuxbridge
agent, also set Q_AGENT=linuxbridge in localrc. The local, flat, and
vlan network types are supported with either agent. Support for
openvswitch's gre network type is not yet implemented in ml2.

Note that ml2 does not yet return a useful value for binding:vif_type,
so nova's GenricVIFDriver cannot currently be used. If using the
linuxbridge agent, work around this by setting
NOVA_VIF_DRIVER=nova.virt.libvirt.vif.LinuxBridgeVIFDriver in localrc.

Implements: blueprint modular-l2
Change-Id: Ib3ed039d25295cf1ab268536cec408af8cd3795a

Bob Kukura authored on 2013/04/24 05:28:24
Showing 5 changed files
... ...
@@ -5,19 +5,6 @@
5 5
 MY_XTRACE=$(set +o | grep xtrace)
6 6
 set +o xtrace
7 7
 
8
-function is_quantum_ovs_base_plugin() {
9
-    # linuxbridge doesn't use OVS
10
-    return 1
11
-}
12
-
13
-function quantum_plugin_create_nova_conf() {
14
-    NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
15
-}
16
-
17
-function quantum_plugin_install_agent_packages() {
18
-    install_package bridge-utils
19
-}
20
-
21 8
 function quantum_plugin_configure_common() {
22 9
     Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge
23 10
     Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
... ...
@@ -25,37 +12,6 @@ function quantum_plugin_configure_common() {
25 25
     Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
26 26
 }
27 27
 
28
-function quantum_plugin_configure_debug_command() {
29
-    iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge
30
-}
31
-
32
-function quantum_plugin_configure_dhcp_agent() {
33
-    iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
34
-}
35
-
36
-function quantum_plugin_configure_l3_agent() {
37
-    iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge
38
-    iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
39
-}
40
-
41
-function quantum_plugin_configure_plugin_agent() {
42
-    # Setup physical network interface mappings.  Override
43
-    # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
44
-    # complex physical network configurations.
45
-    if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
46
-        LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
47
-    fi
48
-    if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
49
-        iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
50
-    fi
51
-    if [[ "$Q_USE_SECGROUP" == "True" ]]; then
52
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
53
-    else
54
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
55
-    fi
56
-    AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
57
-}
58
-
59 28
 function quantum_plugin_configure_service() {
60 29
     if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
61 30
         iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
... ...
@@ -81,19 +37,10 @@ function quantum_plugin_configure_service() {
81 81
     fi
82 82
 }
83 83
 
84
-function quantum_plugin_setup_interface_driver() {
85
-    local conf_file=$1
86
-    iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
87
-}
88
-
89 84
 function has_quantum_plugin_security_group() {
90 85
     # 0 means True here
91 86
     return 0
92 87
 }
93 88
 
94
-function quantum_plugin_check_adv_test_requirements() {
95
-    is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
96
-}
97
-
98 89
 # Restore xtrace
99 90
 $MY_XTRACE
100 91
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+# Quantum Linux Bridge L2 agent
1
+# -----------------------------
2
+
3
+# Save trace setting
4
+PLUGIN_XTRACE=$(set +o | grep xtrace)
5
+set +o xtrace
6
+
7
+function is_quantum_ovs_base_plugin() {
8
+    # linuxbridge doesn't use OVS
9
+    return 1
10
+}
11
+
12
+function quantum_plugin_create_nova_conf() {
13
+    NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
14
+}
15
+
16
+function quantum_plugin_install_agent_packages() {
17
+    install_package bridge-utils
18
+}
19
+
20
+function quantum_plugin_configure_debug_command() {
21
+    iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge
22
+}
23
+
24
+function quantum_plugin_configure_dhcp_agent() {
25
+    iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
26
+}
27
+
28
+function quantum_plugin_configure_l3_agent() {
29
+    iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge
30
+    iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
31
+}
32
+
33
+function quantum_plugin_configure_plugin_agent() {
34
+    # Setup physical network interface mappings.  Override
35
+    # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
36
+    # complex physical network configurations.
37
+    if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
38
+        LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
39
+    fi
40
+    if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
41
+        iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
42
+    fi
43
+    if [[ "$Q_USE_SECGROUP" == "True" ]]; then
44
+        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
45
+    else
46
+        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
47
+    fi
48
+    AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
49
+}
50
+
51
+function quantum_plugin_setup_interface_driver() {
52
+    local conf_file=$1
53
+    iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
54
+}
55
+
56
+function quantum_plugin_check_adv_test_requirements() {
57
+    is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
58
+}
59
+
60
+# Restore xtrace
61
+$PLUGIN_XTRACE
0 62
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+# Quantum Modular Layer 2 plugin
1
+# ------------------------------
2
+
3
+# Save trace setting
4
+MY_XTRACE=$(set +o | grep xtrace)
5
+set +o xtrace
6
+
7
+# Default openvswitch L2 agent
8
+Q_AGENT=${Q_AGENT:-openvswitch}
9
+source $TOP_DIR/lib/quantum_plugins/${Q_AGENT}_agent
10
+
11
+function quantum_plugin_configure_common() {
12
+    Q_PLUGIN_CONF_PATH=etc/quantum/plugins/ml2
13
+    Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
14
+    Q_DB_NAME="quantum_ml2"
15
+    Q_PLUGIN_CLASS="quantum.plugins.ml2.plugin.Ml2Plugin"
16
+}
17
+
18
+function quantum_plugin_configure_service() {
19
+    if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
20
+        iniset /$Q_PLUGIN_CONF_FILE ml2 tenant_network_types gre
21
+        iniset /$Q_PLUGIN_CONF_FILE ml2_type_gre tunnel_id_ranges $TENANT_TUNNEL_RANGES
22
+    elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
23
+        iniset /$Q_PLUGIN_CONF_FILE ml2 tenant_network_types vlan
24
+    else
25
+        echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
26
+    fi
27
+
28
+    # Override ``ML2_VLAN_RANGES`` and any needed agent configuration
29
+    # variables in ``localrc`` for more complex physical network
30
+    # configurations.
31
+    if [[ "$ML2_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
32
+        ML2_VLAN_RANGES=$PHYSICAL_NETWORK
33
+        if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
34
+            ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
35
+        fi
36
+    fi
37
+    if [[ "$ML2_VLAN_RANGES" != "" ]]; then
38
+        iniset /$Q_PLUGIN_CONF_FILE ml2_type_vlan network_vlan_ranges $ML2_VLAN_RANGES
39
+    fi
40
+
41
+    # REVISIT(rkukura): Setting firewall_driver here for
42
+    # quantum.agent.securitygroups_rpc.is_firewall_enabled() which is
43
+    # used in the server, in case no L2 agent is configured on the
44
+    # server's node. If an L2 agent is configured, this will get
45
+    # overridden with the correct driver. The ml2 plugin should
46
+    # instead use its own config variable to indicate whether security
47
+    # groups is enabled, and that will need to be set here instead.
48
+    if [[ "$Q_USE_SECGROUP" == "True" ]]; then
49
+        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.not.a.real.FirewallDriver
50
+    else
51
+        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
52
+    fi
53
+
54
+}
55
+
56
+function has_quantum_plugin_security_group() {
57
+    return 0
58
+}
59
+
60
+# Restore xtrace
61
+$MY_XTRACE
... ...
@@ -1,25 +1,11 @@
1
-# Quantum Open vSwtich plugin
1
+# Quantum Open vSwitch plugin
2 2
 # ---------------------------
3 3
 
4 4
 # Save trace setting
5 5
 MY_XTRACE=$(set +o | grep xtrace)
6 6
 set +o xtrace
7 7
 
8
-source $TOP_DIR/lib/quantum_plugins/ovs_base
9
-
10
-function quantum_plugin_create_nova_conf() {
11
-    _quantum_ovs_base_configure_nova_vif_driver
12
-    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
13
-        iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
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
17
-    fi
18
-}
19
-
20
-function quantum_plugin_install_agent_packages() {
21
-    _quantum_ovs_base_install_agent_packages
22
-}
8
+source $TOP_DIR/lib/quantum_plugins/openvswitch_agent
23 9
 
24 10
 function quantum_plugin_configure_common() {
25 11
     Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
... ...
@@ -28,89 +14,6 @@ function quantum_plugin_configure_common() {
28 28
     Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
29 29
 }
30 30
 
31
-function quantum_plugin_configure_debug_command() {
32
-    _quantum_ovs_base_configure_debug_command
33
-}
34
-
35
-function quantum_plugin_configure_dhcp_agent() {
36
-    iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
37
-}
38
-
39
-function quantum_plugin_configure_l3_agent() {
40
-    _quantum_ovs_base_configure_l3_agent
41
-    iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
42
-}
43
-
44
-function quantum_plugin_configure_plugin_agent() {
45
-    # Setup integration bridge
46
-    _quantum_ovs_base_setup_bridge $OVS_BRIDGE
47
-    _quantum_ovs_base_configure_firewall_driver
48
-
49
-    # Setup agent for tunneling
50
-    if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
51
-        # Verify tunnels are supported
52
-        # REVISIT - also check kernel module support for GRE and patch ports
53
-        OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
54
-        if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
55
-            die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
56
-        fi
57
-        iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
58
-        iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
59
-    fi
60
-
61
-    # Setup physical network bridge mappings.  Override
62
-    # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
63
-    # complex physical network configurations.
64
-    if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
65
-        OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
66
-
67
-        # Configure bridge manually with physical interface as port for multi-node
68
-        sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
69
-    fi
70
-    if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
71
-        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
72
-    fi
73
-    AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
74
-
75
-    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
76
-        # Make a copy of our config for domU
77
-        sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domu"
78
-
79
-        # Deal with Dom0's L2 Agent:
80
-        Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
81
-
82
-        # For now, duplicate the xen configuration already found in nova.conf
83
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_url "$XENAPI_CONNECTION_URL"
84
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_username "$XENAPI_USER"
85
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_password "$XENAPI_PASSWORD"
86
-
87
-        # Under XS/XCP, the ovs agent needs to target the dom0
88
-        # integration bridge.  This is enabled by using a root wrapper
89
-        # that executes commands on dom0 via a XenAPI plugin.
90
-        iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
91
-
92
-        # Set "physical" mapping
93
-        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
94
-
95
-        # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
96
-        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE
97
-
98
-        # Set up domU's L2 agent:
99
-
100
-        # Create a bridge "br-$GUEST_INTERFACE_DEFAULT"
101
-        sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT"
102
-        # Add $GUEST_INTERFACE_DEFAULT to that bridge
103
-        sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
104
-
105
-        # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
106
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
107
-        # Set integration bridge to domU's
108
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE
109
-        # Set root wrap
110
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND"
111
-    fi
112
-}
113
-
114 31
 function quantum_plugin_configure_service() {
115 32
     if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
116 33
         iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
... ...
@@ -141,18 +44,9 @@ function quantum_plugin_configure_service() {
141 141
     _quantum_ovs_base_configure_firewall_driver
142 142
 }
143 143
 
144
-function quantum_plugin_setup_interface_driver() {
145
-    local conf_file=$1
146
-    iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
147
-}
148
-
149 144
 function has_quantum_plugin_security_group() {
150 145
     return 0
151 146
 }
152 147
 
153
-function quantum_plugin_check_adv_test_requirements() {
154
-    is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
155
-}
156
-
157 148
 # Restore xtrace
158 149
 $MY_XTRACE
159 150
new file mode 100644
... ...
@@ -0,0 +1,117 @@
0
+# Quantum Open vSwitch L2 agent
1
+# -----------------------------
2
+
3
+# Save trace setting
4
+PLUGIN_XTRACE=$(set +o | grep xtrace)
5
+set +o xtrace
6
+
7
+source $TOP_DIR/lib/quantum_plugins/ovs_base
8
+
9
+function quantum_plugin_create_nova_conf() {
10
+    _quantum_ovs_base_configure_nova_vif_driver
11
+    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
12
+        iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
13
+        iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $XEN_INTEGRATION_BRIDGE
14
+        # Disable nova's firewall so that it does not conflict with quantum
15
+        iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
16
+    fi
17
+}
18
+
19
+function quantum_plugin_install_agent_packages() {
20
+    _quantum_ovs_base_install_agent_packages
21
+}
22
+
23
+function quantum_plugin_configure_debug_command() {
24
+    _quantum_ovs_base_configure_debug_command
25
+}
26
+
27
+function quantum_plugin_configure_dhcp_agent() {
28
+    iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
29
+}
30
+
31
+function quantum_plugin_configure_l3_agent() {
32
+    _quantum_ovs_base_configure_l3_agent
33
+    iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
34
+}
35
+
36
+function quantum_plugin_configure_plugin_agent() {
37
+    # Setup integration bridge
38
+    _quantum_ovs_base_setup_bridge $OVS_BRIDGE
39
+    _quantum_ovs_base_configure_firewall_driver
40
+
41
+    # Setup agent for tunneling
42
+    if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
43
+        # Verify tunnels are supported
44
+        # REVISIT - also check kernel module support for GRE and patch ports
45
+        OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
46
+        if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
47
+            die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
48
+        fi
49
+        iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
50
+        iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
51
+    fi
52
+
53
+    # Setup physical network bridge mappings.  Override
54
+    # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
55
+    # complex physical network configurations.
56
+    if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
57
+        OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
58
+
59
+        # Configure bridge manually with physical interface as port for multi-node
60
+        sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
61
+    fi
62
+    if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
63
+        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
64
+    fi
65
+    AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
66
+
67
+    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
68
+        # Make a copy of our config for domU
69
+        sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domu"
70
+
71
+        # Deal with Dom0's L2 Agent:
72
+        Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
73
+
74
+        # For now, duplicate the xen configuration already found in nova.conf
75
+        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_url "$XENAPI_CONNECTION_URL"
76
+        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_username "$XENAPI_USER"
77
+        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_password "$XENAPI_PASSWORD"
78
+
79
+        # Under XS/XCP, the ovs agent needs to target the dom0
80
+        # integration bridge.  This is enabled by using a root wrapper
81
+        # that executes commands on dom0 via a XenAPI plugin.
82
+        iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
83
+
84
+        # Set "physical" mapping
85
+        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
86
+
87
+        # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
88
+        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE
89
+
90
+        # Set up domU's L2 agent:
91
+
92
+        # Create a bridge "br-$GUEST_INTERFACE_DEFAULT"
93
+        sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT"
94
+        # Add $GUEST_INTERFACE_DEFAULT to that bridge
95
+        sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
96
+
97
+        # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
98
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
99
+        # Set integration bridge to domU's
100
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE
101
+        # Set root wrap
102
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND"
103
+    fi
104
+}
105
+
106
+function quantum_plugin_setup_interface_driver() {
107
+    local conf_file=$1
108
+    iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
109
+}
110
+
111
+function quantum_plugin_check_adv_test_requirements() {
112
+    is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
113
+}
114
+
115
+# Restore xtrace
116
+$PLUGIN_XTRACE