| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 3 | # Neutron Open vSwitch L2 agent | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 4 | # ----------------------------- | 
|  | 5 |  | 
|  | 6 | # Save trace setting | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 7 | OVSA_XTRACE=$(set +o | grep xtrace) | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 8 | set +o xtrace | 
|  | 9 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 10 | source $TOP_DIR/lib/neutron_plugins/ovs_base | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 11 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 12 | function neutron_plugin_create_nova_conf { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 13 | _neutron_ovs_base_configure_nova_vif_driver | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 14 | if [ "$VIRT_DRIVER" == 'xenserver' ]; then | 
| Gary Kotton | 51c681d | 2014-04-22 01:40:56 -0700 | [diff] [blame] | 15 | iniset $NOVA_CONF xenserver vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver | 
|  | 16 | iniset $NOVA_CONF xenserver ovs_integration_bridge $XEN_INTEGRATION_BRIDGE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 17 | # Disable nova's firewall so that it does not conflict with neutron | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 18 | iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver | 
|  | 19 | fi | 
|  | 20 | } | 
|  | 21 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 22 | function neutron_plugin_install_agent_packages { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 23 | _neutron_ovs_base_install_agent_packages | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 24 | } | 
|  | 25 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 26 | function neutron_plugin_configure_debug_command { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 27 | _neutron_ovs_base_configure_debug_command | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 28 | } | 
|  | 29 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 30 | function neutron_plugin_configure_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 31 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 32 | } | 
|  | 33 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 34 | function neutron_plugin_configure_l3_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 35 | _neutron_ovs_base_configure_l3_agent | 
|  | 36 | iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 37 | } | 
|  | 38 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 39 | function neutron_plugin_configure_plugin_agent { | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 40 | # Setup integration bridge | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 41 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE | 
|  | 42 | _neutron_ovs_base_configure_firewall_driver | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 43 |  | 
|  | 44 | # Setup agent for tunneling | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 45 | if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 46 | # Verify tunnels are supported | 
|  | 47 | # REVISIT - also check kernel module support for GRE and patch ports | 
| Kyle Mestery | 51a3f1f | 2013-06-13 11:47:56 +0000 | [diff] [blame] | 48 | 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 Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 50 | die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts." | 
|  | 51 | fi | 
| Edgar Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 52 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 53 | fi | 
|  | 54 |  | 
|  | 55 | # Setup physical network bridge mappings.  Override | 
|  | 56 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more | 
|  | 57 | # complex physical network configurations. | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 58 | if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 59 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE | 
|  | 60 |  | 
|  | 61 | # Configure bridge manually with physical interface as port for multi-node | 
|  | 62 | sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE | 
|  | 63 | fi | 
|  | 64 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 65 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 66 | fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 67 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 68 |  | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 69 | if [ "$VIRT_DRIVER" == 'xenserver' ]; then | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 70 | # Make a copy of our config for domU | 
| Mate Lakat | 1a247e8 | 2014-08-05 14:32:51 +0100 | [diff] [blame] | 71 | sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domU" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 72 |  | 
|  | 73 | # Deal with Dom0's L2 Agent: | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 74 | Q_RR_DOM0_COMMAND="$NEUTRON_BIN_DIR/neutron-rootwrap-xen-dom0 $Q_RR_CONF_FILE" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 75 |  | 
|  | 76 | # For now, duplicate the xen configuration already found in nova.conf | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 77 | iniset $Q_RR_CONF_FILE xenapi xenapi_connection_url "$XENAPI_CONNECTION_URL" | 
|  | 78 | iniset $Q_RR_CONF_FILE xenapi xenapi_connection_username "$XENAPI_USER" | 
|  | 79 | iniset $Q_RR_CONF_FILE xenapi xenapi_connection_password "$XENAPI_PASSWORD" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 80 |  | 
|  | 81 | # Under XS/XCP, the ovs agent needs to target the dom0 | 
|  | 82 | # integration bridge.  This is enabled by using a root wrapper | 
|  | 83 | # that executes commands on dom0 via a XenAPI plugin. | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 84 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 85 |  | 
|  | 86 | # Set "physical" mapping | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 87 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 88 |  | 
|  | 89 | # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0 | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 90 | iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 91 |  | 
|  | 92 | # Set up domU's L2 agent: | 
|  | 93 |  | 
|  | 94 | # Create a bridge "br-$GUEST_INTERFACE_DEFAULT" | 
|  | 95 | sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT" | 
|  | 96 | # Add $GUEST_INTERFACE_DEFAULT to that bridge | 
|  | 97 | sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT | 
|  | 98 |  | 
|  | 99 | # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT" | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 100 | iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 101 | # Set integration bridge to domU's | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 102 | iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 103 | # Set root wrap | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 104 | iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND" | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 105 | fi | 
| Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 106 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES | 
| Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 107 | # Define extra "AGENT" configuration options when q-agt is configured by defining | 
|  | 108 | # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``. | 
|  | 109 | # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)`` | 
|  | 110 | for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do | 
|  | 111 | # Replace the first '=' with ' ' for iniset syntax | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 112 | iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ } | 
| Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 113 | done | 
|  | 114 | # Define extra "OVS" configuration options when q-agt is configured by defining | 
|  | 115 | # defining the array ``Q_AGENT_EXTRA_SRV_OPTS``. | 
|  | 116 | # For Example: ``Q_AGENT_EXTRA_SRV_OPTS=(foo=true bar=2)`` | 
|  | 117 | for I in "${Q_AGENT_EXTRA_SRV_OPTS[@]}"; do | 
|  | 118 | # Replace the first '=' with ' ' for iniset syntax | 
| Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 119 | iniset /$Q_PLUGIN_CONF_FILE ovs ${I/=/ } | 
| Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 120 | done | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 121 | } | 
|  | 122 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 123 | function neutron_plugin_setup_interface_driver { | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 124 | local conf_file=$1 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 125 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 126 | } | 
|  | 127 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 128 | function neutron_plugin_check_adv_test_requirements { | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 129 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 | 
|  | 130 | } | 
|  | 131 |  | 
|  | 132 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 133 | $OVSA_XTRACE |