blob: 5a843ffba7fb89d19c28613874fd70000e60ebca [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mark McClainb05c8762013-07-06 23:29:39 -04003# Neutron Open vSwitch L2 agent
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04004# -----------------------------
5
6# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05007OVSA_XTRACE=$(set +o | grep xtrace)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04008set +o xtrace
9
Mark McClainb05c8762013-07-06 23:29:39 -040010source $TOP_DIR/lib/neutron_plugins/ovs_base
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040011
Ian Wienandaee18c72014-02-21 15:35:08 +110012function neutron_plugin_create_nova_conf {
Mark McClainb05c8762013-07-06 23:29:39 -040013 _neutron_ovs_base_configure_nova_vif_driver
Kyle Mesterybd085502014-04-30 23:50:29 +000014 if [ "$VIRT_DRIVER" == 'xenserver' ]; then
Gary Kotton51c681d2014-04-22 01:40:56 -070015 iniset $NOVA_CONF xenserver vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
16 iniset $NOVA_CONF xenserver ovs_integration_bridge $XEN_INTEGRATION_BRIDGE
Mark McClainb05c8762013-07-06 23:29:39 -040017 # Disable nova's firewall so that it does not conflict with neutron
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040018 iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
19 fi
20}
21
Ian Wienandaee18c72014-02-21 15:35:08 +110022function neutron_plugin_install_agent_packages {
Mark McClainb05c8762013-07-06 23:29:39 -040023 _neutron_ovs_base_install_agent_packages
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040024}
25
Ian Wienandaee18c72014-02-21 15:35:08 +110026function neutron_plugin_configure_debug_command {
Mark McClainb05c8762013-07-06 23:29:39 -040027 _neutron_ovs_base_configure_debug_command
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040028}
29
Ian Wienandaee18c72014-02-21 15:35:08 +110030function neutron_plugin_configure_dhcp_agent {
Mark McClainb05c8762013-07-06 23:29:39 -040031 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040032}
33
Ian Wienandaee18c72014-02-21 15:35:08 +110034function neutron_plugin_configure_l3_agent {
Mark McClainb05c8762013-07-06 23:29:39 -040035 _neutron_ovs_base_configure_l3_agent
36 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040037}
38
Ian Wienandaee18c72014-02-21 15:35:08 +110039function neutron_plugin_configure_plugin_agent {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040040 # Setup integration bridge
Mark McClainb05c8762013-07-06 23:29:39 -040041 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
42 _neutron_ovs_base_configure_firewall_driver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040043
44 # Setup agent for tunneling
Kyle Mesterybd085502014-04-30 23:50:29 +000045 if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040046 # Verify tunnels are supported
47 # REVISIT - also check kernel module support for GRE and patch ports
Kyle Mestery51a3f1f2013-06-13 11:47:56 +000048 OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"`
49 if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ] && ! is_service_enabled q-svc ; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040050 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
51 fi
Edgar Magana6f335b92014-07-10 15:42:44 -070052 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP
Hirofumi Ichiharad48d6722015-07-04 22:58:44 +090053 iniset /$Q_PLUGIN_CONF_FILE ovs tunnel_bridge $OVS_TUNNEL_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040054 fi
55
56 # Setup physical network bridge mappings. Override
57 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
58 # complex physical network configurations.
Kyle Mesterybd085502014-04-30 23:50:29 +000059 if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040060 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
61
62 # Configure bridge manually with physical interface as port for multi-node
Waldemar Znoinskid4c89282015-05-07 17:14:21 +010063 _neutron_ovs_base_add_bridge $OVS_PHYSICAL_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040064 fi
65 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
Gary Kottond42634f2013-06-24 09:26:55 +000066 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040067 fi
Mark McClainb05c8762013-07-06 23:29:39 -040068 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040069
Kyle Mesterybd085502014-04-30 23:50:29 +000070 if [ "$VIRT_DRIVER" == 'xenserver' ]; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040071 # Make a copy of our config for domU
Mate Lakat1a247e82014-08-05 14:32:51 +010072 sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domU"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040073
74 # Deal with Dom0's L2 Agent:
Mark McClainb05c8762013-07-06 23:29:39 -040075 Q_RR_DOM0_COMMAND="$NEUTRON_BIN_DIR/neutron-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040076
77 # For now, duplicate the xen configuration already found in nova.conf
Gary Kottond42634f2013-06-24 09:26:55 +000078 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_url "$XENAPI_CONNECTION_URL"
79 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_username "$XENAPI_USER"
80 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_password "$XENAPI_PASSWORD"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040081
82 # Under XS/XCP, the ovs agent needs to target the dom0
83 # integration bridge. This is enabled by using a root wrapper
84 # that executes commands on dom0 via a XenAPI plugin.
Gary Kottond42634f2013-06-24 09:26:55 +000085 iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040086
87 # Set "physical" mapping
Gary Kottond42634f2013-06-24 09:26:55 +000088 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040089
90 # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
Gary Kottond42634f2013-06-24 09:26:55 +000091 iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040092
93 # Set up domU's L2 agent:
94
95 # Create a bridge "br-$GUEST_INTERFACE_DEFAULT"
Waldemar Znoinskid4c89282015-05-07 17:14:21 +010096 _neutron_ovs_base_add_bridge "br-$GUEST_INTERFACE_DEFAULT"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040097 # Add $GUEST_INTERFACE_DEFAULT to that bridge
98 sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
99
100 # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
Gary Kottond42634f2013-06-24 09:26:55 +0000101 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400102 # Set integration bridge to domU's
Gary Kottond42634f2013-06-24 09:26:55 +0000103 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400104 # Set root wrap
Gary Kottond42634f2013-06-24 09:26:55 +0000105 iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400106 fi
Akihiro Motoki2307f9d2014-08-09 18:58:20 +0900107 iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES
Michal Ptacekc1605552015-09-23 21:02:02 +0100108 iniset /$Q_PLUGIN_CONF_FILE ovs datapath_type $OVS_DATAPATH_TYPE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400109}
110
Ian Wienandaee18c72014-02-21 15:35:08 +1100111function neutron_plugin_setup_interface_driver {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400112 local conf_file=$1
Martin Hickeydca49de2015-10-20 12:13:19 +0100113 iniset $conf_file DEFAULT interface_driver openvswitch
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400114}
115
Ian Wienandaee18c72014-02-21 15:35:08 +1100116function neutron_plugin_check_adv_test_requirements {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400117 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
118}
119
120# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500121$OVSA_XTRACE