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 |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 7 | _XTRACE_NEUTRON_OVSL2=$(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 { |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 31 | local conf_file=$1 |
| 32 | iniset $conf_file DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 33 | } |
| 34 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 35 | function neutron_plugin_configure_l3_agent { |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 36 | local conf_file=$1 |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 37 | _neutron_ovs_base_configure_l3_agent |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 38 | iniset $conf_file DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 39 | } |
| 40 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 41 | function neutron_plugin_configure_plugin_agent { |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 42 | # Setup integration bridge |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 43 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE |
| 44 | _neutron_ovs_base_configure_firewall_driver |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 45 | |
| 46 | # Setup agent for tunneling |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 47 | if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then |
Edgar Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 48 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP |
Hirofumi Ichihara | d48d672 | 2015-07-04 22:58:44 +0900 | [diff] [blame] | 49 | iniset /$Q_PLUGIN_CONF_FILE ovs tunnel_bridge $OVS_TUNNEL_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 50 | fi |
| 51 | |
| 52 | # Setup physical network bridge mappings. Override |
| 53 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more |
| 54 | # complex physical network configurations. |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 55 | if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 56 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE |
| 57 | |
Sean M. Collins | 54d16f7 | 2016-03-15 15:18:14 -0400 | [diff] [blame] | 58 | # Configure bridge manually with physical interface as port for multi-node |
| 59 | _neutron_ovs_base_add_bridge $OVS_PHYSICAL_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 60 | fi |
| 61 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 62 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 63 | fi |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 64 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 65 | |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 66 | if [ "$VIRT_DRIVER" == 'xenserver' ]; then |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 67 | # Make a copy of our config for domU |
Mate Lakat | 1a247e8 | 2014-08-05 14:32:51 +0100 | [diff] [blame] | 68 | sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domU" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 69 | |
Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 70 | # change domU's config file to STACK_USER |
| 71 | sudo chown $STACK_USER:$STACK_USER /$Q_PLUGIN_CONF_FILE.domU |
| 72 | |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 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. |
Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 84 | # XenAPI does not support daemon rootwrap now, so set root_helper_daemon empty |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 85 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND" |
Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 86 | iniset /$Q_PLUGIN_CONF_FILE agent root_helper_daemon "" |
| 87 | |
| 88 | # Disable minimize polling, so that it can always detect OVS and Port changes |
| 89 | # This is a problem of xenserver + neutron, bug has been reported |
| 90 | # https://bugs.launchpad.net/neutron/+bug/1495423 |
| 91 | iniset /$Q_PLUGIN_CONF_FILE agent minimize_polling False |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 92 | |
| 93 | # Set "physical" mapping |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 94 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 95 | |
| 96 | # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0 |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 97 | iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 98 | |
| 99 | # Set up domU's L2 agent: |
| 100 | |
Huan Xie | 2f5596e | 2016-04-05 22:22:48 -0700 | [diff] [blame] | 101 | # Create a bridge "br-$VLAN_INTERFACE" |
| 102 | _neutron_ovs_base_add_bridge "br-$VLAN_INTERFACE" |
| 103 | # Add $VLAN_INTERFACE to that bridge |
| 104 | sudo ovs-vsctl -- --may-exist add-port "br-$VLAN_INTERFACE" $VLAN_INTERFACE |
Huan Xie | 201e3c1 | 2015-08-27 12:34:24 +0100 | [diff] [blame] | 105 | |
| 106 | # Create external bridge and add port |
| 107 | _neutron_ovs_base_add_bridge $PUBLIC_BRIDGE |
Huan Xie | 2f5596e | 2016-04-05 22:22:48 -0700 | [diff] [blame] | 108 | sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $PUBLIC_INTERFACE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 109 | |
| 110 | # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT" |
Huan Xie | 2f5596e | 2016-04-05 22:22:48 -0700 | [diff] [blame] | 111 | iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:br-$VLAN_INTERFACE,physnet-ex:$PUBLIC_BRIDGE" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 112 | # Set integration bridge to domU's |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 113 | iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 114 | # Set root wrap |
Gary Kotton | d42634f | 2013-06-24 09:26:55 +0000 | [diff] [blame] | 115 | iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND" |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 116 | fi |
Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 117 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES |
Michal Ptacek | c160555 | 2015-09-23 21:02:02 +0100 | [diff] [blame] | 118 | iniset /$Q_PLUGIN_CONF_FILE ovs datapath_type $OVS_DATAPATH_TYPE |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 119 | } |
| 120 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [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 |
Martin Hickey | dca49de | 2015-10-20 12:13:19 +0100 | [diff] [blame] | 123 | iniset $conf_file DEFAULT interface_driver openvswitch |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 124 | } |
| 125 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [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 |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 131 | $_XTRACE_NEUTRON_OVSL2 |