blob: 1f1b0e8e52d75b9dc77dba51c16317ac7da4845a [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
mathieu-rohon50187ee2014-11-21 22:12:40 +01003# Neutron Linux Bridge L2 agent
4# -----------------------------
5
6# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +11007_XTRACE_NEUTRON_LB=$(set +o | grep xtrace)
mathieu-rohon50187ee2014-11-21 22:12:40 +01008set +o xtrace
9
Sean M. Collins64d5ecf2015-06-01 14:13:41 -040010function neutron_lb_cleanup {
Nate Johnston56946cf2018-11-12 11:17:07 -050011 sudo ip link delete $PUBLIC_BRIDGE
Hirofumi Ichihara5c0546e2015-06-26 17:43:28 +090012
Nate Johnston56946cf2018-11-12 11:17:07 -050013 bridge_list=`ls /sys/class/net/*/bridge/bridge_id 2>/dev/null | cut -f5 -d/`
14 if [[ -z "$bridge_list" ]]; then
15 return
16 fi
Hirofumi Ichihara5c0546e2015-06-26 17:43:28 +090017 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vxlan" ]]; then
Nate Johnston56946cf2018-11-12 11:17:07 -050018 for port in $(echo $bridge_list | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e vxlan-[0-9a-f\-]*); do
Hirofumi Ichihara5c0546e2015-06-26 17:43:28 +090019 sudo ip link delete $port
20 done
21 elif [[ "$Q_ML2_TENANT_NETWORK_TYPE" = "vlan" ]]; then
Nate Johnston56946cf2018-11-12 11:17:07 -050022 for port in $(echo $bridge_list | grep -o -e [a-zA-Z\-]*tap[0-9a-f\-]* -e ${LB_PHYSICAL_INTERFACE}\.[0-9a-f\-]*); do
Hirofumi Ichihara5c0546e2015-06-26 17:43:28 +090023 sudo ip link delete $port
24 done
25 fi
Nate Johnston56946cf2018-11-12 11:17:07 -050026 for bridge in $(echo $bridge_list |grep -o -e brq[0-9a-f\-]*); do
27 sudo ip link delete $bridge
Hirofumi Ichihara5c0546e2015-06-26 17:43:28 +090028 done
Sean M. Collins64d5ecf2015-06-01 14:13:41 -040029}
30
mathieu-rohon50187ee2014-11-21 22:12:40 +010031function is_neutron_ovs_base_plugin {
32 # linuxbridge doesn't use OVS
33 return 1
34}
35
36function neutron_plugin_create_nova_conf {
37 :
38}
39
40function neutron_plugin_install_agent_packages {
41 install_package bridge-utils
42}
43
mathieu-rohon50187ee2014-11-21 22:12:40 +010044function neutron_plugin_configure_dhcp_agent {
Sean M. Collins2a242512016-05-03 09:03:09 -040045 local conf_file=$1
Armando Migliaccio14b12a72016-08-12 19:07:12 -070046 :
mathieu-rohon50187ee2014-11-21 22:12:40 +010047}
48
49function neutron_plugin_configure_l3_agent {
Sean M. Collins2a242512016-05-03 09:03:09 -040050 local conf_file=$1
Brian Haleyda188952019-10-31 14:49:23 -040051 sudo ip link add $PUBLIC_BRIDGE type bridge
Ihar Hrachyshka7b5c7dc2016-07-15 20:17:13 +020052 set_mtu $PUBLIC_BRIDGE $PUBLIC_BRIDGE_MTU
mathieu-rohon50187ee2014-11-21 22:12:40 +010053}
54
55function 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
Kevin Benton6a42a852016-07-21 11:11:54 -070062 if [[ "$PUBLIC_BRIDGE" != "" ]] && [[ "$PUBLIC_PHYSICAL_NETWORK" != "" ]]; then
Armando Migliaccio1c08b192016-11-29 15:58:53 -080063 if is_service_enabled q-l3 || is_service_enabled neutron-l3; then
64 iniset /$Q_PLUGIN_CONF_FILE linux_bridge bridge_mappings "$PUBLIC_PHYSICAL_NETWORK:$PUBLIC_BRIDGE"
65 fi
Kevin Benton6a42a852016-07-21 11:11:54 -070066 fi
mathieu-rohon50187ee2014-11-21 22:12:40 +010067 if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
68 iniset /$Q_PLUGIN_CONF_FILE linux_bridge physical_interface_mappings $LB_INTERFACE_MAPPINGS
69 fi
70 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
71 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
Denis Buliga0bf75a42017-02-06 16:56:46 +020072 if ! running_in_container; then
73 enable_kernel_bridge_firewall
74 fi
mathieu-rohon50187ee2014-11-21 22:12:40 +010075 else
76 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
77 fi
78 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-linuxbridge-agent"
79 iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES
Nickc295bca2015-08-04 09:28:19 +080080
81 # Configure vxlan tunneling
82 if [[ "$ENABLE_TENANT_TUNNELS" == "True" ]]; then
83 if [[ "$Q_ML2_TENANT_NETWORK_TYPE" == "vxlan" ]]; then
84 iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "True"
85 iniset /$Q_PLUGIN_CONF_FILE vxlan local_ip $TUNNEL_ENDPOINT_IP
86 else
87 iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False"
88 fi
89 else
90 iniset /$Q_PLUGIN_CONF_FILE vxlan enable_vxlan "False"
91 fi
mathieu-rohon50187ee2014-11-21 22:12:40 +010092}
93
94function neutron_plugin_setup_interface_driver {
95 local conf_file=$1
Martin Hickeydca49de2015-10-20 12:13:19 +010096 iniset $conf_file DEFAULT interface_driver linuxbridge
mathieu-rohon50187ee2014-11-21 22:12:40 +010097}
98
99function neutron_plugin_check_adv_test_requirements {
100 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
101}
102
103# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100104$_XTRACE_NEUTRON_LB