blob: 0483ef1fac41a02d6e54c812bc547ba6b5d35bda [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mark McClainb05c8762013-07-06 23:29:39 -04003# Neutron Modular Layer 2 plugin
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04004# ------------------------------
5
6# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +11007_XTRACE_NEUTRON_ML2=$(set +o | grep xtrace)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04008set +o xtrace
9
Kyle Mesteryb7726592013-07-19 14:26:53 +000010# Enable this to simply and quickly enable tunneling with ML2.
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090011# Select either 'gre', 'vxlan', or 'gre,vxlan'
Attila Fazekas8feaf6c2014-07-27 20:47:04 +020012Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-"vxlan"}
Kyle Mesteryb7726592013-07-19 14:26:53 +000013# This has to be set here since the agent will set this in the config file
Kevin Bentone3cfbf12014-08-04 11:25:20 -060014if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "gre" || "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090015 Q_TUNNEL_TYPES=$Q_ML2_TENANT_NETWORK_TYPE
Kyle Mesterybd085502014-04-30 23:50:29 +000016elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090017 Q_TUNNEL_TYPES=gre
Kyle Mesteryb7726592013-07-19 14:26:53 +000018fi
19
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040020# Default openvswitch L2 agent
21Q_AGENT=${Q_AGENT:-openvswitch}
Hirofumi Ichihara22cf6482015-07-23 18:13:55 +090022if [ -f $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent ]; then
23 source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent
24fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040025
Kyle Mesteryb7726592013-07-19 14:26:53 +000026# List of MechanismDrivers to load
Kyle Mesterybc632472013-09-06 14:59:30 +000027Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-openvswitch,linuxbridge}
Kyle Mesteryb7726592013-07-19 14:26:53 +000028# List of Type Drivers to load
29Q_ML2_PLUGIN_TYPE_DRIVERS=${Q_ML2_PLUGIN_TYPE_DRIVERS:-local,flat,vlan,gre,vxlan}
30# Default GRE TypeDriver options
31Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES}
32# Default VXLAN TypeDriver options
33Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=1001:2000}
34# Default VLAN TypeDriver options
35Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
Yalei Wanga48e5dc2015-03-06 17:05:11 +080036# List of extension drivers to load, use '-' instead of ':-' to allow people to
37# explicitly override this to blank
38Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS-port_security}
Kyle Mesteryb7726592013-07-19 14:26:53 +000039
Kyle Mestery14ea1a22013-09-22 03:04:56 +000040# L3 Plugin to load for ML2
41ML2_L3_PLUGIN=${ML2_L3_PLUGIN:-neutron.services.l3_router.l3_router_plugin.L3RouterPlugin}
42
Ihar Hrachyshka06cfce32016-01-14 15:31:31 +010043# Underlying path MTU for physical network managing br-tun; use '-' instead of
44# ':-' to allow people to explicitly override this to blank, to disable
45# automatic MTU calculation for tunnelled tenant networks
46Q_ML2_PLUGIN_PATH_MTU=${Q_ML2_PLUGIN_PATH_MTU-1500}
47
48
Ian Wienandaee18c72014-02-21 15:35:08 +110049function populate_ml2_config {
Akihiro Motoki130c90e2013-11-28 16:56:51 +090050 CONF=$1
51 SECTION=$2
52 OPTS=$3
Kyle Mesteryb7726592013-07-19 14:26:53 +000053
Akihiro Motoki130c90e2013-11-28 16:56:51 +090054 if [ -z "$OPTS" ]; then
55 return
56 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000057 for I in "${OPTS[@]}"; do
58 # Replace the first '=' with ' ' for iniset syntax
59 iniset $CONF $SECTION ${I/=/ }
60 done
61}
62
Ian Wienandaee18c72014-02-21 15:35:08 +110063function neutron_plugin_configure_common {
Mark McClainb05c8762013-07-06 23:29:39 -040064 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040065 Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
Mark McClainb05c8762013-07-06 23:29:39 -040066 Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin"
Bob Melander748fe3d2013-01-31 17:12:56 +010067 # The ML2 plugin delegates L3 routing/NAT functionality to
68 # the L3 service plugin which must therefore be specified.
Isaku Yamahata9e136b42013-12-16 15:52:03 +090069 _neutron_service_plugin_class_add $ML2_L3_PLUGIN
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040070}
71
Ian Wienandaee18c72014-02-21 15:35:08 +110072function neutron_plugin_configure_service {
Attila Fazekas8feaf6c2014-07-27 20:47:04 +020073 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "local" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000074 Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
Kyle Mesterybd085502014-04-30 23:50:29 +000075 elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000076 # This assumes you want a simple configuration, and will overwrite
77 # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
Kyle Mestery061d5252013-09-09 08:52:19 +000078 Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre)
Kyle Mesteryb7726592013-07-19 14:26:53 +000079 Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
Kyle Mesterybd085502014-04-30 23:50:29 +000080 elif [[ "$ENABLE_TENANT_VLANS" == "True" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000081 Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040082 else
83 echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
84 fi
85
Ihar Hrachyshka06cfce32016-01-14 15:31:31 +010086 # Enable ml2 mtu calculation mechanism for networks by providing path mtu
87 # value for physical devices that are used for br-tun traffic
88 if [[ "$ENABLE_TENANT_TUNNELS" == "True" ]] && [[ "$Q_ML2_PLUGIN_PATH_MTU" != "" ]]; then
89 iniset /$Q_PLUGIN_CONF_FILE ml2 path_mtu "$Q_ML2_PLUGIN_PATH_MTU"
90 fi
91
Kyle Mesteryb7726592013-07-19 14:26:53 +000092 # Allow for overrding VLAN configuration (for example, to configure provider
93 # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set.
94 if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then
Kyle Mesterybd085502014-04-30 23:50:29 +000095 if [[ "$ML2_VLAN_RANGES" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000096 ML2_VLAN_RANGES=$PHYSICAL_NETWORK
97 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
98 ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
99 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400100 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +0000101 if [[ "$ML2_VLAN_RANGES" != "" ]]; then
102 Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES)
103 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400104 fi
105
yunhong jiang73d32162014-10-06 09:34:35 -0700106
107 # Allow for setup the flat type network
108 if [[ -z "$Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS" && -n "$PHYSICAL_NETWORK" ]]; then
Ramakrishnan G8f5fe872015-04-17 12:48:39 +0000109 Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS="flat_networks=$PHYSICAL_NETWORK"
yunhong jiang73d32162014-10-06 09:34:35 -0700110 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400111 # REVISIT(rkukura): Setting firewall_driver here for
Mark McClainb05c8762013-07-06 23:29:39 -0400112 # neutron.agent.securitygroups_rpc.is_firewall_enabled() which is
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400113 # used in the server, in case no L2 agent is configured on the
114 # server's node. If an L2 agent is configured, this will get
115 # overridden with the correct driver. The ml2 plugin should
116 # instead use its own config variable to indicate whether security
117 # groups is enabled, and that will need to be set here instead.
118 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
Akihiro Motoki4074e292014-02-14 00:54:58 +0900119 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.not.a.real.FirewallDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400120 else
Akihiro Motoki4074e292014-02-14 00:54:58 +0900121 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400122 fi
123
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900124 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS
Kyle Mestery3ea28ec2013-08-05 12:24:32 +0000125
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900126 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000127
Yalei Wanga48e5dc2015-03-06 17:05:11 +0800128 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 extension_drivers=$Q_ML2_PLUGIN_EXT_DRIVERS
129
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900130 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000131
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900132 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000133
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900134 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000135
yunhong jiang73d32162014-10-06 09:34:35 -0700136 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_flat $Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS
137
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900138 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS
Brian Haleyeea76212014-06-27 11:45:50 -0400139
140 if [[ "$Q_DVR_MODE" != "legacy" ]]; then
141 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent l2_population=True
142 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent tunnel_types=vxlan
143 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent enable_distributed_routing=True
144 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400145}
146
Ian Wienandaee18c72014-02-21 15:35:08 +1100147function has_neutron_plugin_security_group {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400148 return 0
149}
150
151# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100152$_XTRACE_NEUTRON_ML2