From 05a09eb2cce0019c74394bf6e3141897cc348c01 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sun, 21 May 2017 11:15:01 -0400 Subject: [PATCH] Setup RPC and Notification hybrid messaging backends Change-Id: Id60fb7d0f5220c3abc94c9a6478b3814d4622bb5 --- devstack/plugin.sh | 372 ++++++++++++++++++++++++++++++++++++++++----- devstack/settings | 14 +- tox.ini | 2 +- 3 files changed, 346 insertions(+), 42 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index f7aef38..89074b6 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -1,38 +1,81 @@ #!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# -# devstack/plugin.sh -# Functions to install and configure Apache Kafka +# Install and configure Apache Kafka. Since kafka is only used for +# oslo.messaging notifications, setup a hybrid messaging backend. +# The RPC transport backend will be amqp:// and the +# Notification transport wil be kafka:// # -# Dependencies: -# -# - ``functions`` file -# -# ``stack.sh`` calls the entry points in this order: -# -# - download_kafka -# - install_kafka -# - configure_kafka -# - init_kafka -# - stop_kafka -# - cleanup_kafka +# Environment Configuration +# RPC_HOST - the host used to connect to the RPC messaging service. +# RPC_PORT - the port used to connect to the RPC messaging service. +# Defaults to 5672. +# RPC_{USERNAME,PASSWORD} - for authentication with RPC messaging service. +# NOTIFY_HOST - the host used to connect to the Notification messaging service. +# NOTIFY_PORT - the port used to connect to the Notification messaging service. +# Defaults to 9092. +# NOTIFY_{USERNAME,PASSWORD} - for authentication with Notification messaging +# service. # Save trace setting XTRACE=$(set +o | grep xtrace) set +o xtrace +# builds rpc transport url string +function _get_rpc_transport_url { + if [ -z "$RPC_USERNAME" ]; then + echo "amqp://$RPC_HOST:${RPC_PORT}/" + else + echo "amqp://$RPC_USERNAME:$RPC_PASSWORD@$RPC_HOST:${RPC_PORT}/" + fi +} + +# builds notify transport url string +function _get_notify_transport_url { + if [ -z "$NOTIFY_USERNAME" ]; then + echo "kafka://$NOTIFY_HOST:${NOTIFY_PORT}/" + else + echo "kafka://$NOTIFY_USERNAME:$NOTIFY_PASSWORD@$NOTIFY_HOST:${NOTIFY_PORT}/" + fi +} + # Functions # ------------ -# download_kafka() - downloading kafka -function download_kafka { +# _download_kafka() - downloading kafka +function _download_kafka { if [ ! -f ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz ]; then wget ${KAFKA_BASEURL}/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz \ -O ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz fi } -# install_kafka() - installing Kafka with Scala and Zookeeper -function install_kafka { +# install packages necessary for support of the oslo.messaging kafka +# driver +function _install_kafka_python { + # Install kafka client API + pip_install_gr kafka-python +} +# _install_kafka_backend() - installing Kafka with Scala and Zookeeper +function _install_kafka_backend { + echo_summary "Installing kafka service" local scala_version=${SCALA_VERSION}.0 if is_ubuntu; then @@ -57,7 +100,7 @@ function install_kafka { fi fi - download_kafka + _download_kafka if [ ! -d ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ]; then tar -xvzf ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C ${FILES} @@ -66,58 +109,309 @@ function install_kafka { mkdir -p ${KAFKA_DEST} mv ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ${KAFKA_DEST}/kafka fi + + _install_kafka_python } -# init_kafka() - starting Kafka and Zookeeper processes -function init_kafka { +# _start_kafka_backend() - starting Kafka and Zookeeper processes +function _start_kafka_backend { # start Zookeeper process before starting Kafka + echo_summary "Initializing and starting kafka service" ${KAFKA_DEST}/kafka/bin/zookeeper-server-start.sh -daemon ${KAFKA_DEST}/kafka/config/zookeeper.properties ${KAFKA_DEST}/kafka/bin/kafka-server-start.sh -daemon ${KAFKA_DEST}/kafka/config/server.properties } -# configure_kafka() - configuring Kafka service -function configure_kafka { +# _configure_kafka() - configuring Kafka service +function _configure_kafka { # currently a no op : } -# stop_kafka() - stopping Kafka process -function stop_kafka { +# _stop_kafka() - stopping Kafka process +function _stop_kafka { + echo_summary "Shut down kafka service" ${KAFKA_DEST}/kafka/bin/kafka-server-stop.sh ${KAFKA_DEST}/kafka/bin/zookeeper-server-stop.sh } -# cleanup_kafka() - removing Kafka files +# _cleanup_kafka() - removing Kafka files # make sure this function is called only after calling stop_kafka() function -function cleanup_kafka { +function _cleanup_kafka { + echo_summary "Clean up kafka service" rm ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz rm -rf ${KAFKA_DEST}/kafka } +# Set up the various configuration files used by the qpid-dispatch-router (qdr) +function _configure_qdr { + + # the location of the configuration is /etc/qpid-dispatch + local qdr_conf_file + if [ -e /etc/qpid-dispatch/qdrouterd.conf ]; then + qdr_conf_file=/etc/qpid-dispatch/qdrouterd.conf + else + exit_distro_not_supported "qdrouterd.conf file not found!" + fi + + # ensure that the qpid-dispatch-router service can read its config + sudo chmod o+r $qdr_conf_file + + # qdouterd.conf file customization for devstack deployment + # Define attributes related to the AMQP container + # Create stand alone router + cat <