| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 1 | # OpenFlow Agent plugin | 
|  | 2 | # ---------------------- | 
|  | 3 |  | 
|  | 4 | # Save trace setting | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 5 | OFA_XTRACE=$(set +o | grep xtrace) | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 6 | set +o xtrace | 
|  | 7 |  | 
|  | 8 | source $TOP_DIR/lib/neutron_plugins/ovs_base | 
|  | 9 | source $TOP_DIR/lib/neutron_thirdparty/ryu  # for RYU_DIR, install_ryu, etc | 
|  | 10 |  | 
|  | 11 | function neutron_plugin_create_nova_conf { | 
|  | 12 | _neutron_ovs_base_configure_nova_vif_driver | 
|  | 13 | } | 
|  | 14 |  | 
|  | 15 | function 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 | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 21 | } | 
|  | 22 |  | 
|  | 23 | function neutron_plugin_configure_debug_command { | 
|  | 24 | _neutron_ovs_base_configure_debug_command | 
|  | 25 | } | 
|  | 26 |  | 
|  | 27 | function neutron_plugin_configure_dhcp_agent { | 
|  | 28 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | function neutron_plugin_configure_l3_agent { | 
|  | 32 | _neutron_ovs_base_configure_l3_agent | 
|  | 33 | iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager neutron.agent.l3_agent.L3NATAgentWithStateReport | 
|  | 34 | } | 
|  | 35 |  | 
| YAMAMOTO Takashi | fec7b15 | 2014-07-23 16:39:28 +0900 | [diff] [blame] | 36 | function _neutron_ofagent_configure_firewall_driver { | 
|  | 37 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
|  | 38 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver | 
|  | 39 | else | 
|  | 40 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver | 
|  | 41 | fi | 
|  | 42 | } | 
|  | 43 |  | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 44 | function neutron_plugin_configure_plugin_agent { | 
|  | 45 | # Set up integration bridge | 
|  | 46 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE | 
| YAMAMOTO Takashi | fec7b15 | 2014-07-23 16:39:28 +0900 | [diff] [blame] | 47 | _neutron_ofagent_configure_firewall_driver | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 48 |  | 
|  | 49 | # Check a supported openflow version | 
|  | 50 | OF_VERSION=`ovs-ofctl --version | grep "OpenFlow versions" | awk '{print $3}' | cut -d':' -f2` | 
|  | 51 | if [ `vercmp_numbers "$OF_VERSION" "0x3"` -lt "0" ]; then | 
|  | 52 | die $LINENO "This agent requires OpenFlow 1.3+ capable switch." | 
|  | 53 | fi | 
|  | 54 |  | 
|  | 55 | # Enable tunnel networks if selected | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 56 | if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 57 | # Verify tunnels are supported | 
|  | 58 | # REVISIT - also check kernel module support for GRE and patch ports | 
|  | 59 | OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"` | 
|  | 60 | if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ]; then | 
|  | 61 | die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts." | 
|  | 62 | fi | 
| Edgar Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 63 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 64 | fi | 
|  | 65 |  | 
|  | 66 | # Setup physical network bridge mappings.  Override | 
|  | 67 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more | 
|  | 68 | # complex physical network configurations. | 
| Kyle Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 69 | if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 70 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE | 
|  | 71 |  | 
|  | 72 | # Configure bridge manually with physical interface as port for multi-node | 
|  | 73 | sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE | 
|  | 74 | fi | 
|  | 75 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then | 
|  | 76 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS | 
|  | 77 | fi | 
| YAMAMOTO Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 78 | if [[ "$OFAGENT_PHYSICAL_INTERFACE_MAPPINGS" != "" ]]; then | 
|  | 79 | iniset /$Q_PLUGIN_CONF_FILE agent physical_interface_mappings \ | 
|  | 80 | $OFAGENT_PHYSICAL_INTERFACE_MAPPINGS | 
|  | 81 | fi | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 82 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ofagent-agent" | 
|  | 83 |  | 
| Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 84 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES | 
| fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 85 | # Define extra "AGENT" configuration options when q-agt is configured by defining | 
|  | 86 | # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``. | 
|  | 87 | # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)`` | 
|  | 88 | for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do | 
|  | 89 | # Replace the first '=' with ' ' for iniset syntax | 
|  | 90 | iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ } | 
|  | 91 | done | 
|  | 92 | } | 
|  | 93 |  | 
|  | 94 | function neutron_plugin_setup_interface_driver { | 
|  | 95 | local conf_file=$1 | 
|  | 96 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver | 
|  | 97 | iniset $conf_file DEFAULT ovs_use_veth True | 
|  | 98 | } | 
|  | 99 |  | 
|  | 100 | function neutron_plugin_check_adv_test_requirements { | 
|  | 101 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 105 | $OFA_XTRACE |