blob: c2e78c65cc7559e9b359c26144aab5ca3d29e29b [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
Lucas Alvares Gomese38a39a2021-05-14 09:14:24 +010010# Default OVN L2 agent
11Q_AGENT=${Q_AGENT:-ovn}
Lucas Alvares Gomes1d468d42020-06-09 14:35:52 +010012if [ -f $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent ]; then
13 source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent
14fi
15
Kyle Mesteryb7726592013-07-19 14:26:53 +000016# Enable this to simply and quickly enable tunneling with ML2.
Lucas Alvares Gomese38a39a2021-05-14 09:14:24 +010017# For ML2/OVS select either 'gre', 'vxlan', or 'gre,vxlan'.
18# For ML2/OVN use 'geneve'.
19Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-"geneve"}
Kyle Mesteryb7726592013-07-19 14:26:53 +000020# This has to be set here since the agent will set this in the config file
Kevin Bentone3cfbf12014-08-04 11:25:20 -060021if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "gre" || "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090022 Q_TUNNEL_TYPES=$Q_ML2_TENANT_NETWORK_TYPE
Kyle Mesterybd085502014-04-30 23:50:29 +000023elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090024 Q_TUNNEL_TYPES=gre
Kyle Mesteryb7726592013-07-19 14:26:53 +000025fi
26
Kyle Mesteryb7726592013-07-19 14:26:53 +000027# List of MechanismDrivers to load
Lucas Alvares Gomese38a39a2021-05-14 09:14:24 +010028Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-ovn}
Kyle Mesteryb7726592013-07-19 14:26:53 +000029# Default GRE TypeDriver options
30Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES}
31# Default VXLAN TypeDriver options
Richard Theis8906b482016-06-08 10:28:37 -050032Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES}
Kyle Mesteryb7726592013-07-19 14:26:53 +000033# Default VLAN TypeDriver options
34Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
Richard Theis8906b482016-06-08 10:28:37 -050035# Default GENEVE TypeDriver options
36Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES}
Yalei Wanga48e5dc2015-03-06 17:05:11 +080037# List of extension drivers to load, use '-' instead of ':-' to allow people to
38# explicitly override this to blank
Matt Riedemannc9c9d312016-09-15 20:33:22 -040039if [[ "$NEUTRON_PORT_SECURITY" = "True" ]]; then
40 Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS-port_security}
41else
42 Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS:-}
43fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000044
Kyle Mestery14ea1a22013-09-22 03:04:56 +000045# L3 Plugin to load for ML2
watanabe.isao1c4c16c2016-06-08 14:18:10 +090046# For some flat network environment, they not want to extend L3 plugin.
47# Make sure it is able to set empty to ML2_L3_PLUGIN.
Brian Haley245445b2019-03-21 11:40:17 -040048ML2_L3_PLUGIN=${ML2_L3_PLUGIN-router}
Kyle Mestery14ea1a22013-09-22 03:04:56 +000049
Ian Wienandaee18c72014-02-21 15:35:08 +110050function populate_ml2_config {
Akihiro Motoki130c90e2013-11-28 16:56:51 +090051 CONF=$1
52 SECTION=$2
53 OPTS=$3
Kyle Mesteryb7726592013-07-19 14:26:53 +000054
Akihiro Motoki130c90e2013-11-28 16:56:51 +090055 if [ -z "$OPTS" ]; then
56 return
57 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000058 for I in "${OPTS[@]}"; do
59 # Replace the first '=' with ' ' for iniset syntax
60 iniset $CONF $SECTION ${I/=/ }
61 done
62}
63
Ian Wienandaee18c72014-02-21 15:35:08 +110064function neutron_plugin_configure_common {
Mark McClainb05c8762013-07-06 23:29:39 -040065 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040066 Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
Sean M. Collins50bf4fc2016-11-30 14:27:36 -050067 Q_PLUGIN_CLASS="ml2"
Bob Melander748fe3d2013-01-31 17:12:56 +010068 # The ML2 plugin delegates L3 routing/NAT functionality to
69 # the L3 service plugin which must therefore be specified.
Slawek Kaplonskia52041c2022-11-18 11:39:56 +010070 neutron_service_plugin_class_add $ML2_L3_PLUGIN
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040071}
72
Ian Wienandaee18c72014-02-21 15:35:08 +110073function neutron_plugin_configure_service {
Attila Fazekas8feaf6c2014-07-27 20:47:04 +020074 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "local" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000075 Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
Kyle Mesterybd085502014-04-30 23:50:29 +000076 elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000077 # This assumes you want a simple configuration, and will overwrite
78 # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
Kyle Mestery061d5252013-09-09 08:52:19 +000079 Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre)
Kyle Mesteryb7726592013-07-19 14:26:53 +000080 Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
Kyle Mesterybd085502014-04-30 23:50:29 +000081 elif [[ "$ENABLE_TENANT_VLANS" == "True" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000082 Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040083 else
84 echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
85 fi
86
Kyle Mesteryb7726592013-07-19 14:26:53 +000087 # Allow for overrding VLAN configuration (for example, to configure provider
88 # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set.
89 if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then
Kyle Mesterybd085502014-04-30 23:50:29 +000090 if [[ "$ML2_VLAN_RANGES" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000091 ML2_VLAN_RANGES=$PHYSICAL_NETWORK
92 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
93 ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
94 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040095 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000096 if [[ "$ML2_VLAN_RANGES" != "" ]]; then
97 Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES)
98 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040099 fi
100
yunhong jiang73d32162014-10-06 09:34:35 -0700101
102 # Allow for setup the flat type network
Kevin Benton6a42a852016-07-21 11:11:54 -0700103 if [[ -z "$Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS" ]]; then
104 if [[ -n "$PHYSICAL_NETWORK" || -n "$PUBLIC_PHYSICAL_NETWORK" ]]; then
105 Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS="flat_networks="
106 if [[ -n "$PHYSICAL_NETWORK" ]]; then
107 Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PHYSICAL_NETWORK},"
108 fi
yatin0f978412017-01-05 12:32:57 +0530109 if [[ -n "$PUBLIC_PHYSICAL_NETWORK" ]] && [[ "${PHYSICAL_NETWORK}" != "$PUBLIC_PHYSICAL_NETWORK" ]]; then
Kevin Benton6a42a852016-07-21 11:11:54 -0700110 Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PUBLIC_PHYSICAL_NETWORK},"
111 fi
112 fi
yunhong jiang73d32162014-10-06 09:34:35 -0700113 fi
Slawek Kaplonski30acfc62022-11-24 14:12:08 +0100114 populate_ml2_config /$Q_PLUGIN_CONF_FILE securitygroup enable_security_group=$Q_USE_SECGROUP
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400115
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900116 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS
Takashi Kajinamicf0bf742022-07-13 22:34:47 +0900117 if [[ "$Q_ML2_PLUGIN_MECHANISM_DRIVERS" == *"linuxbridge"* ]]; then
118 iniset $NEUTRON_CONF experimental linuxbridge True
119 fi
Brian Haleyc869d592020-02-28 14:55:08 -0500120 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 overlay_ip_version=$TUNNEL_IP_VERSION
Kyle Mestery3ea28ec2013-08-05 12:24:32 +0000121
Richard Theis8906b482016-06-08 10:28:37 -0500122 if [[ -n "$Q_ML2_PLUGIN_TYPE_DRIVERS" ]]; then
123 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS
124 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +0000125
Yalei Wanga48e5dc2015-03-06 17:05:11 +0800126 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 extension_drivers=$Q_ML2_PLUGIN_EXT_DRIVERS
127
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900128 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000129
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900130 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS
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_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000133
yunhong jiang73d32162014-10-06 09:34:35 -0700134 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_flat $Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS
135
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900136 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS
Brian Haleyeea76212014-06-27 11:45:50 -0400137
Richard Theis8906b482016-06-08 10:28:37 -0500138 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_geneve $Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS
139
Brian Haleyeea76212014-06-27 11:45:50 -0400140 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
Swaminathan Vasudevan9bf7e262019-05-02 13:45:46 -0700144 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent arp_responder=True
Brian Haleyeea76212014-06-27 11:45:50 -0400145 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400146}
147
Ian Wienandaee18c72014-02-21 15:35:08 +1100148function has_neutron_plugin_security_group {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400149 return 0
150}
151
Slawek Kaplonskifaed11d2021-11-18 10:36:57 +0100152function configure_qos_ml2 {
153 neutron_ml2_extension_driver_add "qos"
154}
155
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400156# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100157$_XTRACE_NEUTRON_ML2