2014-12-05 14:25:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2013-07-06 23:29:39 -04:00
|
|
|
# Neutron Modular Layer 2 plugin
|
2013-04-23 16:28:24 -04:00
|
|
|
# ------------------------------
|
|
|
|
|
|
|
|
# Save trace setting
|
2015-10-13 11:03:03 +11:00
|
|
|
_XTRACE_NEUTRON_ML2=$(set +o | grep xtrace)
|
2013-04-23 16:28:24 -04:00
|
|
|
set +o xtrace
|
|
|
|
|
2021-05-14 09:14:24 +01:00
|
|
|
# Default OVN L2 agent
|
|
|
|
Q_AGENT=${Q_AGENT:-ovn}
|
2020-06-09 14:35:52 +01:00
|
|
|
if [ -f $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent ]; then
|
|
|
|
source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent
|
|
|
|
fi
|
|
|
|
|
2013-07-19 14:26:53 +00:00
|
|
|
# Enable this to simply and quickly enable tunneling with ML2.
|
2021-05-14 09:14:24 +01:00
|
|
|
# For ML2/OVS select either 'gre', 'vxlan', or 'gre,vxlan'.
|
|
|
|
# For ML2/OVN use 'geneve'.
|
|
|
|
Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-"geneve"}
|
2013-07-19 14:26:53 +00:00
|
|
|
# This has to be set here since the agent will set this in the config file
|
2014-08-04 11:25:20 -06:00
|
|
|
if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "gre" || "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then
|
2014-08-09 18:58:20 +09:00
|
|
|
Q_TUNNEL_TYPES=$Q_ML2_TENANT_NETWORK_TYPE
|
2014-04-30 23:50:29 +00:00
|
|
|
elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
|
2014-08-09 18:58:20 +09:00
|
|
|
Q_TUNNEL_TYPES=gre
|
2013-07-19 14:26:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# List of MechanismDrivers to load
|
2021-05-14 09:14:24 +01:00
|
|
|
Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-ovn}
|
2013-07-19 14:26:53 +00:00
|
|
|
# Default GRE TypeDriver options
|
|
|
|
Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES}
|
|
|
|
# Default VXLAN TypeDriver options
|
2016-06-08 10:28:37 -05:00
|
|
|
Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES}
|
2013-07-19 14:26:53 +00:00
|
|
|
# Default VLAN TypeDriver options
|
|
|
|
Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
|
2016-06-08 10:28:37 -05:00
|
|
|
# Default GENEVE TypeDriver options
|
|
|
|
Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES}
|
2015-03-06 17:05:11 +08:00
|
|
|
# List of extension drivers to load, use '-' instead of ':-' to allow people to
|
|
|
|
# explicitly override this to blank
|
2016-09-15 20:33:22 -04:00
|
|
|
if [[ "$NEUTRON_PORT_SECURITY" = "True" ]]; then
|
|
|
|
Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS-port_security}
|
|
|
|
else
|
|
|
|
Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS:-}
|
|
|
|
fi
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2013-09-22 03:04:56 +00:00
|
|
|
# L3 Plugin to load for ML2
|
2016-06-08 14:18:10 +09:00
|
|
|
# For some flat network environment, they not want to extend L3 plugin.
|
|
|
|
# Make sure it is able to set empty to ML2_L3_PLUGIN.
|
2019-03-21 11:40:17 -04:00
|
|
|
ML2_L3_PLUGIN=${ML2_L3_PLUGIN-router}
|
2013-09-22 03:04:56 +00:00
|
|
|
|
2014-02-21 15:35:08 +11:00
|
|
|
function populate_ml2_config {
|
2013-11-28 16:56:51 +09:00
|
|
|
CONF=$1
|
|
|
|
SECTION=$2
|
|
|
|
OPTS=$3
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
if [ -z "$OPTS" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2013-07-19 14:26:53 +00:00
|
|
|
for I in "${OPTS[@]}"; do
|
|
|
|
# Replace the first '=' with ' ' for iniset syntax
|
|
|
|
iniset $CONF $SECTION ${I/=/ }
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-02-21 15:35:08 +11:00
|
|
|
function neutron_plugin_configure_common {
|
2013-07-06 23:29:39 -04:00
|
|
|
Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
|
2013-04-23 16:28:24 -04:00
|
|
|
Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
|
2016-11-30 14:27:36 -05:00
|
|
|
Q_PLUGIN_CLASS="ml2"
|
2013-01-31 17:12:56 +01:00
|
|
|
# The ML2 plugin delegates L3 routing/NAT functionality to
|
|
|
|
# the L3 service plugin which must therefore be specified.
|
2013-12-16 15:52:03 +09:00
|
|
|
_neutron_service_plugin_class_add $ML2_L3_PLUGIN
|
2013-04-23 16:28:24 -04:00
|
|
|
}
|
|
|
|
|
2014-02-21 15:35:08 +11:00
|
|
|
function neutron_plugin_configure_service {
|
2014-07-27 20:47:04 +02:00
|
|
|
if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "local" ]]; then
|
2013-09-09 08:52:19 +00:00
|
|
|
Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
|
2014-04-30 23:50:29 +00:00
|
|
|
elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
|
2013-07-19 14:26:53 +00:00
|
|
|
# This assumes you want a simple configuration, and will overwrite
|
|
|
|
# Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
|
2013-09-09 08:52:19 +00:00
|
|
|
Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre)
|
2013-07-19 14:26:53 +00:00
|
|
|
Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
|
2014-04-30 23:50:29 +00:00
|
|
|
elif [[ "$ENABLE_TENANT_VLANS" == "True" ]]; then
|
2013-09-09 08:52:19 +00:00
|
|
|
Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan)
|
2013-04-23 16:28:24 -04:00
|
|
|
else
|
|
|
|
echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
|
|
|
|
fi
|
|
|
|
|
2013-07-19 14:26:53 +00:00
|
|
|
# Allow for overrding VLAN configuration (for example, to configure provider
|
|
|
|
# VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set.
|
|
|
|
if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then
|
2014-04-30 23:50:29 +00:00
|
|
|
if [[ "$ML2_VLAN_RANGES" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
|
2013-07-19 14:26:53 +00:00
|
|
|
ML2_VLAN_RANGES=$PHYSICAL_NETWORK
|
|
|
|
if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
|
|
|
|
ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ "$ML2_VLAN_RANGES" != "" ]]; then
|
|
|
|
Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES)
|
2013-04-23 16:28:24 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-10-06 09:34:35 -07:00
|
|
|
|
|
|
|
# Allow for setup the flat type network
|
2016-07-21 11:11:54 -07:00
|
|
|
if [[ -z "$Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS" ]]; then
|
|
|
|
if [[ -n "$PHYSICAL_NETWORK" || -n "$PUBLIC_PHYSICAL_NETWORK" ]]; then
|
|
|
|
Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS="flat_networks="
|
|
|
|
if [[ -n "$PHYSICAL_NETWORK" ]]; then
|
|
|
|
Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PHYSICAL_NETWORK},"
|
|
|
|
fi
|
2017-01-05 12:32:57 +05:30
|
|
|
if [[ -n "$PUBLIC_PHYSICAL_NETWORK" ]] && [[ "${PHYSICAL_NETWORK}" != "$PUBLIC_PHYSICAL_NETWORK" ]]; then
|
2016-07-21 11:11:54 -07:00
|
|
|
Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PUBLIC_PHYSICAL_NETWORK},"
|
|
|
|
fi
|
|
|
|
fi
|
2014-10-06 09:34:35 -07:00
|
|
|
fi
|
2013-04-23 16:28:24 -04:00
|
|
|
# REVISIT(rkukura): Setting firewall_driver here for
|
2013-07-06 23:29:39 -04:00
|
|
|
# neutron.agent.securitygroups_rpc.is_firewall_enabled() which is
|
2013-04-23 16:28:24 -04:00
|
|
|
# used in the server, in case no L2 agent is configured on the
|
|
|
|
# server's node. If an L2 agent is configured, this will get
|
|
|
|
# overridden with the correct driver. The ml2 plugin should
|
|
|
|
# instead use its own config variable to indicate whether security
|
|
|
|
# groups is enabled, and that will need to be set here instead.
|
|
|
|
if [[ "$Q_USE_SECGROUP" == "True" ]]; then
|
2014-02-14 00:54:58 +09:00
|
|
|
iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.not.a.real.FirewallDriver
|
2013-04-23 16:28:24 -04:00
|
|
|
else
|
2014-02-14 00:54:58 +09:00
|
|
|
iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
|
2013-04-23 16:28:24 -04:00
|
|
|
fi
|
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS
|
2013-08-05 12:24:32 +00:00
|
|
|
|
2016-06-08 10:28:37 -05:00
|
|
|
if [[ -n "$Q_ML2_PLUGIN_TYPE_DRIVERS" ]]; then
|
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS
|
|
|
|
fi
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2015-03-06 17:05:11 +08:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 extension_drivers=$Q_ML2_PLUGIN_EXT_DRIVERS
|
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS
|
2013-07-19 14:26:53 +00:00
|
|
|
|
2014-10-06 09:34:35 -07:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_flat $Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS
|
|
|
|
|
2013-11-28 16:56:51 +09:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS
|
2014-06-27 11:45:50 -04:00
|
|
|
|
2016-06-08 10:28:37 -05:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_geneve $Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS
|
|
|
|
|
2014-06-27 11:45:50 -04:00
|
|
|
if [[ "$Q_DVR_MODE" != "legacy" ]]; then
|
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE agent l2_population=True
|
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE agent tunnel_types=vxlan
|
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE agent enable_distributed_routing=True
|
2019-05-02 13:45:46 -07:00
|
|
|
populate_ml2_config /$Q_PLUGIN_CONF_FILE agent arp_responder=True
|
2014-06-27 11:45:50 -04:00
|
|
|
fi
|
2013-04-23 16:28:24 -04:00
|
|
|
}
|
|
|
|
|
2014-02-21 15:35:08 +11:00
|
|
|
function has_neutron_plugin_security_group {
|
2013-04-23 16:28:24 -04:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-11-18 10:36:57 +01:00
|
|
|
function configure_qos_ml2 {
|
|
|
|
neutron_ml2_extension_driver_add "qos"
|
|
|
|
}
|
|
|
|
|
2013-04-23 16:28:24 -04:00
|
|
|
# Restore xtrace
|
2015-10-13 11:03:03 +11:00
|
|
|
$_XTRACE_NEUTRON_ML2
|