blob: 3b1a25716a9a5af381d143cc30a42c58510ba3f1 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mark McClainb05c8762013-07-06 23:29:39 -04003# Neutron NEC OpenFlow plugin
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +09004# ---------------------------
5
6# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05007NEC_XTRACE=$(set +o | grep xtrace)
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +09008set +o xtrace
9
10# Configuration parameters
11OFC_HOST=${OFC_HOST:-127.0.0.1}
12OFC_PORT=${OFC_PORT:-8888}
13
14OFC_API_HOST=${OFC_API_HOST:-$OFC_HOST}
15OFC_API_PORT=${OFC_API_PORT:-$OFC_PORT}
16OFC_OFP_HOST=${OFC_OFP_HOST:-$OFC_HOST}
17OFC_OFP_PORT=${OFC_OFP_PORT:-6633}
18OFC_DRIVER=${OFC_DRIVER:-trema}
19OFC_RETRY_MAX=${OFC_RETRY_MAX:-0}
20OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1}
21
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090022# Main logic
23# ---------------------------
24
Mark McClainb05c8762013-07-06 23:29:39 -040025source $TOP_DIR/lib/neutron_plugins/ovs_base
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090026
Ian Wienandaee18c72014-02-21 15:35:08 +110027function neutron_plugin_create_nova_conf {
Mark McClainb05c8762013-07-06 23:29:39 -040028 _neutron_ovs_base_configure_nova_vif_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090029}
30
Ian Wienandaee18c72014-02-21 15:35:08 +110031function neutron_plugin_install_agent_packages {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090032 # 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
Mark McClainb05c8762013-07-06 23:29:39 -040038 _neutron_ovs_base_install_agent_packages
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090039}
40
Ian Wienandaee18c72014-02-21 15:35:08 +110041function neutron_plugin_configure_common {
Mark McClainb05c8762013-07-06 23:29:39 -040042 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/nec
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090043 Q_PLUGIN_CONF_FILENAME=nec.ini
Mark McClainb05c8762013-07-06 23:29:39 -040044 Q_PLUGIN_CLASS="neutron.plugins.nec.nec_plugin.NECPluginV2"
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090045}
46
Ian Wienandaee18c72014-02-21 15:35:08 +110047function neutron_plugin_configure_debug_command {
Mark McClainb05c8762013-07-06 23:29:39 -040048 _neutron_ovs_base_configure_debug_command
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090049}
50
Ian Wienandaee18c72014-02-21 15:35:08 +110051function neutron_plugin_configure_dhcp_agent {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090052 :
53}
54
Ian Wienandaee18c72014-02-21 15:35:08 +110055function neutron_plugin_configure_l3_agent {
Mark McClainb05c8762013-07-06 23:29:39 -040056 _neutron_ovs_base_configure_l3_agent
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090057}
58
Ian Wienandaee18c72014-02-21 15:35:08 +110059function _quantum_plugin_setup_bridge {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090060 if [[ "$SKIP_OVS_BRIDGE_SETUP" = "True" ]]; then
61 return
62 fi
63 # Set up integration bridge
Mark McClainb05c8762013-07-06 23:29:39 -040064 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090065 # Generate datapath ID from HOST_IP
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090066 local dpid=$(printf "%07d%03d%03d%03d\n" ${HOST_IP//./ })
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090067 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
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090069 sudo ovs-vsctl --no-wait set-controller $OVS_BRIDGE tcp:$OFC_OFP_HOST:$OFC_OFP_PORT
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090070 if [ -n "$OVS_INTERFACE" ]; then
71 sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $OVS_INTERFACE
72 fi
Mark McClainb05c8762013-07-06 23:29:39 -040073 _neutron_setup_ovs_tunnels $OVS_BRIDGE
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090074}
75
Ian Wienandaee18c72014-02-21 15:35:08 +110076function neutron_plugin_configure_plugin_agent {
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090077 _quantum_plugin_setup_bridge
78
Mark McClainb05c8762013-07-06 23:29:39 -040079 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-nec-agent"
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090080
Mark McClainb05c8762013-07-06 23:29:39 -040081 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090082}
83
Ian Wienandaee18c72014-02-21 15:35:08 +110084function neutron_plugin_configure_service {
Mark McClainb05c8762013-07-06 23:29:39 -040085 iniset $NEUTRON_CONF DEFAULT api_extensions_path neutron/plugins/nec/extensions/
Gary Kottond42634f2013-06-24 09:26:55 +000086 iniset /$Q_PLUGIN_CONF_FILE ofc host $OFC_API_HOST
87 iniset /$Q_PLUGIN_CONF_FILE ofc port $OFC_API_PORT
88 iniset /$Q_PLUGIN_CONF_FILE ofc driver $OFC_DRIVER
89 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_max OFC_RETRY_MAX
90 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_interval OFC_RETRY_INTERVAL
Jiajun Liue6f2ee52013-05-14 09:48:15 +000091
Mark McClainb05c8762013-07-06 23:29:39 -040092 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090093}
94
Ian Wienandaee18c72014-02-21 15:35:08 +110095function neutron_plugin_setup_interface_driver {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090096 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -040097 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090098 iniset $conf_file DEFAULT ovs_use_veth True
99}
100
101# Utility functions
102# ---------------------------
103
104# Setup OVS tunnel manually
Ian Wienandaee18c72014-02-21 15:35:08 +1100105function _neutron_setup_ovs_tunnels {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900106 local bridge=$1
107 local id=0
108 GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
109 if [ -n "$GRE_REMOTE_IPS" ]; then
Sean Dague16dd8b32014-02-03 09:10:54 +0900110 for ip in ${GRE_REMOTE_IPS//:/ }; do
Sean Dague3bdb9222013-10-22 08:36:16 -0400111 if [[ "$ip" == "$GRE_LOCAL_IP" ]]; then
112 continue
113 fi
114 sudo ovs-vsctl --no-wait add-port $bridge gre$id -- \
115 set Interface gre$id type=gre options:remote_ip=$ip
116 id=`expr $id + 1`
117 done
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900118 fi
119}
120
Ian Wienandaee18c72014-02-21 15:35:08 +1100121function has_neutron_plugin_security_group {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900122 # 0 means True here
123 return 0
124}
125
Ian Wienandaee18c72014-02-21 15:35:08 +1100126function neutron_plugin_check_adv_test_requirements {
armando-migliaccio7c025fe2013-05-08 11:33:07 -0700127 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
128}
129
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900130# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500131$NEC_XTRACE