Akihiro MOTOKI | f85fa08 | 2013-01-13 05:01:08 +0900 | [diff] [blame^] | 1 | # Quantum NEC OpenFlow plugin |
| 2 | # --------------------------- |
| 3 | |
| 4 | # Save trace setting |
| 5 | MY_XTRACE=$(set +o | grep xtrace) |
| 6 | set +o xtrace |
| 7 | |
| 8 | # Configuration parameters |
| 9 | OFC_HOST=${OFC_HOST:-127.0.0.1} |
| 10 | OFC_PORT=${OFC_PORT:-8888} |
| 11 | |
| 12 | OFC_API_HOST=${OFC_API_HOST:-$OFC_HOST} |
| 13 | OFC_API_PORT=${OFC_API_PORT:-$OFC_PORT} |
| 14 | OFC_OFP_HOST=${OFC_OFP_HOST:-$OFC_HOST} |
| 15 | OFC_OFP_PORT=${OFC_OFP_PORT:-6633} |
| 16 | OFC_DRIVER=${OFC_DRIVER:-trema} |
| 17 | OFC_RETRY_MAX=${OFC_RETRY_MAX:-0} |
| 18 | OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1} |
| 19 | |
| 20 | OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
| 21 | |
| 22 | # Main logic |
| 23 | # --------------------------- |
| 24 | |
| 25 | source $TOP_DIR/lib/quantum_plugins/ovs_base |
| 26 | |
| 27 | function quantum_plugin_create_nova_conf() { |
| 28 | _quantum_ovs_base_configure_nova_vif_driver |
| 29 | } |
| 30 | |
| 31 | function quantum_plugin_install_agent_packages() { |
| 32 | # SKIP_OVS_INSTALL is useful when we want to use Open vSwitch whose |
| 33 | # version is different from the version provided by the distribution. |
| 34 | if [[ "$SKIP_OVS_INSTALL" = "True" ]]; then |
| 35 | echo "You need to install Open vSwitch manually." |
| 36 | return |
| 37 | fi |
| 38 | _quantum_ovs_base_install_agent_packages |
| 39 | } |
| 40 | |
| 41 | function quantum_plugin_configure_common() { |
| 42 | Q_PLUGIN_CONF_PATH=etc/quantum/plugins/nec |
| 43 | Q_PLUGIN_CONF_FILENAME=nec.ini |
| 44 | Q_DB_NAME="quantum_nec" |
| 45 | Q_PLUGIN_CLASS="quantum.plugins.nec.nec_plugin.NECPluginV2" |
| 46 | } |
| 47 | |
| 48 | function quantum_plugin_configure_debug_command() { |
| 49 | _quantum_ovs_base_configure_debug_command |
| 50 | } |
| 51 | |
| 52 | function quantum_plugin_configure_dhcp_agent() { |
| 53 | : |
| 54 | } |
| 55 | |
| 56 | function quantum_plugin_configure_l3_agent() { |
| 57 | _quantum_ovs_base_configure_l3_agent |
| 58 | } |
| 59 | |
| 60 | function quantum_plugin_configure_plugin_agent() { |
| 61 | if [[ "$SKIP_OVS_BRIDGE_SETUP" = "True" ]]; then |
| 62 | return |
| 63 | fi |
| 64 | # Set up integration bridge |
| 65 | _quantum_ovs_base_setup_bridge $OVS_BRIDGE |
| 66 | sudo ovs-vsctl --no-wait set-controller $OVS_BRIDGE tcp:$OFC_OFP_HOST:$OFC_OFP_PORT |
| 67 | # Generate datapath ID from HOST_IP |
| 68 | local dpid=$(printf "0x%07d%03d%03d%03d\n" ${HOST_IP//./ }) |
| 69 | sudo ovs-vsctl --no-wait set Bridge $OVS_BRIDGE other-config:datapath-id=$dpid |
| 70 | sudo ovs-vsctl --no-wait set-fail-mode $OVS_BRIDGE secure |
| 71 | if [ -n "$OVS_INTERFACE" ]; then |
| 72 | sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $OVS_INTERFACE |
| 73 | fi |
| 74 | _quantum_setup_ovs_tunnels $OVS_BRIDGE |
| 75 | AGENT_BINARY="$QUANTUM_DIR/bin/quantum-nec-agent" |
| 76 | |
| 77 | _quantum_ovs_base_configure_firewall_driver |
| 78 | } |
| 79 | |
| 80 | function quantum_plugin_configure_service() { |
| 81 | iniset $QUANTUM_CONF DEFAULT api_extensions_path quantum/plugins/nec/extensions/ |
| 82 | iniset /$Q_PLUGIN_CONF_FILE OFC host $OFC_API_HOST |
| 83 | iniset /$Q_PLUGIN_CONF_FILE OFC port $OFC_API_PORT |
| 84 | iniset /$Q_PLUGIN_CONF_FILE OFC driver $OFC_DRIVER |
| 85 | iniset /$Q_PLUGIN_CONF_FILE OFC api_retry_max OFC_RETRY_MAX |
| 86 | iniset /$Q_PLUGIN_CONF_FILE OFC api_retry_interval OFC_RETRY_INTERVAL |
| 87 | } |
| 88 | |
| 89 | function quantum_plugin_setup_interface_driver() { |
| 90 | local conf_file=$1 |
| 91 | iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver |
| 92 | iniset $conf_file DEFAULT ovs_use_veth True |
| 93 | } |
| 94 | |
| 95 | # Utility functions |
| 96 | # --------------------------- |
| 97 | |
| 98 | # Setup OVS tunnel manually |
| 99 | function _quantum_setup_ovs_tunnels() { |
| 100 | local bridge=$1 |
| 101 | local id=0 |
| 102 | GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP} |
| 103 | if [ -n "$GRE_REMOTE_IPS" ]; then |
| 104 | for ip in ${GRE_REMOTE_IPS//:/ } |
| 105 | do |
| 106 | if [[ "$ip" == "$GRE_LOCAL_IP" ]]; then |
| 107 | continue |
| 108 | fi |
| 109 | sudo ovs-vsctl --no-wait add-port $bridge gre$id -- \ |
| 110 | set Interface gre$id type=gre options:remote_ip=$ip |
| 111 | id=`expr $id + 1` |
| 112 | done |
| 113 | fi |
| 114 | } |
| 115 | |
| 116 | function has_quantum_plugin_security_group() { |
| 117 | # 0 means True here |
| 118 | return 0 |
| 119 | } |
| 120 | |
| 121 | # Restore xtrace |
| 122 | $MY_XTRACE |