blob: 3806c32c7549647cf74e339f8b43deecb36f64d1 [file] [log] [blame]
Mark McClainb05c8762013-07-06 23:29:39 -04001# Neutron NEC OpenFlow plugin
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +09002# ---------------------------
3
4# Save trace setting
5MY_XTRACE=$(set +o | grep xtrace)
6set +o xtrace
7
8# Configuration parameters
9OFC_HOST=${OFC_HOST:-127.0.0.1}
10OFC_PORT=${OFC_PORT:-8888}
11
12OFC_API_HOST=${OFC_API_HOST:-$OFC_HOST}
13OFC_API_PORT=${OFC_API_PORT:-$OFC_PORT}
14OFC_OFP_HOST=${OFC_OFP_HOST:-$OFC_HOST}
15OFC_OFP_PORT=${OFC_OFP_PORT:-6633}
16OFC_DRIVER=${OFC_DRIVER:-trema}
17OFC_RETRY_MAX=${OFC_RETRY_MAX:-0}
18OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1}
19
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090020# Main logic
21# ---------------------------
22
Mark McClainb05c8762013-07-06 23:29:39 -040023source $TOP_DIR/lib/neutron_plugins/ovs_base
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090024
Mark McClainb05c8762013-07-06 23:29:39 -040025function neutron_plugin_create_nova_conf() {
26 _neutron_ovs_base_configure_nova_vif_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090027}
28
Mark McClainb05c8762013-07-06 23:29:39 -040029function neutron_plugin_install_agent_packages() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090030 # SKIP_OVS_INSTALL is useful when we want to use Open vSwitch whose
31 # version is different from the version provided by the distribution.
32 if [[ "$SKIP_OVS_INSTALL" = "True" ]]; then
33 echo "You need to install Open vSwitch manually."
34 return
35 fi
Mark McClainb05c8762013-07-06 23:29:39 -040036 _neutron_ovs_base_install_agent_packages
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090037}
38
Mark McClainb05c8762013-07-06 23:29:39 -040039function neutron_plugin_configure_common() {
40 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/nec
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090041 Q_PLUGIN_CONF_FILENAME=nec.ini
Mark McClainb05c8762013-07-06 23:29:39 -040042 Q_DB_NAME="neutron_nec"
43 Q_PLUGIN_CLASS="neutron.plugins.nec.nec_plugin.NECPluginV2"
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090044}
45
Mark McClainb05c8762013-07-06 23:29:39 -040046function neutron_plugin_configure_debug_command() {
47 _neutron_ovs_base_configure_debug_command
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090048}
49
Mark McClainb05c8762013-07-06 23:29:39 -040050function neutron_plugin_configure_dhcp_agent() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090051 :
52}
53
Mark McClainb05c8762013-07-06 23:29:39 -040054function neutron_plugin_configure_l3_agent() {
55 _neutron_ovs_base_configure_l3_agent
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090056}
57
Mark McClainb05c8762013-07-06 23:29:39 -040058function neutron_plugin_configure_plugin_agent() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090059 if [[ "$SKIP_OVS_BRIDGE_SETUP" = "True" ]]; then
60 return
61 fi
62 # Set up integration bridge
Mark McClainb05c8762013-07-06 23:29:39 -040063 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090064 sudo ovs-vsctl --no-wait set-controller $OVS_BRIDGE tcp:$OFC_OFP_HOST:$OFC_OFP_PORT
65 # Generate datapath ID from HOST_IP
66 local dpid=$(printf "0x%07d%03d%03d%03d\n" ${HOST_IP//./ })
67 sudo ovs-vsctl --no-wait set Bridge $OVS_BRIDGE other-config:datapath-id=$dpid
68 sudo ovs-vsctl --no-wait set-fail-mode $OVS_BRIDGE secure
69 if [ -n "$OVS_INTERFACE" ]; then
70 sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $OVS_INTERFACE
71 fi
Mark McClainb05c8762013-07-06 23:29:39 -040072 _neutron_setup_ovs_tunnels $OVS_BRIDGE
73 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-nec-agent"
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090074
Mark McClainb05c8762013-07-06 23:29:39 -040075 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090076}
77
Mark McClainb05c8762013-07-06 23:29:39 -040078function neutron_plugin_configure_service() {
79 iniset $NEUTRON_CONF DEFAULT api_extensions_path neutron/plugins/nec/extensions/
Gary Kottond42634f2013-06-24 09:26:55 +000080 iniset /$Q_PLUGIN_CONF_FILE ofc host $OFC_API_HOST
81 iniset /$Q_PLUGIN_CONF_FILE ofc port $OFC_API_PORT
82 iniset /$Q_PLUGIN_CONF_FILE ofc driver $OFC_DRIVER
83 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_max OFC_RETRY_MAX
84 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_interval OFC_RETRY_INTERVAL
Jiajun Liue6f2ee52013-05-14 09:48:15 +000085
Mark McClainb05c8762013-07-06 23:29:39 -040086 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090087}
88
Mark McClainb05c8762013-07-06 23:29:39 -040089function neutron_plugin_setup_interface_driver() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090090 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -040091 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090092 iniset $conf_file DEFAULT ovs_use_veth True
93}
94
95# Utility functions
96# ---------------------------
97
98# Setup OVS tunnel manually
Mark McClainb05c8762013-07-06 23:29:39 -040099function _neutron_setup_ovs_tunnels() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900100 local bridge=$1
101 local id=0
102 GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
103 if [ -n "$GRE_REMOTE_IPS" ]; then
Sean Dague3bdb9222013-10-22 08:36:16 -0400104 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
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900113 fi
114}
115
Mark McClainb05c8762013-07-06 23:29:39 -0400116function has_neutron_plugin_security_group() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900117 # 0 means True here
118 return 0
119}
120
Mark McClainb05c8762013-07-06 23:29:39 -0400121function neutron_plugin_check_adv_test_requirements() {
armando-migliaccio7c025fe2013-05-08 11:33:07 -0700122 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
123}
124
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900125# Restore xtrace
126$MY_XTRACE