blob: ee761edf66c47201a30971f17f50c41b3daf7583 [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
46 OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
47 if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
48 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
49 fi
50 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
51 iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
52 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
64 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
65 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
76 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"
79
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.
83 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
84
85 # Set "physical" mapping
86 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
87
88 # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
89 iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE
90
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"
99 iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
100 # Set integration bridge to domU's
101 iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE
102 # Set root wrap
103 iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND"
104 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
110 iniset /$Q_PLUGIN_CONF_FILE AGENT ${I/=/ }
111 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
117 iniset /$Q_PLUGIN_CONF_FILE OVS ${I/=/ }
118 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