Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 3 | # Neutron Modular Layer 2 plugin |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 4 | # ------------------------------ |
| 5 | |
| 6 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 7 | _XTRACE_NEUTRON_ML2=$(set +o | grep xtrace) |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 8 | set +o xtrace |
| 9 | |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 10 | # Enable this to simply and quickly enable tunneling with ML2. |
Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 11 | # Select either 'gre', 'vxlan', or 'gre,vxlan' |
Attila Fazekas | 8feaf6c | 2014-07-27 20:47:04 +0200 | [diff] [blame] | 12 | Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-"vxlan"} |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 13 | # This has to be set here since the agent will set this in the config file |
Kevin Benton | e3cfbf1 | 2014-08-04 11:25:20 -0600 | [diff] [blame] | 14 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "gre" || "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then |
Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 15 | Q_TUNNEL_TYPES=$Q_ML2_TENANT_NETWORK_TYPE |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 16 | elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then |
Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 17 | Q_TUNNEL_TYPES=gre |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 18 | fi |
| 19 | |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 20 | # Default openvswitch L2 agent |
| 21 | Q_AGENT=${Q_AGENT:-openvswitch} |
Hirofumi Ichihara | 22cf648 | 2015-07-23 18:13:55 +0900 | [diff] [blame] | 22 | if [ -f $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent ]; then |
| 23 | source $TOP_DIR/lib/neutron_plugins/${Q_AGENT}_agent |
| 24 | fi |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 25 | |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 26 | # List of MechanismDrivers to load |
Kyle Mestery | bc63247 | 2013-09-06 14:59:30 +0000 | [diff] [blame] | 27 | Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-openvswitch,linuxbridge} |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 28 | # Default GRE TypeDriver options |
| 29 | Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GRE_TYPE_OPTIONS:-tunnel_id_ranges=$TENANT_TUNNEL_RANGES} |
| 30 | # Default VXLAN TypeDriver options |
Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 31 | Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES} |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 32 | # Default VLAN TypeDriver options |
| 33 | Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=${Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS:-} |
Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 34 | # Default GENEVE TypeDriver options |
| 35 | Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS:-vni_ranges=$TENANT_TUNNEL_RANGES} |
Yalei Wang | a48e5dc | 2015-03-06 17:05:11 +0800 | [diff] [blame] | 36 | # List of extension drivers to load, use '-' instead of ':-' to allow people to |
| 37 | # explicitly override this to blank |
Matt Riedemann | c9c9d31 | 2016-09-15 20:33:22 -0400 | [diff] [blame] | 38 | if [[ "$NEUTRON_PORT_SECURITY" = "True" ]]; then |
| 39 | Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS-port_security} |
| 40 | else |
| 41 | Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS:-} |
| 42 | fi |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 43 | |
Kyle Mestery | 14ea1a2 | 2013-09-22 03:04:56 +0000 | [diff] [blame] | 44 | # L3 Plugin to load for ML2 |
watanabe.isao | 1c4c16c | 2016-06-08 14:18:10 +0900 | [diff] [blame] | 45 | # For some flat network environment, they not want to extend L3 plugin. |
| 46 | # Make sure it is able to set empty to ML2_L3_PLUGIN. |
| 47 | ML2_L3_PLUGIN=${ML2_L3_PLUGIN-neutron.services.l3_router.l3_router_plugin.L3RouterPlugin} |
Kyle Mestery | 14ea1a2 | 2013-09-22 03:04:56 +0000 | [diff] [blame] | 48 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 49 | function populate_ml2_config { |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 50 | CONF=$1 |
| 51 | SECTION=$2 |
| 52 | OPTS=$3 |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 53 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 54 | if [ -z "$OPTS" ]; then |
| 55 | return |
| 56 | fi |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 57 | for I in "${OPTS[@]}"; do |
| 58 | # Replace the first '=' with ' ' for iniset syntax |
| 59 | iniset $CONF $SECTION ${I/=/ } |
| 60 | done |
| 61 | } |
| 62 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 63 | function neutron_plugin_configure_common { |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 64 | Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ml2 |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 65 | Q_PLUGIN_CONF_FILENAME=ml2_conf.ini |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 66 | Q_PLUGIN_CLASS="neutron.plugins.ml2.plugin.Ml2Plugin" |
Bob Melander | 748fe3d | 2013-01-31 17:12:56 +0100 | [diff] [blame] | 67 | # The ML2 plugin delegates L3 routing/NAT functionality to |
| 68 | # the L3 service plugin which must therefore be specified. |
Isaku Yamahata | 9e136b4 | 2013-12-16 15:52:03 +0900 | [diff] [blame] | 69 | _neutron_service_plugin_class_add $ML2_L3_PLUGIN |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 70 | } |
| 71 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 72 | function neutron_plugin_configure_service { |
Attila Fazekas | 8feaf6c | 2014-07-27 20:47:04 +0200 | [diff] [blame] | 73 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" != "local" ]]; then |
Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 74 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=$Q_ML2_TENANT_NETWORK_TYPE) |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 75 | elif [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 76 | # This assumes you want a simple configuration, and will overwrite |
| 77 | # Q_SRV_EXTRA_OPTS if set in addition to ENABLE_TENANT_TUNNELS. |
Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 78 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=gre) |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 79 | Q_ML2_PLUGIN_GRE_TYPE_OPTIONS=(tunnel_id_ranges=$TENANT_TUNNEL_RANGES) |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 80 | elif [[ "$ENABLE_TENANT_VLANS" == "True" ]]; then |
Kyle Mestery | 061d525 | 2013-09-09 08:52:19 +0000 | [diff] [blame] | 81 | Q_SRV_EXTRA_OPTS+=(tenant_network_types=vlan) |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 82 | else |
| 83 | echo "WARNING - The ml2 plugin is using local tenant networks, with no connectivity between hosts." |
| 84 | fi |
| 85 | |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 86 | # Allow for overrding VLAN configuration (for example, to configure provider |
| 87 | # VLANs) by first checking if Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS is set. |
| 88 | if [ "$Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS" == "" ]; then |
Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 89 | if [[ "$ML2_VLAN_RANGES" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 90 | ML2_VLAN_RANGES=$PHYSICAL_NETWORK |
| 91 | if [[ "$TENANT_VLAN_RANGE" != "" ]]; then |
| 92 | ML2_VLAN_RANGES=$ML2_VLAN_RANGES:$TENANT_VLAN_RANGE |
| 93 | fi |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 94 | fi |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 95 | if [[ "$ML2_VLAN_RANGES" != "" ]]; then |
| 96 | Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS=(network_vlan_ranges=$ML2_VLAN_RANGES) |
| 97 | fi |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 98 | fi |
| 99 | |
yunhong jiang | 73d3216 | 2014-10-06 09:34:35 -0700 | [diff] [blame] | 100 | |
| 101 | # Allow for setup the flat type network |
Kevin Benton | 6a42a85 | 2016-07-21 11:11:54 -0700 | [diff] [blame] | 102 | if [[ -z "$Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS" ]]; then |
| 103 | if [[ -n "$PHYSICAL_NETWORK" || -n "$PUBLIC_PHYSICAL_NETWORK" ]]; then |
| 104 | Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS="flat_networks=" |
| 105 | if [[ -n "$PHYSICAL_NETWORK" ]]; then |
| 106 | Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PHYSICAL_NETWORK}," |
| 107 | fi |
| 108 | if [[ -n "$PUBLIC_PHYSICAL_NETWORK" ]]; then |
| 109 | Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS+="${PUBLIC_PHYSICAL_NETWORK}," |
| 110 | fi |
| 111 | fi |
yunhong jiang | 73d3216 | 2014-10-06 09:34:35 -0700 | [diff] [blame] | 112 | fi |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 113 | # REVISIT(rkukura): Setting firewall_driver here for |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 114 | # neutron.agent.securitygroups_rpc.is_firewall_enabled() which is |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 115 | # used in the server, in case no L2 agent is configured on the |
| 116 | # server's node. If an L2 agent is configured, this will get |
| 117 | # overridden with the correct driver. The ml2 plugin should |
| 118 | # instead use its own config variable to indicate whether security |
| 119 | # groups is enabled, and that will need to be set here instead. |
| 120 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then |
Akihiro Motoki | 4074e29 | 2014-02-14 00:54:58 +0900 | [diff] [blame] | 121 | 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] | 122 | else |
Akihiro Motoki | 4074e29 | 2014-02-14 00:54:58 +0900 | [diff] [blame] | 123 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 124 | fi |
| 125 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 126 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 mechanism_drivers=$Q_ML2_PLUGIN_MECHANISM_DRIVERS |
Kyle Mestery | 3ea28ec | 2013-08-05 12:24:32 +0000 | [diff] [blame] | 127 | |
Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 128 | if [[ -n "$Q_ML2_PLUGIN_TYPE_DRIVERS" ]]; then |
| 129 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 type_drivers=$Q_ML2_PLUGIN_TYPE_DRIVERS |
| 130 | fi |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 131 | |
Yalei Wang | a48e5dc | 2015-03-06 17:05:11 +0800 | [diff] [blame] | 132 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 extension_drivers=$Q_ML2_PLUGIN_EXT_DRIVERS |
| 133 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 134 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2 $Q_SRV_EXTRA_OPTS |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 135 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 136 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_gre $Q_ML2_PLUGIN_GRE_TYPE_OPTIONS |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 137 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 138 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vxlan $Q_ML2_PLUGIN_VXLAN_TYPE_OPTIONS |
Kyle Mestery | b772659 | 2013-07-19 14:26:53 +0000 | [diff] [blame] | 139 | |
yunhong jiang | 73d3216 | 2014-10-06 09:34:35 -0700 | [diff] [blame] | 140 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_flat $Q_ML2_PLUGIN_FLAT_TYPE_OPTIONS |
| 141 | |
Akihiro Motoki | 130c90e | 2013-11-28 16:56:51 +0900 | [diff] [blame] | 142 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_vlan $Q_ML2_PLUGIN_VLAN_TYPE_OPTIONS |
Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 143 | |
Richard Theis | 8906b48 | 2016-06-08 10:28:37 -0500 | [diff] [blame] | 144 | populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_geneve $Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS |
| 145 | |
Brian Haley | eea7621 | 2014-06-27 11:45:50 -0400 | [diff] [blame] | 146 | if [[ "$Q_DVR_MODE" != "legacy" ]]; then |
| 147 | populate_ml2_config /$Q_PLUGIN_CONF_FILE agent l2_population=True |
| 148 | populate_ml2_config /$Q_PLUGIN_CONF_FILE agent tunnel_types=vxlan |
| 149 | populate_ml2_config /$Q_PLUGIN_CONF_FILE agent enable_distributed_routing=True |
| 150 | fi |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 151 | } |
| 152 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 153 | function has_neutron_plugin_security_group { |
Bob Kukura | c9b0f1a | 2013-04-23 16:28:24 -0400 | [diff] [blame] | 154 | return 0 |
| 155 | } |
| 156 | |
| 157 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 158 | $_XTRACE_NEUTRON_ML2 |