update for name change to Neutron
Note: Nova and Horizon are not updated until those projects have
migrated.
Change-Id: I256ef20e7caadd9c96e6dd908c5d8b69ca5c4aeb
diff --git a/lib/neutron_thirdparty/README.md b/lib/neutron_thirdparty/README.md
new file mode 100644
index 0000000..b289f58
--- /dev/null
+++ b/lib/neutron_thirdparty/README.md
@@ -0,0 +1,36 @@
+Neutron third party specific files
+==================================
+Some Neutron plugins require third party programs to function.
+The files under the directory, ``lib/neutron_thirdparty/``, will be used
+when their service are enabled.
+Third party program specific configuration variables should be in this file.
+
+* filename: ``<third_party>``
+ * The corresponding file name should be same to service name, ``<third_party>``.
+
+functions
+---------
+``lib/neutron`` calls the following functions when the ``<third_party>`` is enabled
+
+functions to be implemented
+* ``configure_<third_party>``:
+ set config files, create data dirs, etc
+ e.g.
+ sudo python setup.py deploy
+ iniset $XXXX_CONF...
+
+* ``init_<third_party>``:
+ initialize databases, etc
+
+* ``install_<third_party>``:
+ collect source and prepare
+ e.g.
+ git clone xxx
+
+* ``start_<third_party>``:
+ start running processes, including screen
+ e.g.
+ screen_it XXXX "cd $XXXXY_DIR && $XXXX_DIR/bin/XXXX-bin"
+
+* ``stop_<third_party>``:
+ stop running processes (non-screen)
diff --git a/lib/neutron_thirdparty/bigswitch_floodlight b/lib/neutron_thirdparty/bigswitch_floodlight
new file mode 100644
index 0000000..ebde067
--- /dev/null
+++ b/lib/neutron_thirdparty/bigswitch_floodlight
@@ -0,0 +1,49 @@
+# Big Switch/FloodLight OpenFlow Controller
+# ------------------------------------------
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80}
+BS_FL_OF_PORT=${BS_FL_OF_PORT:-6633}
+
+function configure_bigswitch_floodlight() {
+ :
+}
+
+function init_bigswitch_floodlight() {
+ install_neutron_agent_packages
+
+ echo -n "Installing OVS managed by the openflow controllers:"
+ echo ${BS_FL_CONTROLLERS_PORT}
+
+ # Create local OVS bridge and configure it
+ sudo ovs-vsctl --no-wait -- --if-exists del-br ${OVS_BRIDGE}
+ sudo ovs-vsctl --no-wait add-br ${OVS_BRIDGE}
+ sudo ovs-vsctl --no-wait br-set-external-id ${OVS_BRIDGE} bridge-id ${OVS_BRIDGE}
+
+ ctrls=
+ for ctrl in `echo ${BS_FL_CONTROLLERS_PORT} | tr ',' ' '`
+ do
+ ctrl=${ctrl%:*}
+ ctrls="${ctrls} tcp:${ctrl}:${BS_FL_OF_PORT}"
+ done
+ echo "Adding Network conttrollers: " ${ctrls}
+ sudo ovs-vsctl --no-wait set-controller ${OVS_BRIDGE} ${ctrls}
+}
+
+function install_bigswitch_floodlight() {
+ :
+}
+
+function start_bigswitch_floodlight() {
+ :
+}
+
+function stop_bigswitch_floodlight() {
+ :
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/lib/neutron_thirdparty/nicira b/lib/neutron_thirdparty/nicira
new file mode 100644
index 0000000..5a20934
--- /dev/null
+++ b/lib/neutron_thirdparty/nicira
@@ -0,0 +1,52 @@
+# Nicira NVP
+# ----------
+
+# This third-party addition can be used to configure connectivity between a DevStack instance
+# and an NVP Gateway in dev/test environments. In order to use this correctly, the following
+# env variables need to be set (e.g. in your localrc file):
+#
+# * enable_service nicira --> to execute this third-party addition
+# * PUBLIC_BRIDGE --> bridge used for external connectivity, typically br-ex
+# * NVP_GATEWAY_NETWORK_INTERFACE --> interface used to communicate with the NVP Gateway
+# * NVP_GATEWAY_NETWORK_CIDR --> CIDR to configure br-ex, e.g. 172.24.4.211/24
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+# This is the interface that connects the Devstack instance
+# to an network that allows it to talk to the gateway for
+# testing purposes
+NVP_GATEWAY_NETWORK_INTERFACE=${NVP_GATEWAY_NETWORK_INTERFACE:-eth2}
+
+function configure_nicira() {
+ :
+}
+
+function init_nicira() {
+ die_if_not_set $LINENO NVP_GATEWAY_NETWORK_CIDR "Please, specify CIDR for the gateway network interface."
+ # Make sure the interface is up, but not configured
+ sudo ifconfig $NVP_GATEWAY_NETWORK_INTERFACE up
+ sudo ip addr flush $NVP_GATEWAY_NETWORK_INTERFACE
+ # Use the PUBLIC Bridge to route traffic to the NVP gateway
+ # NOTE(armando-migliaccio): if running in a nested environment this will work
+ # only with mac learning enabled, portsecurity and security profiles disabled
+ sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_INTERFACE
+ nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
+ sudo ifconfig $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_CIDR hw ether $nvp_gw_net_if_mac
+}
+
+function install_nicira() {
+ :
+}
+
+function start_nicira() {
+ :
+}
+
+function stop_nicira() {
+ :
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/lib/neutron_thirdparty/ryu b/lib/neutron_thirdparty/ryu
new file mode 100644
index 0000000..3b825a1
--- /dev/null
+++ b/lib/neutron_thirdparty/ryu
@@ -0,0 +1,79 @@
+# Ryu OpenFlow Controller
+# -----------------------
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+
+RYU_DIR=$DEST/ryu
+# Ryu API Host
+RYU_API_HOST=${RYU_API_HOST:-127.0.0.1}
+# Ryu API Port
+RYU_API_PORT=${RYU_API_PORT:-8080}
+# Ryu OFP Host
+RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1}
+# Ryu OFP Port
+RYU_OFP_PORT=${RYU_OFP_PORT:-6633}
+# Ryu Applications
+RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest}
+
+# configure_ryu can be called multiple times as neutron_pluing/ryu may call
+# this function for neutron-ryu-agent
+_RYU_CONFIGURED=${_RYU_CONFIGURED:-False}
+function configure_ryu() {
+ if [[ "$_RYU_CONFIGURED" == "False" ]]; then
+ setup_develop $RYU_DIR
+ _RYU_CONFIGURED=True
+ fi
+}
+
+function init_ryu() {
+ RYU_CONF_DIR=/etc/ryu
+ if [[ ! -d $RYU_CONF_DIR ]]; then
+ sudo mkdir -p $RYU_CONF_DIR
+ fi
+ sudo chown $STACK_USER $RYU_CONF_DIR
+ RYU_CONF=$RYU_CONF_DIR/ryu.conf
+ sudo rm -rf $RYU_CONF
+
+ # Ryu configuration
+ RYU_CONF_CONTENTS=${RYU_CONF_CONTENTS:-"[DEFAULT]
+app_lists=$RYU_APPS
+wsapi_host=$RYU_API_HOST
+wsapi_port=$RYU_API_PORT
+ofp_listen_host=$RYU_OFP_HOST
+ofp_tcp_listen_port=$RYU_OFP_PORT
+neutron_url=http://$Q_HOST:$Q_PORT
+neutron_admin_username=$Q_ADMIN_USERNAME
+neutron_admin_password=$SERVICE_PASSWORD
+neutron_admin_tenant_name=$SERVICE_TENANT_NAME
+neutron_admin_auth_url=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0
+neutron_auth_strategy=$Q_AUTH_STRATEGY
+neutron_controller_addr=tcp:$RYU_OFP_HOST:$RYU_OFP_PORT
+"}
+ echo "${RYU_CONF_CONTENTS}" > $RYU_CONF
+}
+
+# install_ryu can be called multiple times as neutron_pluing/ryu may call
+# this function for neutron-ryu-agent
+# Make this function idempotent and avoid cloning same repo many times
+# with RECLONE=yes
+_RYU_INSTALLED=${_RYU_INSTALLED:-False}
+function install_ryu() {
+ if [[ "$_RYU_INSTALLED" == "False" ]]; then
+ git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH
+ _RYU_INSTALLED=True
+ fi
+}
+
+function start_ryu() {
+ screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --config-file $RYU_CONF"
+}
+
+function stop_ryu() {
+ :
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/lib/neutron_thirdparty/trema b/lib/neutron_thirdparty/trema
new file mode 100644
index 0000000..09dc46b
--- /dev/null
+++ b/lib/neutron_thirdparty/trema
@@ -0,0 +1,113 @@
+# Trema Sliceable Switch
+# ----------------------
+
+# Trema is a Full-Stack OpenFlow Framework in Ruby and C
+# https://github.com/trema/trema
+#
+# Trema Sliceable Switch is an OpenFlow controller which provides
+# virtual layer-2 network slices.
+# https://github.com/trema/apps/wiki
+
+# Trema Sliceable Switch (OpenFlow Controller)
+TREMA_APPS_REPO=${TREMA_APPS_REPO:-https://github.com/trema/apps.git}
+TREMA_APPS_BRANCH=${TREMA_APPS_BRANCH:-master}
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+TREMA_DIR=${TREMA_DIR:-$DEST/trema}
+TREMA_SS_DIR="$TREMA_DIR/apps/sliceable_switch"
+
+TREMA_DATA_DIR=${TREMA_DATA_DIR:-$DATA_DIR/trema}
+TREMA_SS_ETC_DIR=$TREMA_DATA_DIR/sliceable_switch/etc
+TREMA_SS_DB_DIR=$TREMA_DATA_DIR/sliceable_switch/db
+TREMA_SS_SCRIPT_DIR=$TREMA_DATA_DIR/sliceable_switch/script
+TREMA_TMP_DIR=$TREMA_DATA_DIR/trema
+
+TREMA_LOG_LEVEL=${TREMA_LOG_LEVEL:-info}
+
+TREMA_SS_CONFIG=$TREMA_SS_ETC_DIR/sliceable.conf
+TREMA_SS_APACHE_CONFIG=/etc/apache2/sites-available/sliceable_switch
+
+# configure_trema - Set config files, create data dirs, etc
+function configure_trema() {
+ # prepare dir
+ for d in $TREMA_SS_ETC_DIR $TREMA_SS_DB_DIR $TREMA_SS_SCRIPT_DIR; do
+ sudo mkdir -p $d
+ sudo chown -R `whoami` $d
+ done
+ sudo mkdir -p $TREMA_TMP_DIR
+}
+
+# init_trema - Initialize databases, etc.
+function init_trema() {
+ local _pwd=$(pwd)
+
+ # Initialize databases for Sliceable Switch
+ cd $TREMA_SS_DIR
+ rm -f filter.db slice.db
+ ./create_tables.sh
+ mv filter.db slice.db $TREMA_SS_DB_DIR
+ # Make sure that apache cgi has write access to the databases
+ sudo chown -R www-data.www-data $TREMA_SS_DB_DIR
+ cd $_pwd
+
+ # Setup HTTP Server for sliceable_switch
+ cp $TREMA_SS_DIR/{Slice.pm,Filter.pm,config.cgi} $TREMA_SS_SCRIPT_DIR
+ sed -i -e "s|/home/sliceable_switch/db|$TREMA_SS_DB_DIR|" \
+ $TREMA_SS_SCRIPT_DIR/config.cgi
+
+ sudo cp $TREMA_SS_DIR/apache/sliceable_switch $TREMA_SS_APACHE_CONFIG
+ sudo sed -i -e "s|/home/sliceable_switch/script|$TREMA_SS_SCRIPT_DIR|" \
+ $TREMA_SS_APACHE_CONFIG
+ sudo a2enmod rewrite actions
+ sudo a2ensite sliceable_switch
+
+ cp $TREMA_SS_DIR/sliceable_switch_null.conf $TREMA_SS_CONFIG
+ sed -i -e "s|^\$apps_dir.*$|\$apps_dir = \"$TREMA_DIR/apps\"|" \
+ -e "s|^\$db_dir.*$|\$db_dir = \"$TREMA_SS_DB_DIR\"|" \
+ $TREMA_SS_CONFIG
+}
+
+function gem_install() {
+ [[ "$OFFLINE" = "True" ]] && return
+ [ -n "$RUBYGEMS_CMD" ] || get_gem_command
+
+ local pkg=$1
+ $RUBYGEMS_CMD list | grep "^${pkg} " && return
+ sudo $RUBYGEMS_CMD install $pkg
+}
+
+function get_gem_command() {
+ # Trema requires ruby 1.8, so gem1.8 is checked first
+ RUBYGEMS_CMD=$(which gem1.8 || which gem)
+ if [ -z "$RUBYGEMS_CMD" ]; then
+ echo "Warning: ruby gems command not found."
+ fi
+}
+
+function install_trema() {
+ # Trema
+ gem_install trema
+ # Sliceable Switch
+ git_clone $TREMA_APPS_REPO $TREMA_DIR/apps $TREMA_APPS_BRANCH
+ make -C $TREMA_DIR/apps/topology
+ make -C $TREMA_DIR/apps/flow_manager
+ make -C $TREMA_DIR/apps/sliceable_switch
+}
+
+function start_trema() {
+ # APACHE_NAME is defined in init_horizon (in lib/horizon)
+ restart_service $APACHE_NAME
+
+ sudo LOGGING_LEVEL=$TREMA_LOG_LEVEL TREMA_TMP=$TREMA_TMP_DIR \
+ trema run -d -c $TREMA_SS_CONFIG
+}
+
+function stop_trema() {
+ sudo TREMA_TMP=$TREMA_TMP_DIR trema killall
+}
+
+# Restore xtrace
+$MY_XTRACE