Neutron NEC plugin support is configured using DevStack external
plugin mechanism. The following needs to be added in local.conf:
Q_PLUGIN=nec
enable_plugin networking-nec https://git.openstack.org/stackforge/networking-nec
Also removes lib/neutron_thirdparty/trema and files/debs/trema.
DevStack external plugin for Trema Sliceable Switch is available
and the following is needed to enable it in DevStack.
enable_plugin trema-devstack-plugin https://github.com/nec-openstack/trema-devstack-plugin
Change-Id: If983b986355fcc0118b6e0446b3b295f23b3c40e
| ... | ... |
@@ -1,131 +1,10 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 |
-# |
|
| 3 |
-# Neutron NEC OpenFlow plugin |
|
| 4 |
-# --------------------------- |
|
| 5 | 2 |
|
| 6 |
-# Save trace setting |
|
| 7 |
-NEC_XTRACE=$(set +o | grep xtrace) |
|
| 8 |
-set +o xtrace |
|
| 9 |
- |
|
| 10 |
-# Configuration parameters |
|
| 11 |
-OFC_HOST=${OFC_HOST:-127.0.0.1}
|
|
| 12 |
-OFC_PORT=${OFC_PORT:-8888}
|
|
| 13 |
- |
|
| 14 |
-OFC_API_HOST=${OFC_API_HOST:-$OFC_HOST}
|
|
| 15 |
-OFC_API_PORT=${OFC_API_PORT:-$OFC_PORT}
|
|
| 16 |
-OFC_OFP_HOST=${OFC_OFP_HOST:-$OFC_HOST}
|
|
| 17 |
-OFC_OFP_PORT=${OFC_OFP_PORT:-6633}
|
|
| 18 |
-OFC_DRIVER=${OFC_DRIVER:-trema}
|
|
| 19 |
-OFC_RETRY_MAX=${OFC_RETRY_MAX:-0}
|
|
| 20 |
-OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1}
|
|
| 21 |
- |
|
| 22 |
-# Main logic |
|
| 23 |
-# --------------------------- |
|
| 24 |
- |
|
| 25 |
-source $TOP_DIR/lib/neutron_plugins/ovs_base |
|
| 26 |
- |
|
| 27 |
-function neutron_plugin_create_nova_conf {
|
|
| 28 |
- _neutron_ovs_base_configure_nova_vif_driver |
|
| 29 |
-} |
|
| 30 |
- |
|
| 31 |
-function neutron_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 |
- _neutron_ovs_base_install_agent_packages |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-function neutron_plugin_configure_common {
|
|
| 42 |
- Q_PLUGIN_CONF_PATH=etc/neutron/plugins/nec |
|
| 43 |
- Q_PLUGIN_CONF_FILENAME=nec.ini |
|
| 44 |
- Q_PLUGIN_CLASS="neutron.plugins.nec.nec_plugin.NECPluginV2" |
|
| 45 |
-} |
|
| 46 |
- |
|
| 47 |
-function neutron_plugin_configure_debug_command {
|
|
| 48 |
- _neutron_ovs_base_configure_debug_command |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-function neutron_plugin_configure_dhcp_agent {
|
|
| 52 |
- : |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-function neutron_plugin_configure_l3_agent {
|
|
| 56 |
- _neutron_ovs_base_configure_l3_agent |
|
| 57 |
-} |
|
| 58 |
- |
|
| 59 |
-function _quantum_plugin_setup_bridge {
|
|
| 60 |
- if [[ "$SKIP_OVS_BRIDGE_SETUP" = "True" ]]; then |
|
| 61 |
- return |
|
| 62 |
- fi |
|
| 63 |
- # Set up integration bridge |
|
| 64 |
- _neutron_ovs_base_setup_bridge $OVS_BRIDGE |
|
| 65 |
- # Generate datapath ID from HOST_IP |
|
| 66 |
- local dpid=$(printf "%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 |
- sudo ovs-vsctl --no-wait set-controller $OVS_BRIDGE tcp:$OFC_OFP_HOST:$OFC_OFP_PORT |
|
| 70 |
- if [ -n "$OVS_INTERFACE" ]; then |
|
| 71 |
- sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $OVS_INTERFACE |
|
| 72 |
- fi |
|
| 73 |
- _neutron_setup_ovs_tunnels $OVS_BRIDGE |
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 |
-function neutron_plugin_configure_plugin_agent {
|
|
| 77 |
- _quantum_plugin_setup_bridge |
|
| 78 |
- |
|
| 79 |
- AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-nec-agent" |
|
| 80 |
- |
|
| 81 |
- _neutron_ovs_base_configure_firewall_driver |
|
| 82 |
-} |
|
| 83 |
- |
|
| 84 |
-function neutron_plugin_configure_service {
|
|
| 85 |
- iniset $NEUTRON_CONF DEFAULT api_extensions_path neutron/plugins/nec/extensions/ |
|
| 86 |
- 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 |
|
| 91 |
- |
|
| 92 |
- _neutron_ovs_base_configure_firewall_driver |
|
| 93 |
-} |
|
| 94 |
- |
|
| 95 |
-function neutron_plugin_setup_interface_driver {
|
|
| 96 |
- local conf_file=$1 |
|
| 97 |
- iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver |
|
| 98 |
- iniset $conf_file DEFAULT ovs_use_veth True |
|
| 99 |
-} |
|
| 100 |
- |
|
| 101 |
-# Utility functions |
|
| 102 |
-# --------------------------- |
|
| 103 |
- |
|
| 104 |
-# Setup OVS tunnel manually |
|
| 105 |
-function _neutron_setup_ovs_tunnels {
|
|
| 106 |
- local bridge=$1 |
|
| 107 |
- local id=0 |
|
| 108 |
- GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
|
|
| 109 |
- if [ -n "$GRE_REMOTE_IPS" ]; then |
|
| 110 |
- for ip in ${GRE_REMOTE_IPS//:/ }; do
|
|
| 111 |
- 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 |
|
| 118 |
- fi |
|
| 119 |
-} |
|
| 3 |
+# This file is needed so Q_PLUGIN=nec will work. |
|
| 120 | 4 |
|
| 5 |
+# FIXME(amotoki): This function should not be here, but unfortunately |
|
| 6 |
+# devstack calls it before the external plugins are fetched |
|
| 121 | 7 |
function has_neutron_plugin_security_group {
|
| 122 | 8 |
# 0 means True here |
| 123 | 9 |
return 0 |
| 124 | 10 |
} |
| 125 |
- |
|
| 126 |
-function neutron_plugin_check_adv_test_requirements {
|
|
| 127 |
- is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-# Restore xtrace |
|
| 131 |
-$NEC_XTRACE |
| 132 | 11 |
deleted file mode 100644 |
| ... | ... |
@@ -1,119 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-# |
|
| 3 |
-# Trema Sliceable Switch |
|
| 4 |
-# ---------------------- |
|
| 5 |
- |
|
| 6 |
-# Trema is a Full-Stack OpenFlow Framework in Ruby and C |
|
| 7 |
-# https://github.com/trema/trema |
|
| 8 |
-# |
|
| 9 |
-# Trema Sliceable Switch is an OpenFlow controller which provides |
|
| 10 |
-# virtual layer-2 network slices. |
|
| 11 |
-# https://github.com/trema/apps/wiki |
|
| 12 |
- |
|
| 13 |
-# Trema Sliceable Switch (OpenFlow Controller) |
|
| 14 |
-TREMA_APPS_REPO=${TREMA_APPS_REPO:-https://github.com/trema/apps.git}
|
|
| 15 |
-TREMA_APPS_BRANCH=${TREMA_APPS_BRANCH:-master}
|
|
| 16 |
- |
|
| 17 |
-# Save trace setting |
|
| 18 |
-TREMA3_XTRACE=$(set +o | grep xtrace) |
|
| 19 |
-set +o xtrace |
|
| 20 |
- |
|
| 21 |
-TREMA_DIR=${TREMA_DIR:-$DEST/trema}
|
|
| 22 |
-TREMA_SS_DIR="$TREMA_DIR/apps/sliceable_switch" |
|
| 23 |
- |
|
| 24 |
-TREMA_DATA_DIR=${TREMA_DATA_DIR:-$DATA_DIR/trema}
|
|
| 25 |
-TREMA_SS_ETC_DIR=$TREMA_DATA_DIR/sliceable_switch/etc |
|
| 26 |
-TREMA_SS_DB_DIR=$TREMA_DATA_DIR/sliceable_switch/db |
|
| 27 |
-TREMA_SS_SCRIPT_DIR=$TREMA_DATA_DIR/sliceable_switch/script |
|
| 28 |
-TREMA_TMP_DIR=$TREMA_DATA_DIR/trema |
|
| 29 |
- |
|
| 30 |
-TREMA_LOG_LEVEL=${TREMA_LOG_LEVEL:-info}
|
|
| 31 |
- |
|
| 32 |
-TREMA_SS_CONFIG=$TREMA_SS_ETC_DIR/sliceable.conf |
|
| 33 |
-TREMA_SS_APACHE_CONFIG=$(apache_site_config_for sliceable_switch) |
|
| 34 |
- |
|
| 35 |
-# configure_trema - Set config files, create data dirs, etc |
|
| 36 |
-function configure_trema {
|
|
| 37 |
- # prepare dir |
|
| 38 |
- for d in $TREMA_SS_ETC_DIR $TREMA_SS_DB_DIR $TREMA_SS_SCRIPT_DIR; do |
|
| 39 |
- sudo mkdir -p $d |
|
| 40 |
- sudo chown -R `whoami` $d |
|
| 41 |
- done |
|
| 42 |
- sudo mkdir -p $TREMA_TMP_DIR |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-# init_trema - Initialize databases, etc. |
|
| 46 |
-function init_trema {
|
|
| 47 |
- local _pwd=$(pwd) |
|
| 48 |
- |
|
| 49 |
- # Initialize databases for Sliceable Switch |
|
| 50 |
- cd $TREMA_SS_DIR |
|
| 51 |
- rm -f filter.db slice.db |
|
| 52 |
- ./create_tables.sh |
|
| 53 |
- mv filter.db slice.db $TREMA_SS_DB_DIR |
|
| 54 |
- # Make sure that apache cgi has write access to the databases |
|
| 55 |
- sudo chown -R www-data.www-data $TREMA_SS_DB_DIR |
|
| 56 |
- cd $_pwd |
|
| 57 |
- |
|
| 58 |
- # Setup HTTP Server for sliceable_switch |
|
| 59 |
- cp $TREMA_SS_DIR/{Slice.pm,Filter.pm,config.cgi} $TREMA_SS_SCRIPT_DIR
|
|
| 60 |
- sed -i -e "s|/home/sliceable_switch/db|$TREMA_SS_DB_DIR|" \ |
|
| 61 |
- $TREMA_SS_SCRIPT_DIR/config.cgi |
|
| 62 |
- |
|
| 63 |
- sudo cp $TREMA_SS_DIR/apache/sliceable_switch $TREMA_SS_APACHE_CONFIG |
|
| 64 |
- sudo sed -i -e "s|/home/sliceable_switch/script|$TREMA_SS_SCRIPT_DIR|" \ |
|
| 65 |
- $TREMA_SS_APACHE_CONFIG |
|
| 66 |
- # TODO(gabriel-bezerra): use some function from lib/apache to enable these modules |
|
| 67 |
- sudo a2enmod rewrite actions |
|
| 68 |
- enable_apache_site sliceable_switch |
|
| 69 |
- |
|
| 70 |
- cp $TREMA_SS_DIR/sliceable_switch_null.conf $TREMA_SS_CONFIG |
|
| 71 |
- sed -i -e "s|^\$apps_dir.*$|\$apps_dir = \"$TREMA_DIR/apps\"|" \ |
|
| 72 |
- -e "s|^\$db_dir.*$|\$db_dir = \"$TREMA_SS_DB_DIR\"|" \ |
|
| 73 |
- $TREMA_SS_CONFIG |
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 |
-function gem_install {
|
|
| 77 |
- [[ "$OFFLINE" = "True" ]] && return |
|
| 78 |
- [ -n "$RUBYGEMS_CMD" ] || get_gem_command |
|
| 79 |
- |
|
| 80 |
- local pkg=$1 |
|
| 81 |
- $RUBYGEMS_CMD list | grep "^${pkg} " && return
|
|
| 82 |
- sudo $RUBYGEMS_CMD install $pkg |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-function get_gem_command {
|
|
| 86 |
- # Trema requires ruby 1.8, so gem1.8 is checked first |
|
| 87 |
- RUBYGEMS_CMD=$(which gem1.8 || which gem) |
|
| 88 |
- if [ -z "$RUBYGEMS_CMD" ]; then |
|
| 89 |
- echo "Warning: ruby gems command not found." |
|
| 90 |
- fi |
|
| 91 |
-} |
|
| 92 |
- |
|
| 93 |
-function install_trema {
|
|
| 94 |
- # Trema |
|
| 95 |
- gem_install trema |
|
| 96 |
- # Sliceable Switch |
|
| 97 |
- git_clone $TREMA_APPS_REPO $TREMA_DIR/apps $TREMA_APPS_BRANCH |
|
| 98 |
- make -C $TREMA_DIR/apps/topology |
|
| 99 |
- make -C $TREMA_DIR/apps/flow_manager |
|
| 100 |
- make -C $TREMA_DIR/apps/sliceable_switch |
|
| 101 |
-} |
|
| 102 |
- |
|
| 103 |
-function start_trema {
|
|
| 104 |
- restart_apache_server |
|
| 105 |
- |
|
| 106 |
- sudo LOGGING_LEVEL=$TREMA_LOG_LEVEL TREMA_TMP=$TREMA_TMP_DIR \ |
|
| 107 |
- trema run -d -c $TREMA_SS_CONFIG |
|
| 108 |
-} |
|
| 109 |
- |
|
| 110 |
-function stop_trema {
|
|
| 111 |
- sudo TREMA_TMP=$TREMA_TMP_DIR trema killall |
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 |
-function check_trema {
|
|
| 115 |
- : |
|
| 116 |
-} |
|
| 117 |
- |
|
| 118 |
-# Restore xtrace |
|
| 119 |
-$TREMA3_XTRACE |