Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 3 | # OpenFlow Agent plugin |
| 4 | # ---------------------- |
| 5 | |
| 6 | # Save trace setting |
Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 7 | OFA_XTRACE=$(set +o | grep xtrace) |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 8 | set +o xtrace |
| 9 | |
| 10 | source $TOP_DIR/lib/neutron_plugins/ovs_base |
| 11 | source $TOP_DIR/lib/neutron_thirdparty/ryu # for RYU_DIR, install_ryu, etc |
| 12 | |
| 13 | function neutron_plugin_create_nova_conf { |
| 14 | _neutron_ovs_base_configure_nova_vif_driver |
| 15 | } |
| 16 | |
| 17 | function 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 kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | function neutron_plugin_configure_debug_command { |
| 26 | _neutron_ovs_base_configure_debug_command |
| 27 | } |
| 28 | |
| 29 | function neutron_plugin_configure_dhcp_agent { |
| 30 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport |
| 31 | } |
| 32 | |
| 33 | function 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 Takashi | fec7b15 | 2014-07-23 16:39:28 +0900 | [diff] [blame] | 38 | function _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 kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 46 | function neutron_plugin_configure_plugin_agent { |
| 47 | # Set up integration bridge |
| 48 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE |
YAMAMOTO Takashi | fec7b15 | 2014-07-23 16:39:28 +0900 | [diff] [blame] | 49 | _neutron_ofagent_configure_firewall_driver |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 50 | |
| 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 Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 58 | if [[ "$OVS_ENABLE_TUNNELING" == "True" ]]; then |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 59 | # 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 Magana | 6f335b9 | 2014-07-10 15:42:44 -0700 | [diff] [blame] | 65 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $TUNNEL_ENDPOINT_IP |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 66 | 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 Mestery | bd08550 | 2014-04-30 23:50:29 +0000 | [diff] [blame] | 71 | if [[ "$OVS_BRIDGE_MAPPINGS" == "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 72 | 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 Takashi | 0f18c23 | 2014-09-12 23:44:58 +0900 | [diff] [blame] | 80 | if [[ "$OFAGENT_PHYSICAL_INTERFACE_MAPPINGS" != "" ]]; then |
| 81 | iniset /$Q_PLUGIN_CONF_FILE agent physical_interface_mappings \ |
| 82 | $OFAGENT_PHYSICAL_INTERFACE_MAPPINGS |
| 83 | fi |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 84 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ofagent-agent" |
| 85 | |
Akihiro Motoki | 2307f9d | 2014-08-09 18:58:20 +0900 | [diff] [blame] | 86 | iniset /$Q_PLUGIN_CONF_FILE agent tunnel_types $Q_TUNNEL_TYPES |
fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | function neutron_plugin_setup_interface_driver { |
| 90 | local conf_file=$1 |
| 91 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver |
| 92 | iniset $conf_file DEFAULT ovs_use_veth True |
| 93 | } |
| 94 | |
| 95 | function neutron_plugin_check_adv_test_requirements { |
| 96 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
| 97 | } |
| 98 | |
| 99 | # Restore xtrace |
Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 100 | $OFA_XTRACE |