blob: acab582212ae346af0962c8c5552520cc5ae7da5 [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
Ian Wienand523f4882015-10-13 11:03:03 +11007_XTRACE_NEUTRON_OVSL2=$(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_dhcp_agent {
Sean M. Collins2a242512016-05-03 09:03:09 -040027 local conf_file=$1
Armando Migliaccio14b12a72016-08-12 19:07:12 -070028 :
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040029}
30
Ian Wienandaee18c72014-02-21 15:35:08 +110031function neutron_plugin_configure_l3_agent {
Sean M. Collins2a242512016-05-03 09:03:09 -040032 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -040033 _neutron_ovs_base_configure_l3_agent
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040034}
35
Ian Wienandaee18c72014-02-21 15:35:08 +110036function neutron_plugin_configure_plugin_agent {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040037 # Setup integration bridge
Mark McClainb05c8762013-07-06 23:29:39 -040038 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
39 _neutron_ovs_base_configure_firewall_driver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040040
41 # Setup agent for tunneling
Kyle Mesterybd085502014-04-30 23:50:29 +000042 if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then
Edgar Magana6f335b92014-07-10 15:42:44 -070043 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP
Hirofumi Ichiharad48d6722015-07-04 22:58:44 +090044 iniset /$Q_PLUGIN_CONF_FILE ovs tunnel_bridge $OVS_TUNNEL_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040045 fi
46
47 # Setup physical network bridge mappings. Override
48 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
49 # complex physical network configurations.
Kyle Mesterybd085502014-04-30 23:50:29 +000050 if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040051 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
52
Sean M. Collins54d16f72016-03-15 15:18:14 -040053 # Configure bridge manually with physical interface as port for multi-node
54 _neutron_ovs_base_add_bridge $OVS_PHYSICAL_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040055 fi
56 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
Gary Kottond42634f2013-06-24 09:26:55 +000057 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040058 fi
Mark McClainb05c8762013-07-06 23:29:39 -040059 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-openvswitch-agent"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040060
Kyle Mesterybd085502014-04-30 23:50:29 +000061 if [ "$VIRT_DRIVER" == 'xenserver' ]; then
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040062 # Make a copy of our config for domU
Mate Lakat1a247e82014-08-05 14:32:51 +010063 sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domU"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040064
Huan Xie201e3c12015-08-27 12:34:24 +010065 # change domU's config file to STACK_USER
66 sudo chown $STACK_USER:$STACK_USER /$Q_PLUGIN_CONF_FILE.domU
67
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040068 # Deal with Dom0's L2 Agent:
Mark McClainb05c8762013-07-06 23:29:39 -040069 Q_RR_DOM0_COMMAND="$NEUTRON_BIN_DIR/neutron-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040070
71 # For now, duplicate the xen configuration already found in nova.conf
Gary Kottond42634f2013-06-24 09:26:55 +000072 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_url "$XENAPI_CONNECTION_URL"
73 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_username "$XENAPI_USER"
74 iniset $Q_RR_CONF_FILE xenapi xenapi_connection_password "$XENAPI_PASSWORD"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040075
76 # Under XS/XCP, the ovs agent needs to target the dom0
77 # integration bridge. This is enabled by using a root wrapper
78 # that executes commands on dom0 via a XenAPI plugin.
Huan Xie201e3c12015-08-27 12:34:24 +010079 # XenAPI does not support daemon rootwrap now, so set root_helper_daemon empty
Jianghua Wang465ee452016-11-08 17:49:45 +080080 iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper ""
81 iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper_daemon "xenapi_root_helper"
82 iniset "/$Q_PLUGIN_CONF_FILE.domU" xenapi connection_url "$XENAPI_CONNECTION_URL"
83 iniset "/$Q_PLUGIN_CONF_FILE.domU" xenapi connection_username "$XENAPI_USER"
84 iniset "/$Q_PLUGIN_CONF_FILE.domU" xenapi connection_password "$XENAPI_PASSWORD"
Huan Xie201e3c12015-08-27 12:34:24 +010085
86 # Disable minimize polling, so that it can always detect OVS and Port changes
87 # This is a problem of xenserver + neutron, bug has been reported
88 # https://bugs.launchpad.net/neutron/+bug/1495423
Jianghua Wangcaa822f2016-11-11 18:23:17 +080089 iniset "/$Q_PLUGIN_CONF_FILE.domU" agent minimize_polling False
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040090
91 # Set "physical" mapping
Jianghua Wangcaa822f2016-11-11 18:23:17 +080092 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040093
94 # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
Jianghua Wangcaa822f2016-11-11 18:23:17 +080095 iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $XEN_INTEGRATION_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040096
Huan Xie28641502016-09-20 06:49:50 +000097 # Set OVS native interface for ovs-agent in compute node
98 XEN_DOM0_IP=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3)
Huan Xiedf875c52016-11-30 19:47:24 -080099 iniset /$Q_PLUGIN_CONF_FILE.domU ovs ovsdb_connection tcp:$XEN_DOM0_IP:6640
100 iniset /$Q_PLUGIN_CONF_FILE.domU ovs of_listen_address $HOST_IP
Huan Xie28641502016-09-20 06:49:50 +0000101
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400102 # Set up domU's L2 agent:
103
Huan Xie2f5596e2016-04-05 22:22:48 -0700104 # Create a bridge "br-$VLAN_INTERFACE"
105 _neutron_ovs_base_add_bridge "br-$VLAN_INTERFACE"
106 # Add $VLAN_INTERFACE to that bridge
107 sudo ovs-vsctl -- --may-exist add-port "br-$VLAN_INTERFACE" $VLAN_INTERFACE
Huan Xie201e3c12015-08-27 12:34:24 +0100108
109 # Create external bridge and add port
Ihar Hrachyshka7b5c7dc2016-07-15 20:17:13 +0200110 _neutron_ovs_base_add_public_bridge
Huan Xie2f5596e2016-04-05 22:22:48 -0700111 sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $PUBLIC_INTERFACE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400112
113 # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
Jianghua Wangcaa822f2016-11-11 18:23:17 +0800114 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:br-$VLAN_INTERFACE,physnet-ex:$PUBLIC_BRIDGE"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400115 # Set integration bridge to domU's
Jianghua Wangcaa822f2016-11-11 18:23:17 +0800116 iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $OVS_BRIDGE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400117 # Set root wrap
Jianghua Wangcaa822f2016-11-11 18:23:17 +0800118 iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND"
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400119 fi
Akihiro Motoki2307f9d2014-08-09 18:58:20 +0900120 iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES
Michal Ptacekc1605552015-09-23 21:02:02 +0100121 iniset /$Q_PLUGIN_CONF_FILE ovs datapath_type $OVS_DATAPATH_TYPE
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400122}
123
Ian Wienandaee18c72014-02-21 15:35:08 +1100124function neutron_plugin_setup_interface_driver {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400125 local conf_file=$1
Martin Hickeydca49de2015-10-20 12:13:19 +0100126 iniset $conf_file DEFAULT interface_driver openvswitch
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400127}
128
Ian Wienandaee18c72014-02-21 15:35:08 +1100129function neutron_plugin_check_adv_test_requirements {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400130 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
131}
132
133# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100134$_XTRACE_NEUTRON_OVSL2