Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 3 | # Neutron Linux Bridge L2 agent |
| 4 | # ----------------------------- |
| 5 | |
| 6 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 7 | _XTRACE_NEUTRON_LB=$(set +o | grep xtrace) |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 8 | set +o xtrace |
| 9 | |
Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 10 | function neutron_lb_cleanup { |
Hirofumi Ichihara | 40aae6a | 2017-02-08 00:08:53 +0900 | [diff] [blame] | 11 | sudo ip link set $PUBLIC_BRIDGE down |
Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 12 | sudo brctl delbr $PUBLIC_BRIDGE |
Hirofumi Ichihara | 5c0546e | 2015-06-26 17:43:28 +0900 | [diff] [blame] | 13 | |
| 14 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vxlan" ]]; then |
| 15 | for port in $(sudo brctl show | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e vxlan-[0-9a-f\-]*); do |
| 16 | sudo ip link delete $port |
| 17 | done |
| 18 | elif [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vlan" ]]; then |
| 19 | for port in $(sudo brctl show | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e ${LB_PHYSICAL_INTERFACE}\.[0-9a-f\-]*); do |
| 20 | sudo ip link delete $port |
| 21 | done |
| 22 | fi |
| 23 | for bridge in $(sudo brctl show |grep -o -e brq[0-9a-f\-]*); do |
| 24 | sudo ip link set $bridge down |
| 25 | sudo brctl delbr $bridge |
| 26 | done |
Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 27 | } |
| 28 | |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 29 | function is_neutron_ovs_base_plugin { |
| 30 | # linuxbridge doesn't use OVS |
| 31 | return 1 |
| 32 | } |
| 33 | |
| 34 | function neutron_plugin_create_nova_conf { |
| 35 | : |
| 36 | } |
| 37 | |
| 38 | function neutron_plugin_install_agent_packages { |
| 39 | install_package bridge-utils |
| 40 | } |
| 41 | |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 42 | function neutron_plugin_configure_dhcp_agent { |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 43 | local conf_file=$1 |
Armando Migliaccio | 14b12a7 | 2016-08-12 19:07:12 -0700 | [diff] [blame] | 44 | : |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | function neutron_plugin_configure_l3_agent { |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 48 | local conf_file=$1 |
Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 49 | sudo brctl addbr $PUBLIC_BRIDGE |
Ihar Hrachyshka | 7b5c7dc | 2016-07-15 20:17:13 +0200 | [diff] [blame] | 50 | set_mtu $PUBLIC_BRIDGE $PUBLIC_BRIDGE_MTU |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | function neutron_plugin_configure_plugin_agent { |
| 54 | # Setup physical network interface mappings. Override |
| 55 | # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more |
| 56 | # complex physical network configurations. |
| 57 | if [[ "$LB_INTERFACE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then |
| 58 | LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE |
| 59 | fi |
Kevin Benton | 6a42a85 | 2016-07-21 11:11:54 -0700 | [diff] [blame] | 60 | if [[ "$PUBLIC_BRIDGE" != "" ]] && [[ "$PUBLIC_PHYSICAL_NETWORK" != "" ]]; then |
Armando Migliaccio | 1c08b19 | 2016-11-29 15:58:53 -0800 | [diff] [blame] | 61 | if is_service_enabled q-l3 || is_service_enabled neutron-l3; then |
| 62 | iniset /$Q_PLUGIN_CONF_FILE linux_bridge bridge_mappings "$PUBLIC_PHYSICAL_NETWORK:$PUBLIC_BRIDGE" |
| 63 | fi |
Kevin Benton | 6a42a85 | 2016-07-21 11:11:54 -0700 | [diff] [blame] | 64 | fi |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 65 | if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then |
| 66 | iniset /$Q_PLUGIN_CONF_FILE linux_bridge physical_interface_mappings $LB_INTERFACE_MAPPINGS |
| 67 | fi |
| 68 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then |
| 69 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver |
Denis Buliga | 0bf75a4 | 2017-02-06 16:56:46 +0200 | [diff] [blame] | 70 | if ! running_in_container; then |
| 71 | enable_kernel_bridge_firewall |
| 72 | fi |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 73 | else |
| 74 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver |
| 75 | fi |
| 76 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-linuxbridge-agent" |
| 77 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES |
Nick | c295bca | 2015-08-04 09:28:19 +0800 | [diff] [blame] | 78 | |
| 79 | # Configure vxlan tunneling |
| 80 | if [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then |
| 81 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then |
| 82 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "True" |
| 83 | iniset /$Q_PLUGIN_CONF_FILE vxlan local_ip $TUNNEL_ENDPOINT_IP |
| 84 | else |
| 85 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False" |
| 86 | fi |
| 87 | else |
| 88 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False" |
| 89 | fi |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | function neutron_plugin_setup_interface_driver { |
| 93 | local conf_file=$1 |
Martin Hickey | dca49de | 2015-10-20 12:13:19 +0100 | [diff] [blame] | 94 | iniset $conf_file DEFAULT interface_driver linuxbridge |
mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | function neutron_plugin_check_adv_test_requirements { |
| 98 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
| 99 | } |
| 100 | |
| 101 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 102 | $_XTRACE_NEUTRON_LB |