blob: 1c04f2f64eb5895e1c1338b12f2b0af3d103d70a [file] [log] [blame]
fumihiko kakuma5a110d42014-01-29 14:42:06 +09001# OpenFlow Agent plugin
2# ----------------------
3
4# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05005OFA_XTRACE=$(set +o | grep xtrace)
fumihiko kakuma5a110d42014-01-29 14:42:06 +09006set +o xtrace
7
8source $TOP_DIR/lib/neutron_plugins/ovs_base
9source $TOP_DIR/lib/neutron_thirdparty/ryu # for RYU_DIR, install_ryu, etc
10
11function neutron_plugin_create_nova_conf {
12 _neutron_ovs_base_configure_nova_vif_driver
13}
14
15function neutron_plugin_install_agent_packages {
16 _neutron_ovs_base_install_agent_packages
17
18 # This agent uses ryu to talk with switches
19 install_package $(get_packages "ryu")
20 install_ryu
21 configure_ryu
22}
23
24function neutron_plugin_configure_debug_command {
25 _neutron_ovs_base_configure_debug_command
26}
27
28function neutron_plugin_configure_dhcp_agent {
29 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
30}
31
32function neutron_plugin_configure_l3_agent {
33 _neutron_ovs_base_configure_l3_agent
34 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport
35}
36
YAMAMOTO Takashifec7b152014-07-23 16:39:28 +090037function _neutron_ofagent_configure_firewall_driver {
38 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
39 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
40 else
41 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
42 fi
43}
44
fumihiko kakuma5a110d42014-01-29 14:42:06 +090045function neutron_plugin_configure_plugin_agent {
46 # Set up integration bridge
47 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
YAMAMOTO Takashifec7b152014-07-23 16:39:28 +090048 _neutron_ofagent_configure_firewall_driver
fumihiko kakuma5a110d42014-01-29 14:42:06 +090049
50 # Check a supported openflow version
51 OF_VERSION=`ovs-ofctl --version | grep "OpenFlow versions" | awk '{print $3}' | cut -d':' -f2`
52 if [ `vercmp_numbers "$OF_VERSION" "0x3"` -lt "0" ]; then
53 die $LINENO "This agent requires OpenFlow 1.3+ capable switch."
54 fi
55
56 # Enable tunnel networks if selected
Kyle Mesterybd085502014-04-30 23:50:29 +000057 if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then
fumihiko kakuma5a110d42014-01-29 14:42:06 +090058 # Verify tunnels are supported
59 # REVISIT - also check kernel module support for GRE and patch ports
60 OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"`
61 if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ]; then
62 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
63 fi
64 iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True
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