blob: 915badc7a08a9ee9de6acacb069cf9ae1c206eee [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
fumihiko kakuma5a110d42014-01-29 14:42:06 +09003# OpenFlow Agent plugin
4# ----------------------
5
6# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05007OFA_XTRACE=$(set +o | grep xtrace)
fumihiko kakuma5a110d42014-01-29 14:42:06 +09008set +o xtrace
9
10source $TOP_DIR/lib/neutron_plugins/ovs_base
11source $TOP_DIR/lib/neutron_thirdparty/ryu # for RYU_DIR, install_ryu, etc
12
13function neutron_plugin_create_nova_conf {
14 _neutron_ovs_base_configure_nova_vif_driver
15}
16
17function neutron_plugin_install_agent_packages {
18 _neutron_ovs_base_install_agent_packages
19
20 # This agent uses ryu to talk with switches
21 install_package $(get_packages "ryu")
22 install_ryu
fumihiko kakuma5a110d42014-01-29 14:42:06 +090023}
24
25function neutron_plugin_configure_debug_command {
26 _neutron_ovs_base_configure_debug_command
27}
28
29function neutron_plugin_configure_dhcp_agent {
30 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
31}
32
33function neutron_plugin_configure_l3_agent {
34 _neutron_ovs_base_configure_l3_agent
35 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport
36}
37
YAMAMOTO Takashifec7b152014-07-23 16:39:28 +090038function _neutron_ofagent_configure_firewall_driver {
39 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
40 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
41 else
42 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
43 fi
44}
45
fumihiko kakuma5a110d42014-01-29 14:42:06 +090046function neutron_plugin_configure_plugin_agent {
47 # Set up integration bridge
48 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
YAMAMOTO Takashifec7b152014-07-23 16:39:28 +090049 _neutron_ofagent_configure_firewall_driver
fumihiko kakuma5a110d42014-01-29 14:42:06 +090050
51 # Check a supported openflow version
52 OF_VERSION=`ovs-ofctl --version | grep "OpenFlow versions" | awk '{print $3}' | cut -d':' -f2`
53 if [ `vercmp_numbers "$OF_VERSION" "0x3"` -lt "0" ]; then
54 die $LINENO "This agent requires OpenFlow 1.3+ capable switch."
55 fi
56
57 # Enable tunnel networks if selected
Kyle Mesterybd085502014-04-30 23:50:29 +000058 if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then
fumihiko kakuma5a110d42014-01-29 14:42:06 +090059 # Verify tunnels are supported
60 # REVISIT - also check kernel module support for GRE and patch ports
61 OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"`
62 if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ]; then
63 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
64 fi
Edgar Magana6f335b92014-07-10 15:42:44 -070065 iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP
fumihiko kakuma5a110d42014-01-29 14:42:06 +090066 fi
67
68 # Setup physical network bridge mappings. Override
69 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
70 # complex physical network configurations.
Kyle Mesterybd085502014-04-30 23:50:29 +000071 if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
fumihiko kakuma5a110d42014-01-29 14:42:06 +090072 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
73
74 # Configure bridge manually with physical interface as port for multi-node
75 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
76 fi
77 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
78 iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
79 fi
YAMAMOTO Takashi0f18c232014-09-12 23:44:58 +090080 if [[ "$OFAGENT_PHYSICAL_INTERFACE_MAPPINGS" != "" ]]; then
81 iniset /$Q_PLUGIN_CONF_FILE agent physical_interface_mappings \
82 $OFAGENT_PHYSICAL_INTERFACE_MAPPINGS
83 fi
fumihiko kakuma5a110d42014-01-29 14:42:06 +090084 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ofagent-agent"
85
Akihiro Motoki2307f9d2014-08-09 18:58:20 +090086 iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES
fumihiko kakuma5a110d42014-01-29 14:42:06 +090087 # Define extra "AGENT" configuration options when q-agt is configured by defining
88 # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``.
89 # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)``
90 for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do
91 # Replace the first '=' with ' ' for iniset syntax
92 iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ }
93 done
94}
95
96function neutron_plugin_setup_interface_driver {
97 local conf_file=$1
98 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
99 iniset $conf_file DEFAULT ovs_use_veth True
100}
101
102function neutron_plugin_check_adv_test_requirements {
103 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
104}
105
106# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500107$OFA_XTRACE