Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 1 | # Neutron Open vSwitch L2 agent |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 2 | # ----------------------------- |
| 3 | |
| 4 | # Save trace setting |
| 5 | PLUGIN_XTRACE=$(set +o | grep xtrace) |
| 6 | set +o xtrace |
| 7 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 8 | source $TOP_DIR/lib/neutron_plugins/ovs_base |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 9 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 10 | function neutron_plugin_create_nova_conf() { |
| 11 | _neutron_ovs_base_configure_nova_vif_driver |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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 |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 15 | # Disable nova's firewall so that it does not conflict with neutron |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 16 | iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver |
| 17 | fi |
| 18 | } |
| 19 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 20 | function neutron_plugin_install_agent_packages() { |
| 21 | _neutron_ovs_base_install_agent_packages |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 22 | } |
| 23 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 24 | function neutron_plugin_configure_debug_command() { |
| 25 | _neutron_ovs_base_configure_debug_command |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 26 | } |
| 27 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 28 | function neutron_plugin_configure_dhcp_agent() { |
| 29 | 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] | 30 | } |
| 31 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 32 | function 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 Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 35 | } |
| 36 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 37 | function neutron_plugin_configure_plugin_agent() { |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 38 | # Setup integration bridge |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 39 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE |
| 40 | _neutron_ovs_base_configure_firewall_driver |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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 Mestery | 51a3f1f | 2013-06-13 11:47:56 +0000 | [diff] [blame] | 46 | 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 Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 48 | die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts." |
| 49 | fi |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 50 | iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True |
| 51 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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 |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 64 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 65 | fi |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 66 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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: |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 73 | 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] | 74 | |
| 75 | # For now, duplicate the xen configuration already found in nova.conf |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 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" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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. |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 83 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 84 | |
| 85 | # Set "physical" mapping |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 86 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 87 | |
| 88 | # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0 |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 89 | iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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" |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 99 | 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] | 100 | # Set integration bridge to domU's |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 101 | iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 102 | # Set root wrap |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 103 | iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 104 | fi |
Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 105 | # 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 Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 110 | iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ } |
Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 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 |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 117 | iniset /$Q_PLUGIN_CONF_FILE ovs ${I/=/ } |
Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 118 | done |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 119 | } |
| 120 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 121 | function neutron_plugin_setup_interface_driver() { |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 122 | local conf_file=$1 |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 123 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 124 | } |
| 125 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame^] | 126 | function neutron_plugin_check_adv_test_requirements() { |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 127 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
| 128 | } |
| 129 | |
| 130 | # Restore xtrace |
| 131 | $PLUGIN_XTRACE |