blob: 46c2a5c6e299aa98d581853e3930a8ccd0f84eee [file] [log] [blame]
Mark McClainb05c8762013-07-06 23:29:39 -04001# Neutron Open vSwitch L2 agent
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04002# -----------------------------
3
4# Save trace setting
5PLUGIN_XTRACE=$(set +o | grep xtrace)
6set +o xtrace
7
Mark McClainb05c8762013-07-06 23:29:39 -04008source $TOP_DIR/lib/neutron_plugins/ovs_base
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04009
Mark McClainb05c8762013-07-06 23:29:39 -040010function neutron_plugin_create_nova_conf() {
11 _neutron_ovs_base_configure_nova_vif_driver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040012 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
Mark McClainb05c8762013-07-06 23:29:39 -040015 # Disable nova's firewall so that it does not conflict with neutron
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040016 iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
17 fi
18}
19
Mark McClainb05c8762013-07-06 23:29:39 -040020function neutron_plugin_install_agent_packages() {
21 _neutron_ovs_base_install_agent_packages
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040022}
23
Mark McClainb05c8762013-07-06 23:29:39 -040024function neutron_plugin_configure_debug_command() {
25 _neutron_ovs_base_configure_debug_command
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040026}
27
Mark McClainb05c8762013-07-06 23:29:39 -040028function neutron_plugin_configure_dhcp_agent() {
29 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040030}
31
Mark McClainb05c8762013-07-06 23:29:39 -040032function neutron_plugin_configure_l3_agent() {
33 _neutron_ovs_base_configure_l3_agent
34 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040035}
36
Mark McClainb05c8762013-07-06 23:29:39 -040037function neutron_plugin_configure_plugin_agent() {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040038 # Setup integration bridge
Mark McClainb05c8762013-07-06 23:29:39 -040039 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
40 _neutron_ovs_base_configure_firewall_driver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040041
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
Mark McClainb05c8762013-07-06 23:29:39 -040066 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040067
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:
Mark McClainb05c8762013-07-06 23:29:39 -040073 Q_RR_DOM0_COMMAND="$NEUTRON_BIN_DIR/neutron-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040074
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
Mark McClainb05c8762013-07-06 23:29:39 -0400121function neutron_plugin_setup_interface_driver() {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400122 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -0400123 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400124}
125
Mark McClainb05c8762013-07-06 23:29:39 -0400126function neutron_plugin_check_adv_test_requirements() {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400127 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
128}
129
130# Restore xtrace
131$PLUGIN_XTRACE