blob: 1cb2fef5330089a37a748ee577990ae4160ea741 [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
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090058function _quantum_plugin_setup_bridge() {
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 # Generate datapath ID from HOST_IP
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090065 local dpid=$(printf "%07d%03d%03d%03d\n" ${HOST_IP//./ })
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090066 sudo ovs-vsctl --no-wait set Bridge $OVS_BRIDGE other-config:datapath-id=$dpid
67 sudo ovs-vsctl --no-wait set-fail-mode $OVS_BRIDGE secure
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090068 sudo ovs-vsctl --no-wait set-controller $OVS_BRIDGE tcp:$OFC_OFP_HOST:$OFC_OFP_PORT
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090069 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
Akihiro MOTOKI7a4ae3d2013-10-10 00:40:38 +090073}
74
75function neutron_plugin_configure_plugin_agent() {
76 _quantum_plugin_setup_bridge
77
Mark McClainb05c8762013-07-06 23:29:39 -040078 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-nec-agent"
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090079
Mark McClainb05c8762013-07-06 23:29:39 -040080 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090081}
82
Mark McClainb05c8762013-07-06 23:29:39 -040083function neutron_plugin_configure_service() {
84 iniset $NEUTRON_CONF DEFAULT api_extensions_path neutron/plugins/nec/extensions/
Gary Kottond42634f2013-06-24 09:26:55 +000085 iniset /$Q_PLUGIN_CONF_FILE ofc host $OFC_API_HOST
86 iniset /$Q_PLUGIN_CONF_FILE ofc port $OFC_API_PORT
87 iniset /$Q_PLUGIN_CONF_FILE ofc driver $OFC_DRIVER
88 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_max OFC_RETRY_MAX
89 iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_interval OFC_RETRY_INTERVAL
Jiajun Liue6f2ee52013-05-14 09:48:15 +000090
Mark McClainb05c8762013-07-06 23:29:39 -040091 _neutron_ovs_base_configure_firewall_driver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090092}
93
Mark McClainb05c8762013-07-06 23:29:39 -040094function neutron_plugin_setup_interface_driver() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090095 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -040096 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +090097 iniset $conf_file DEFAULT ovs_use_veth True
98}
99
100# Utility functions
101# ---------------------------
102
103# Setup OVS tunnel manually
Mark McClainb05c8762013-07-06 23:29:39 -0400104function _neutron_setup_ovs_tunnels() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900105 local bridge=$1
106 local id=0
107 GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
108 if [ -n "$GRE_REMOTE_IPS" ]; then
Sean Dague16dd8b32014-02-03 09:10:54 +0900109 for ip in ${GRE_REMOTE_IPS//:/ }; do
Sean Dague3bdb9222013-10-22 08:36:16 -0400110 if [[ "$ip" == "$GRE_LOCAL_IP" ]]; then
111 continue
112 fi
113 sudo ovs-vsctl --no-wait add-port $bridge gre$id -- \
114 set Interface gre$id type=gre options:remote_ip=$ip
115 id=`expr $id + 1`
116 done
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900117 fi
118}
119
Mark McClainb05c8762013-07-06 23:29:39 -0400120function has_neutron_plugin_security_group() {
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900121 # 0 means True here
122 return 0
123}
124
Mark McClainb05c8762013-07-06 23:29:39 -0400125function neutron_plugin_check_adv_test_requirements() {
armando-migliaccio7c025fe2013-05-08 11:33:07 -0700126 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
127}
128
Akihiro MOTOKIf85fa082013-01-13 05:01:08 +0900129# Restore xtrace
130$MY_XTRACE