blob: 4cf484e7be67856c230b9c117caa04759d1a9959 [file] [log] [blame]
Mark McClainb05c8762013-07-06 23:29:39 -04001# Neutron Modular Layer 2 plugin
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04002# ------------------------------
3
4# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05005ML2_XTRACE=$(set +o | grep xtrace)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -04006set +o xtrace
7
Kyle Mesteryb7726592013-07-19 14:26:53 +00008# Enable this to simply and quickly enable tunneling with ML2.
9# Select either 'gre', 'vxlan', or '(gre vxlan)'
10Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-}
11# This has to be set here since the agent will set this in the config file
12if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000013 Q_AGENT_EXTRA_AGENT_OPTS+=(tunnel_types=$Q_ML2_TENANT_NETWORK_TYPE)
Kyle Mesterybd085502014-04-30 23:50:29 +000014elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000015 Q_AGENT_EXTRA_AGENT_OPTS+=(tunnel_types=gre)
Kyle Mesteryb7726592013-07-19 14:26:53 +000016fi
17
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040018# Default openvswitch L2 agent
19Q_AGENT=${Q_AGENT:-openvswitch}
Mark McClainb05c8762013-07-06 23:29:39 -040020source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040021
Kyle Mesteryb7726592013-07-19 14:26:53 +000022# List of MechanismDrivers to load
Kyle Mesterybc632472013-09-06 14:59:30 +000023Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-openvswitch,linuxbridge}
Kyle Mesteryb7726592013-07-19 14:26:53 +000024# List of Type Drivers to load
25Q_ML2_PLUGIN_TYPE_DRIVERS=${Q_ML2_PLUGIN_TYPE_DRIVERS:-local,flat,vlan,gre,vxlan}
26# Default GRE TypeDriver options
27Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES}
28# Default VXLAN TypeDriver options
29Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=1001:2000}
30# Default VLAN TypeDriver options
31Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-}
32
Kyle Mestery14ea1a22013-09-22 03:04:56 +000033# L3 Plugin to load for ML2
34ML2_L3_PLUGIN=${ML2_L3_PLUGIN:-neutron.services.l3_router.l3_router_plugin.L3RouterPlugin}
35
Ian Wienandaee18c72014-02-21 15:35:08 +110036function populate_ml2_config {
Akihiro Motoki130c90e2013-11-28 16:56:51 +090037 CONF=$1
38 SECTION=$2
39 OPTS=$3
Kyle Mesteryb7726592013-07-19 14:26:53 +000040
Akihiro Motoki130c90e2013-11-28 16:56:51 +090041 if [ -z "$OPTS" ]; then
42 return
43 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000044 for I in "${OPTS[@]}"; do
45 # Replace the first '=' with ' ' for iniset syntax
46 iniset $CONF $SECTION ${I/=/ }
47 done
48}
49
Ian Wienandaee18c72014-02-21 15:35:08 +110050function neutron_plugin_configure_common {
Mark McClainb05c8762013-07-06 23:29:39 -040051 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040052 Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
Mark McClainb05c8762013-07-06 23:29:39 -040053 Q_DB_NAME="neutron_ml2"
54 Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin"
Bob Melander748fe3d2013-01-31 17:12:56 +010055 # The ML2 plugin delegates L3 routing/NAT functionality to
56 # the L3 service plugin which must therefore be specified.
Isaku Yamahata9e136b42013-12-16 15:52:03 +090057 _neutron_service_plugin_class_add $ML2_L3_PLUGIN
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040058}
59
Ian Wienandaee18c72014-02-21 15:35:08 +110060function neutron_plugin_configure_service {
Kyle Mesteryb7726592013-07-19 14:26:53 +000061 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000062 Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
Kyle Mesterybd085502014-04-30 23:50:29 +000063 elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000064 # This assumes you want a simple configuration, and will overwrite
65 # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
Kyle Mestery061d5252013-09-09 08:52:19 +000066 Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre)
Kyle Mesteryb7726592013-07-19 14:26:53 +000067 Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
Kyle Mesterybd085502014-04-30 23:50:29 +000068 elif [[ "$ENABLE_TENANT_VLANS" == "True" ]]; then
Kyle Mestery061d5252013-09-09 08:52:19 +000069 Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040070 else
71 echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts."
72 fi
73
Kyle Mesteryb7726592013-07-19 14:26:53 +000074 # Allow for overrding VLAN configuration (for example, to configure provider
75 # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set.
76 if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then
Kyle Mesterybd085502014-04-30 23:50:29 +000077 if [[ "$ML2_VLAN_RANGES" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +000078 ML2_VLAN_RANGES=$PHYSICAL_NETWORK
79 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
80 ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE
81 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040082 fi
Kyle Mesteryb7726592013-07-19 14:26:53 +000083 if [[ "$ML2_VLAN_RANGES" != "" ]]; then
84 Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES)
85 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040086 fi
87
88 # REVISIT(rkukura): Setting firewall_driver here for
Mark McClainb05c8762013-07-06 23:29:39 -040089 # neutron.agent.securitygroups_rpc.is_firewall_enabled() which is
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040090 # used in the server, in case no L2 agent is configured on the
91 # server's node. If an L2 agent is configured, this will get
92 # overridden with the correct driver. The ml2 plugin should
93 # instead use its own config variable to indicate whether security
94 # groups is enabled, and that will need to be set here instead.
95 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
Akihiro Motoki4074e292014-02-14 00:54:58 +090096 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.not.a.real.FirewallDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040097 else
Akihiro Motoki4074e292014-02-14 00:54:58 +090098 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040099 fi
100
Kyle Mesteryb7726592013-07-19 14:26:53 +0000101 # Since we enable the tunnel TypeDrivers, also enable a local_ip
Edgar Magana6f335b92014-07-10 15:42:44 -0700102 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP
Kyle Mesteryb7726592013-07-19 14:26:53 +0000103
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900104 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS
Kyle Mestery3ea28ec2013-08-05 12:24:32 +0000105
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900106 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000107
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900108 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000109
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900110 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000111
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900112 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS
Kyle Mesteryb7726592013-07-19 14:26:53 +0000113
Akihiro Motoki130c90e2013-11-28 16:56:51 +0900114 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS
Brian Haleyeea76212014-06-27 11:45:50 -0400115
116 if [[ "$Q_DVR_MODE" != "legacy" ]]; then
117 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent l2_population=True
118 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent tunnel_types=vxlan
119 populate_ml2_config /$Q_PLUGIN_CONF_FILE agent enable_distributed_routing=True
120 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400121}
122
Ian Wienandaee18c72014-02-21 15:35:08 +1100123function has_neutron_plugin_security_group {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400124 return 0
125}
126
127# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500128$ML2_XTRACE