From fb4c68d6203c4ba0e6e3dc5b8309ed98ddd0057e Mon Sep 17 00:00:00 2001 From: "steve.ruan" Date: Tue, 3 May 2016 07:26:15 -0500 Subject: [PATCH] Add devstack for neutron-dynamic-routing stadium project Change-Id: I406b276f691e68adac935a4a2119efc055df31b1 Implements: blueprint bgp-spinout Partial-Bug: #1560003 --- devstack/README.rst | 40 ++++++++++++++++++++ devstack/lib/dr | 91 +++++++++++++++++++++++++++++++++++++++++++++ devstack/plugin.sh | 23 ++++++++++++ devstack/settings | 66 ++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 devstack/README.rst create mode 100644 devstack/lib/dr create mode 100644 devstack/plugin.sh create mode 100644 devstack/settings diff --git a/devstack/README.rst b/devstack/README.rst new file mode 100644 index 00000000..987135f5 --- /dev/null +++ b/devstack/README.rst @@ -0,0 +1,40 @@ +====================== + Enabling in Devstack +====================== + +1. Download devstack:: + + git clone http://git.openstack.org/openstack-dev/devstack.git + +2. Add neutron-dynamic-routing to devstack. The minimal set of critical local.conf + additions are following:: + + cd devstack + cat << EOF >> local.conf + > enable_plugin neutron-dynamic-routing http://git.openstack.org/openstack/neutron-dynamic-routing + > EOF + +3. run devstack:: + + ./stack.sh + +Notes: + +1. In default case, neutron-dynamic-routing is installed in allinone mode. + In multiple nodes environment, for controller node:: + cd devstack + cat << EOF >> local.conf + > enable_plugin neutron-dynamic-routing http://git.openstack.org/openstack/neutron-dynamic-routing + > DR_MODE=dr_plugin + > EOF + + For the nodes where you want to run dr-agent:: + cd devstack + cat << EOF >> local.conf + > enable_plugin neutron-dynamic-routing http://git.openstack.org/openstack/neutron-dynamic-routing + > DR_MODE=dr_agent + > EOF + +2. In default case, protocol BGP is enabled for neutron-dynamic-routing. + You can change "DR_SUPPORTED_PROTOCOLS" in "devstack/settings" to protocols wanted. + diff --git a/devstack/lib/dr b/devstack/lib/dr new file mode 100644 index 00000000..cb04b367 --- /dev/null +++ b/devstack/lib/dr @@ -0,0 +1,91 @@ +function is_protocol_enabled { + local enabled=1 + local protocol=$1 + for temp in $DR_SUPPORTED_PROTOCOLS ;do + if [ $protocol == $temp ] ; then + enabled=0 + fi + done + + return $enabled +} + + +############################## +# BGP Section # +############################## + +function configure_dr_agent_bgp_config { + cp $NEUTRON_DYNAMIC_ROUTING_DIR/etc/bgp_dragent.ini.sample $DR_AGENT_BGP_CONF_FILE + iniset $DR_AGENT_BGP_CONF_FILE DEFAULT verbose True + iniset $DR_AGENT_BGP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL + iniset $DR_AGENT_BGP_CONF_FILE BGP bgp_router_id $BGP_ROUTER_ID +} + +function configure_dr_agent_bgp_driver { + if [ -z "$BGP_SPEAKER_DRIVER" ] ; then + BGP_SPEAKER_DRIVER=$RYU_BGP_SPEAKER_DRIVER + fi + iniset $DR_AGENT_BGP_CONF_FILE BGP bgp_speaker_driver $BGP_SPEAKER_DRIVER +} + +############################# +# Stack Install Section # +############################# + +#This API will be called for phase "install" + +function dr_configure { + setup_develop $NEUTRON_DYNAMIC_ROUTING_DIR + if is_service_enabled q-dr && is_service_enabled q-svc; then + if is_protocol_enabled BGP; then + _neutron_service_plugin_class_add $BGP_PLUGIN + fi + fi +} + +############################# +# Stack Post-config Section # +############################# + +#This API will be called for phase "post-config" +function dr_generate_config_files { + (cd $NEUTRON_DYNAMIC_ROUTING_DIR && exec ./tools/generate_config_file_samples.sh) +} + +function dr_post_configure { + if is_service_enabled q-dr-agent; then + dr_generate_config_files + if is_protocol_enabled BGP; then + configure_dr_agent_bgp_config + configure_dr_agent_bgp_driver + fi + fi +} + +############################# +# Stack Extra Section # +############################# + +#This API will be called for phase "extra" +function start_dr_agent { + local process="$DR_AGENT_BINARY --config-file $NEUTRON_CONF " + local bgp_parameter + if is_protocol_enabled BGP; then + bgp_parameter="--config-file $DR_AGENT_BGP_CONF_FILE" + fi + + agent_process=$process$bgp_parameter + if is_service_enabled q-dr-agent; then + run_process q-dr-agent "$agent_process" + fi +} + +############################# +# Unstack Section # +############################# + +#This API will be called for unstack +function stop_dr_agent { + stop_process q-dr-agent +} diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 00000000..554cb7c6 --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,23 @@ +LIBDIR=$NEUTRON_DYNAMIC_ROUTING_DIR/devstack/lib + +source $LIBDIR/dr + +if [[ "$1" == "stack" ]]; then + case "$2" in + install) + echo_summary "Installing neutron-dynamic-routing" + dr_configure + ;; + post-config) + echo_summary "Configuring neutron-dynamic-routing" + dr_post_configure + ;; + extra) + echo_summary "Launching neutron-dynamic-routing agent" + start_dr_agent + ;; + esac +elif [[ "$1" == "unstack" ]]; then + echo_summary "Uninstalling neutron-dynamic-routing" + stop_dr_agent +fi diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 00000000..ccbf6fc5 --- /dev/null +++ b/devstack/settings @@ -0,0 +1,66 @@ +######################### +# Devstack Settings # +######################### + +# Each service you enable has the following meaning: +# q-dr - Add this config flag for Openstack Neutron server node +# q-dr-agent - Add this config flag indicate that dynamic routing agent +# will be running + +# This can be overridden in the localrc file +DR_MODE=${DR_MODE:-allinone} + +# DR_MODE is used to configure how devstack works with neutron-dynamic-routing. +# You can configure it in there ways: +# +# DR_MODE=allinone +# Use this mode if you want to run neutron server and q-dr-agent on same node. +# Useful for a single node deployment or on the control node of a multi-node +# devstack environment. +# +# DR_MODE=dr_plugin +# Use this to enable dr plugin extension on neutron server +# +# DR_MODE=dr_agent +# Use this for the nodes where you want to run q-dr-agent in a multi-node +# devstack environment. + +case $DR_MODE in + allinone) + enable_service q-dr q-dr-agent + ;; + dr_plugin) + enable_service q-dr + ;; + dr_agent) + enable_service q-dr-agent + ;; +esac + +# DR_SUPPORTED_PROTOCOLS specifies the list of protocols supported +# by neutron-dynamic-routing project. ONLY BGP is supported as of now +# and it's enabled by default. The protocols may include: "BGP OSPF ISIS RIP". +# It can be overridden in the localrc file. +DR_SUPPORTED_PROTOCOLS=${DR_SUPPORTED_PROTOCOLS:-"BGP"} + + +####################### +# Binary Settings # +####################### +NEUTRON_DYNAMIC_ROUTING_DIR=$DEST/neutron-dynamic-routing +DR_AGENT_BINARY=${DR_AGENT_BINARY:-"$NEUTRON_BIN_DIR/neutron-bgp-dragent"} + + +################################ +# Protocol Config Settings # +################################ + + +########### +# BGP # +########### +DR_AGENT_BGP_CONF_FILE=${DR_AGENT_BGP_CONF_FILE:-"$NEUTRON_CONF_DIR/bgp_dragent.ini"} +BGP_ROUTER_ID=${BGP_ROUTER_ID:-"127.0.0.1"} +BGP_PLUGIN=${BGP_PLUGIN:-"neutron_dynamic_routing.services.bgp.bgp_plugin.BgpPlugin"} +RYU_BGP_SPEAKER_DRIVER="neutron_dynamic_routing.services.bgp.agent.driver.ryu.driver.RyuBgpDriver" +