| 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 { | 
|  | 11 | sudo brctl delbr $PUBLIC_BRIDGE | 
| Hirofumi Ichihara | 5c0546e | 2015-06-26 17:43:28 +0900 | [diff] [blame] | 12 |  | 
|  | 13 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vxlan" ]]; then | 
|  | 14 | for port in $(sudo brctl show | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e vxlan-[0-9a-f\-]*); do | 
|  | 15 | sudo ip link delete $port | 
|  | 16 | done | 
|  | 17 | elif [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vlan" ]]; then | 
|  | 18 | for port in $(sudo brctl show | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e ${LB_PHYSICAL_INTERFACE}\.[0-9a-f\-]*); do | 
|  | 19 | sudo ip link delete $port | 
|  | 20 | done | 
|  | 21 | fi | 
|  | 22 | for bridge in $(sudo brctl show |grep -o -e brq[0-9a-f\-]*); do | 
|  | 23 | sudo ip link set $bridge down | 
|  | 24 | sudo brctl delbr $bridge | 
|  | 25 | done | 
| Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 26 | } | 
|  | 27 |  | 
| mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 28 | function is_neutron_ovs_base_plugin { | 
|  | 29 | # linuxbridge doesn't use OVS | 
|  | 30 | return 1 | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | function neutron_plugin_create_nova_conf { | 
|  | 34 | : | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | function neutron_plugin_install_agent_packages { | 
|  | 38 | install_package bridge-utils | 
|  | 39 | } | 
|  | 40 |  | 
|  | 41 | function neutron_plugin_configure_debug_command { | 
|  | 42 | iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | function neutron_plugin_configure_dhcp_agent { | 
|  | 46 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport | 
|  | 47 | } | 
|  | 48 |  | 
|  | 49 | function neutron_plugin_configure_l3_agent { | 
| Sean M. Collins | 64d5ecf | 2015-06-01 14:13:41 -0400 | [diff] [blame] | 50 | sudo brctl addbr $PUBLIC_BRIDGE | 
| mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 51 | iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge | 
|  | 52 | iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | function neutron_plugin_configure_plugin_agent { | 
|  | 56 | # Setup physical network interface mappings.  Override | 
|  | 57 | # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more | 
|  | 58 | # complex physical network configurations. | 
|  | 59 | if [[ "$LB_INTERFACE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then | 
|  | 60 | LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE | 
|  | 61 | fi | 
|  | 62 | if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then | 
|  | 63 | iniset /$Q_PLUGIN_CONF_FILE linux_bridge physical_interface_mappings $LB_INTERFACE_MAPPINGS | 
|  | 64 | fi | 
|  | 65 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
|  | 66 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver | 
|  | 67 | else | 
|  | 68 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver | 
|  | 69 | fi | 
|  | 70 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-linuxbridge-agent" | 
|  | 71 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES | 
| Nick | c295bca | 2015-08-04 09:28:19 +0800 | [diff] [blame] | 72 |  | 
|  | 73 | # Configure vxlan tunneling | 
|  | 74 | if [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then | 
|  | 75 | if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then | 
|  | 76 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "True" | 
|  | 77 | iniset /$Q_PLUGIN_CONF_FILE vxlan local_ip $TUNNEL_ENDPOINT_IP | 
|  | 78 | else | 
|  | 79 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False" | 
|  | 80 | fi | 
|  | 81 | else | 
|  | 82 | iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False" | 
|  | 83 | fi | 
| mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 84 | } | 
|  | 85 |  | 
|  | 86 | function neutron_plugin_setup_interface_driver { | 
|  | 87 | local conf_file=$1 | 
| Martin Hickey | dca49de | 2015-10-20 12:13:19 +0100 | [diff] [blame] | 88 | iniset $conf_file DEFAULT interface_driver linuxbridge | 
| mathieu-rohon | 50187ee | 2014-11-21 22:12:40 +0100 | [diff] [blame] | 89 | } | 
|  | 90 |  | 
|  | 91 | function neutron_plugin_check_adv_test_requirements { | 
|  | 92 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 | 
|  | 93 | } | 
|  | 94 |  | 
|  | 95 | # Restore xtrace | 
| Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 96 | $_XTRACE_NEUTRON_LB |