blob: 035d6cc81db1e2cabeedf12286e44fc48c68d5c4 [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
5MY_XTRACE=$(set +o | grep xtrace)
6set +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
13 Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=$Q_ML2_TENANT_NETWORK_TYPE)
14elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
15 Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=gre)
16fi
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 Mestery3ea28ec2013-08-05 12:24:32 +000023Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-}
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
33function populate_ml2_config() {
34 OPTS=$1
35 CONF=$2
36 SECTION=$3
37
38 for I in "${OPTS[@]}"; do
39 # Replace the first '=' with ' ' for iniset syntax
40 iniset $CONF $SECTION ${I/=/ }
41 done
42}
43
Mark McClainb05c8762013-07-06 23:29:39 -040044function neutron_plugin_configure_common() {
45 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040046 Q_PLUGIN_CONF_FILENAME=ml2_conf.ini
Mark McClainb05c8762013-07-06 23:29:39 -040047 Q_DB_NAME="neutron_ml2"
48 Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin"
Bob Melander748fe3d2013-01-31 17:12:56 +010049 # The ML2 plugin delegates L3 routing/NAT functionality to
50 # the L3 service plugin which must therefore be specified.
51 Q_L3_PLUGIN_CLASS=${Q_L3_PLUGIN_CLASS:-"neutron.services.l3_router.l3_router_plugin.L3RouterPlugin"}
52 if ini_has_option $NEUTRON_CONF DEFAULT service_plugins ; then
53 srv_plugins=$(iniget $NEUTRON_CONF DEFAULT service_plugins)","$Q_L3_PLUGIN_CLASS
54 else
55 srv_plugins=$Q_L3_PLUGIN_CLASS
56 fi
57 iniset $NEUTRON_CONF DEFAULT service_plugins $srv_plugins
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040058}
59
Mark McClainb05c8762013-07-06 23:29:39 -040060function neutron_plugin_configure_service() {
Kyle Mesteryb7726592013-07-19 14:26:53 +000061 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then
62 Q_SRV_EXTRA_OPTS=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE)
63 elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
64 # This assumes you want a simple configuration, and will overwrite
65 # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS.
66 Q_SRV_EXTRA_OPTS=(tenant_network_types=gre)
67 Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES)
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040068 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
Kyle Mesteryb7726592013-07-19 14:26:53 +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
77 if [[ "$ML2_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
78 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
Mark McClainb05c8762013-07-06 23:29:39 -040096 iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver neutron.agent.not.a.real.FirewallDriver
Bob Kukurac9b0f1a2013-04-23 16:28:24 -040097 else
Mark McClainb05c8762013-07-06 23:29:39 -040098 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
102 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP
103
Kyle Mestery3ea28ec2013-08-05 12:24:32 +0000104 populate_ml2_config mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS /$Q_PLUGIN_CONF_FILE ml2
105
Kyle Mesteryb7726592013-07-19 14:26:53 +0000106 populate_ml2_config type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS /$Q_PLUGIN_CONF_FILE ml2
107
108 populate_ml2_config $Q_SRV_EXTRA_OPTS /$Q_PLUGIN_CONF_FILE ml2
109
110 populate_ml2_config $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_gre
111
112 populate_ml2_config $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vxlan
113
114 if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" != "" ]; then
115 populate_ml2_config $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vlan
116 fi
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400117}
118
Mark McClainb05c8762013-07-06 23:29:39 -0400119function has_neutron_plugin_security_group() {
Bob Kukurac9b0f1a2013-04-23 16:28:24 -0400120 return 0
121}
122
123# Restore xtrace
124$MY_XTRACE