blob: 608c3eae98b30e5352ee74f235b50907611839ef [file] [log] [blame]
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04001# Quantum Open vSwitch L2 agent
2# -----------------------------
3
4# Save trace setting
5PLUGIN_XTRACE=$(set +o | grep xtrace)
6set +o xtrace
7
8source $TOP_DIR/lib/quantum_plugins/ovs_base
9
10function 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
20function quantum_plugin_install_agent_packages() {
21 _quantum_ovs_base_install_agent_packages
22}
23
24function quantum_plugin_configure_debug_command() {
25 _quantum_ovs_base_configure_debug_command
26}
27
28function quantum_plugin_configure_dhcp_agent() {
29 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
30}
31
32function quantum_plugin_configure_l3_agent() {
33 _quantum_ovs_base_configure_l3_agent
34 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
35}
36
37function quantum_plugin_configure_plugin_agent() {
38 # Setup integration bridge
39 _quantum_ovs_base_setup_bridge $OVS_BRIDGE
40 _quantum_ovs_base_configure_firewall_driver
41
42 # Setup agent for tunneling
43 if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
44 # Verify tunnels are supported
45 # REVISIT - also check kernel module support for GRE and patch ports
Kyle Mestery51a3f1f2013-06-13 11:47:56 +000046 OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"`
47 if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ] && ! is_service_enabled q-svc ; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040048 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
49 fi
Gary Kottond42634f2013-06-24 09:26:55 +000050 iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True
51 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040052 fi
53
54 # Setup physical network bridge mappings. Override
55 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
56 # complex physical network configurations.
57 if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
58 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
59
60 # Configure bridge manually with physical interface as port for multi-node
61 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
62 fi
63 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
Gary Kottond42634f2013-06-24 09:26:55 +000064 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040065 fi
66 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
67
68 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
69 # Make a copy of our config for domU
70 sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domu"
71
72 # Deal with Dom0's L2 Agent:
73 Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
74
75 # For now, duplicate the xen configuration already found in nova.conf
Gary Kottond42634f2013-06-24 09:26:55 +000076 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_url "$XENAPI_CONNECTION_URL"
77 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_username "$XENAPI_USER"
78 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_password "$XENAPI_PASSWORD"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040079
80 # Under XS/XCP, the ovs agent needs to target the dom0
81 # integration bridge. This is enabled by using a root wrapper
82 # that executes commands on dom0 via a XenAPI plugin.
Gary Kottond42634f2013-06-24 09:26:55 +000083 iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040084
85 # Set "physical" mapping
Gary Kottond42634f2013-06-24 09:26:55 +000086 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040087
88 # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
Gary Kottond42634f2013-06-24 09:26:55 +000089 iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040090
91 # Set up domU's L2 agent:
92
93 # Create a bridge "br-$GUEST_INTERFACE_DEFAULT"
94 sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT"
95 # Add $GUEST_INTERFACE_DEFAULT to that bridge
96 sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
97
98 # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
Gary Kottond42634f2013-06-24 09:26:55 +000099 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400100 # Set integration bridge to domU's
Gary Kottond42634f2013-06-24 09:26:55 +0000101 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400102 # Set root wrap
Gary Kottond42634f2013-06-24 09:26:55 +0000103 iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400104 fi
Kyle Mesteryebfac642013-05-17 15:20:56 -0500105 # Define extra "AGENT" configuration options when q-agt is configured by defining
106 # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``.
107 # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)``
108 for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do
109 # Replace the first '=' with ' ' for iniset syntax
Gary Kottond42634f2013-06-24 09:26:55 +0000110 iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ }
Kyle Mesteryebfac642013-05-17 15:20:56 -0500111 done
112 # Define extra "OVS" configuration options when q-agt is configured by defining
113 # defining the array ``Q_AGENT_EXTRA_SRV_OPTS``.
114 # For Example: ``Q_AGENT_EXTRA_SRV_OPTS=(foo=true bar=2)``
115 for I in "${Q_AGENT_EXTRA_SRV_OPTS[@]}"; do
116 # Replace the first '=' with ' ' for iniset syntax
Gary Kottond42634f2013-06-24 09:26:55 +0000117 iniset /$Q_PLUGIN_CONF_FILE ovs ${I/=/ }
Kyle Mesteryebfac642013-05-17 15:20:56 -0500118 done
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400119}
120
121function quantum_plugin_setup_interface_driver() {
122 local conf_file=$1
123 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
124}
125
126function quantum_plugin_check_adv_test_requirements() {
127 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
128}
129
130# Restore xtrace
131$PLUGIN_XTRACE