| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1 | # Neutron Modular Layer 2 plugin | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 2 | # ------------------------------ | 
|  | 3 |  | 
|  | 4 | # Save trace setting | 
|  | 5 | MY_XTRACE=$(set +o | grep xtrace) | 
|  | 6 | set +o xtrace | 
|  | 7 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 8 | # Enable this to simply and quickly enable tunneling with ML2. | 
|  | 9 | # Select either 'gre', 'vxlan', or '(gre vxlan)' | 
|  | 10 | Q_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 | 
|  | 12 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then | 
| Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 13 | Q_AGENT_EXTRA_AGENT_OPTS+=(tunnel_types=$Q_ML2_TENANT_NETWORK_TYPE) | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 14 | elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then | 
| Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 15 | Q_AGENT_EXTRA_AGENT_OPTS+=(tunnel_types=gre) | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 16 | fi | 
|  | 17 |  | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 18 | # Default openvswitch L2 agent | 
|  | 19 | Q_AGENT=${Q_AGENT:-openvswitch} | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 20 | source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 21 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 22 | # List of MechanismDrivers to load | 
| Kyle Mestery | bc63247 | 2013-09-06 14:59:30 +0000 | [diff] [blame] | 23 | Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-openvswitch,linuxbridge} | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 24 | # List of Type Drivers to load | 
|  | 25 | Q_ML2_PLUGIN_TYPE_DRIVERS=${Q_ML2_PLUGIN_TYPE_DRIVERS:-local,flat,vlan,gre,vxlan} | 
|  | 26 | # Default GRE TypeDriver options | 
|  | 27 | Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES} | 
|  | 28 | # Default VXLAN TypeDriver options | 
|  | 29 | Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=1001:2000} | 
|  | 30 | # Default VLAN TypeDriver options | 
|  | 31 | Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-} | 
|  | 32 |  | 
| Kyle Mestery | 14ea1a2 | 2013-09-22 03:04:56 +0000 | [diff] [blame] | 33 | # L3 Plugin to load for ML2 | 
|  | 34 | ML2_L3_PLUGIN=${ML2_L3_PLUGIN:-neutron.services.l3_router.l3_router_plugin.L3RouterPlugin} | 
|  | 35 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 36 | function populate_ml2_config() { | 
|  | 37 | OPTS=$1 | 
|  | 38 | CONF=$2 | 
|  | 39 | SECTION=$3 | 
|  | 40 |  | 
|  | 41 | for I in "${OPTS[@]}"; do | 
|  | 42 | # Replace the first '=' with ' ' for iniset syntax | 
|  | 43 | iniset $CONF $SECTION ${I/=/ } | 
|  | 44 | done | 
|  | 45 | } | 
|  | 46 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 47 | function neutron_plugin_configure_common() { | 
|  | 48 | Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2 | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 49 | Q_PLUGIN_CONF_FILENAME=ml2_conf.ini | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 50 | Q_DB_NAME="neutron_ml2" | 
|  | 51 | Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin" | 
| Bob Melander | 748fe3d | 2013-01-31 17:12:56 +0100 | [diff] [blame] | 52 | # The ML2 plugin delegates L3 routing/NAT functionality to | 
|  | 53 | # the L3 service plugin which must therefore be specified. | 
| Kyle Mestery | 14ea1a2 | 2013-09-22 03:04:56 +0000 | [diff] [blame] | 54 | if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then | 
|  | 55 | Q_SERVICE_PLUGIN_CLASSES=$ML2_L3_PLUGIN | 
| Bob Melander | 748fe3d | 2013-01-31 17:12:56 +0100 | [diff] [blame] | 56 | else | 
| Kyle Mestery | 14ea1a2 | 2013-09-22 03:04:56 +0000 | [diff] [blame] | 57 | Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$ML2_L3_PLUGIN" | 
| Bob Melander | 748fe3d | 2013-01-31 17:12:56 +0100 | [diff] [blame] | 58 | fi | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 59 | } | 
|  | 60 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 61 | function neutron_plugin_configure_service() { | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 62 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "" ]]; then | 
| Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 63 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE) | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 64 | elif [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then | 
|  | 65 | # This assumes you want a simple configuration, and will overwrite | 
|  | 66 | # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS. | 
| Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 67 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre) | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 68 | Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES) | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 69 | elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then | 
| Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 70 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan) | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 71 | else | 
|  | 72 | echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts." | 
|  | 73 | fi | 
|  | 74 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 75 | # Allow for overrding VLAN configuration (for example, to configure provider | 
|  | 76 | # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set. | 
|  | 77 | if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then | 
|  | 78 | if [[ "$ML2_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then | 
|  | 79 | ML2_VLAN_RANGES=$PHYSICAL_NETWORK | 
|  | 80 | if [[ "$TENANT_VLAN_RANGE" != "" ]]; then | 
|  | 81 | ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE | 
|  | 82 | fi | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 83 | fi | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 84 | if [[ "$ML2_VLAN_RANGES" != "" ]]; then | 
|  | 85 | Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES) | 
|  | 86 | fi | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 87 | fi | 
|  | 88 |  | 
|  | 89 | # REVISIT(rkukura): Setting firewall_driver here for | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 90 | # neutron.agent.securitygroups_rpc.is_firewall_enabled() which is | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 91 | # used in the server, in case no L2 agent is configured on the | 
|  | 92 | # server's node. If an L2 agent is configured, this will get | 
|  | 93 | # overridden with the correct driver. The ml2 plugin should | 
|  | 94 | # instead use its own config variable to indicate whether security | 
|  | 95 | # groups is enabled, and that will need to be set here instead. | 
|  | 96 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 97 | iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver neutron.agent.not.a.real.FirewallDriver | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 98 | else | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 99 | iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver neutron.agent.firewall.NoopFirewallDriver | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 100 | fi | 
|  | 101 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 102 | # Since we enable the tunnel TypeDrivers, also enable a local_ip | 
|  | 103 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP | 
|  | 104 |  | 
| Kyle Mestery | 3ea28ec | 2013-08-05 12:24:32 +0000 | [diff] [blame] | 105 | populate_ml2_config mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS /$Q_PLUGIN_CONF_FILE ml2 | 
|  | 106 |  | 
| Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 107 | populate_ml2_config type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS /$Q_PLUGIN_CONF_FILE ml2 | 
|  | 108 |  | 
|  | 109 | populate_ml2_config $Q_SRV_EXTRA_OPTS /$Q_PLUGIN_CONF_FILE ml2 | 
|  | 110 |  | 
|  | 111 | populate_ml2_config $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_gre | 
|  | 112 |  | 
|  | 113 | populate_ml2_config $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vxlan | 
|  | 114 |  | 
|  | 115 | if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" != "" ]; then | 
|  | 116 | populate_ml2_config $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS /$Q_PLUGIN_CONF_FILE ml2_type_vlan | 
|  | 117 | fi | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 118 | } | 
|  | 119 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 120 | function has_neutron_plugin_security_group() { | 
| Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 121 | return 0 | 
|  | 122 | } | 
|  | 123 |  | 
|  | 124 | # Restore xtrace | 
|  | 125 | $MY_XTRACE |