fumihiko kakuma | 5a110d4 | 2014-01-29 14:42:06 +0900 | [diff] [blame^] | 1 | # OpenFlow Agent plugin |
| 2 | # ---------------------- |
| 3 | |
| 4 | # Save trace setting |
| 5 | MY_XTRACE=$(set +o | grep xtrace) |
| 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 |
| 21 | configure_ryu |
| 22 | } |
| 23 | |
| 24 | function neutron_plugin_configure_debug_command { |
| 25 | _neutron_ovs_base_configure_debug_command |
| 26 | } |
| 27 | |
| 28 | function neutron_plugin_configure_dhcp_agent { |
| 29 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport |
| 30 | } |
| 31 | |
| 32 | function 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 | |
| 37 | function neutron_plugin_configure_plugin_agent { |
| 38 | # Set up integration bridge |
| 39 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE |
| 40 | _neutron_ovs_base_configure_firewall_driver |
| 41 | |
| 42 | # Check a supported openflow version |
| 43 | OF_VERSION=`ovs-ofctl --version | grep "OpenFlow versions" | awk '{print $3}' | cut -d':' -f2` |
| 44 | if [ `vercmp_numbers "$OF_VERSION" "0x3"` -lt "0" ]; then |
| 45 | die $LINENO "This agent requires OpenFlow 1.3+ capable switch." |
| 46 | fi |
| 47 | |
| 48 | # Enable tunnel networks if selected |
| 49 | if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then |
| 50 | # Verify tunnels are supported |
| 51 | # REVISIT - also check kernel module support for GRE and patch ports |
| 52 | OVS_VERSION=`ovs-vsctl --version | head -n 1 | grep -E -o "[0-9]+\.[0-9]+"` |
| 53 | if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ]; then |
| 54 | die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts." |
| 55 | fi |
| 56 | iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True |
| 57 | iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP |
| 58 | fi |
| 59 | |
| 60 | # Setup physical network bridge mappings. Override |
| 61 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more |
| 62 | # complex physical network configurations. |
| 63 | if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then |
| 64 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE |
| 65 | |
| 66 | # Configure bridge manually with physical interface as port for multi-node |
| 67 | sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE |
| 68 | fi |
| 69 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then |
| 70 | iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS |
| 71 | fi |
| 72 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ofagent-agent" |
| 73 | |
| 74 | # Define extra "AGENT" configuration options when q-agt is configured by defining |
| 75 | # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``. |
| 76 | # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)`` |
| 77 | for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do |
| 78 | # Replace the first '=' with ' ' for iniset syntax |
| 79 | iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ } |
| 80 | done |
| 81 | } |
| 82 | |
| 83 | function neutron_plugin_setup_interface_driver { |
| 84 | local conf_file=$1 |
| 85 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver |
| 86 | iniset $conf_file DEFAULT ovs_use_veth True |
| 87 | } |
| 88 | |
| 89 | function neutron_plugin_check_adv_test_requirements { |
| 90 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
| 91 | } |
| 92 | |
| 93 | # Restore xtrace |
| 94 | $MY_XTRACE |