Add the 'external' message bus configuration option
This option is used to run devstack against a pre-provisioned message bus, rather than having this plugin setup the bus. Change-Id: I44f15889e6f1f14460bac34702407a8d30721616 Closes-Bug: #1683403 Closes-Bug: #1683397
This commit is contained in:
parent
297d85ff58
commit
59221dd8cc
|
@ -23,33 +23,77 @@
|
|||
#
|
||||
# Environment Configuration
|
||||
#
|
||||
# AMQP1_SERVICE - identifies the messaging backend to use. Should be
|
||||
# one of 'qpid' for broker backend, 'qpid-dual' for hybrid router-broker, or
|
||||
# 'qpid-hybrid' for keeping Rabbit for notifcations.
|
||||
# @TODO(kgiusti) add qpid-dispatch, etc
|
||||
# AMQP1_SERVICE - This plugin can deploy one of several different
|
||||
# message bus configurations. This variable identifies the message
|
||||
# bus configuration that will be used. Should be one of:
|
||||
# 'qpid' - use the qpidd broker for both RPC and Notifications
|
||||
# 'qpid-dual' - use qpidd for Notifications, qdrouterd for RPC
|
||||
# 'qpid-hybrid' - use rabbitmq for Notifications, qdrouterd for RPC
|
||||
# 'external' - use a pre-provisioned message bus. This prevents
|
||||
# this plugin from creating the message bus. Instead it assumes
|
||||
# the bus has already been set up and simply connects to it.
|
||||
# AMQP1_RPC_TRANSPORT_URL - Transport URL to use for RPC service
|
||||
# AMQP1_NOTIFY_TRANSPORT_URL - Transport URL to use for Notification
|
||||
# service.
|
||||
#
|
||||
# If the above AMQP1_*_TRANSPORT_URL env vars are not defined, this
|
||||
# plugin will construct these urls using the following env vars:
|
||||
#
|
||||
# AMQP1_HOST - the host used to connect to the messaging service.
|
||||
# Defaults to 127.0.0.1
|
||||
# AMQP1_{DEFAULT_PORT, NOTIFY_PORT} - the port used to connect to the messaging
|
||||
# service. Defaults to 5672 and 5671.
|
||||
# AMQP1_{USERNAME,PASSWORD} - for authentication with AMQP1_HOST
|
||||
# Defaults to $SERVICE_HOST
|
||||
# AMQP1_{DEFAULT_PORT, NOTIFY_PORT} - the port used to connect to the
|
||||
# messaging service. AMQP1_NOTIFY_PORT defaults to 5672.
|
||||
# AMQP_DEFAULT_PORT also defaults to 5672 for the 'qpid'
|
||||
# configuration, otherwise 45672 to avoid port# clashes with the
|
||||
# Notification port.
|
||||
# AMQP1_{USERNAME,PASSWORD} - for authentication with AMQP1_HOST (optional)
|
||||
#
|
||||
# The RPC transport url will be defined as:
|
||||
# "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_DEFAULT_PORT}/"
|
||||
#
|
||||
# The notify transport url will be defined as:
|
||||
# "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_NOTIFY_PORT}/"
|
||||
#
|
||||
|
||||
# builds default transport url string
|
||||
function _get_amqp1_default_transport_url {
|
||||
if [ -z "$AMQP1_USERNAME" ]; then
|
||||
echo "amqp://$AMQP1_HOST:${AMQP1_DEFAULT_PORT}/"
|
||||
# parse URL, extracting host, port, username, password
|
||||
function _parse_transport_url {
|
||||
local uphp # user+password+host+port
|
||||
local user # username
|
||||
local passwd # password
|
||||
local hostport # host+port
|
||||
local host # hostname
|
||||
local port # port #
|
||||
|
||||
# extract [user:pass@]host:port
|
||||
uphp=$(echo $1 | sed -e "s#^[^:]*://\([^/]*\).*#\1#")
|
||||
# parse out username + password if present:
|
||||
user=""
|
||||
passwd=""
|
||||
if [[ "$uphp" =~ .+@.+ ]]; then
|
||||
local passhostport
|
||||
user=$(echo $uphp | sed -e "s#^\([^:]*\).*#\1#")
|
||||
passhostport=$(echo $uphp | sed -e "s#$user:##")
|
||||
passwd=$(echo $passhostport | sed -e "s#^\([^@]*\).*#\1#")
|
||||
hostport=$(echo $passhostport | sed -e "s#$passwd@##")
|
||||
else
|
||||
echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_DEFAULT_PORT}/"
|
||||
hostport=$uphp
|
||||
fi
|
||||
host=$(echo $hostport | cut -d: -f1)
|
||||
port=$(echo $hostport | cut -d: -f2)
|
||||
|
||||
# field 1 2 3 4
|
||||
echo "$host $port $user $passwd"
|
||||
}
|
||||
|
||||
# builds notify transport url string
|
||||
|
||||
# default transport url string
|
||||
function _get_amqp1_default_transport_url {
|
||||
echo "$AMQP1_RPC_TRANSPORT_URL"
|
||||
}
|
||||
|
||||
# notify transport url string
|
||||
function _get_amqp1_notify_transport_url {
|
||||
if [ -z "$AMQP1_USERNAME" ]; then
|
||||
echo "amqp://$AMQP1_HOST:${AMQP1_NOTIFY_PORT}/"
|
||||
else
|
||||
echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_NOTIFY_PORT}/"
|
||||
fi
|
||||
echo "$AMQP1_NOTIFY_TRANSPORT_URL"
|
||||
}
|
||||
|
||||
# install packages necessary for support of the oslo.messaging AMQP
|
||||
|
@ -81,6 +125,9 @@ function _remove_pyngus {
|
|||
# Set up the various configuration files used by the qpidd broker
|
||||
function _configure_qpid {
|
||||
|
||||
local url
|
||||
url=$(_parse_transport_url $1)
|
||||
|
||||
# the location of the configuration files have changed since qpidd 0.14
|
||||
local qpid_conf_file
|
||||
if [ -e /etc/qpid/qpidd.conf ]; then
|
||||
|
@ -95,7 +142,8 @@ function _configure_qpid {
|
|||
sudo chmod o+r $qpid_conf_file
|
||||
|
||||
# force the ACL file to a known location
|
||||
local qpid_acl_file=/etc/qpid/qpidd.acl
|
||||
local qpid_acl_file
|
||||
qpid_acl_file=/etc/qpid/qpidd.acl
|
||||
if [ ! -e $qpid_acl_file ]; then
|
||||
sudo mkdir -p -m 755 `dirname $qpid_acl_file`
|
||||
sudo touch $qpid_acl_file
|
||||
|
@ -103,12 +151,9 @@ function _configure_qpid {
|
|||
fi
|
||||
echo "acl-file=$qpid_acl_file" | sudo tee $qpid_conf_file
|
||||
|
||||
# map broker port for dual backend config
|
||||
if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
|
||||
echo "port=${AMQP1_NOTIFY_PORT}" | sudo tee --append $qpid_conf_file
|
||||
fi
|
||||
|
||||
if [ -z "$AMQP1_USERNAME" ]; then
|
||||
local username
|
||||
username=$(echo "$url" | cut -d' ' -f3)
|
||||
if [ -z "$username" ]; then
|
||||
# no QPID user configured, so disable authentication
|
||||
# and access control
|
||||
echo "auth=no" | sudo tee --append $qpid_conf_file
|
||||
|
@ -117,19 +162,22 @@ acl allow all all
|
|||
EOF
|
||||
else
|
||||
# Configure qpidd to use PLAIN authentication, and add
|
||||
# AMQP1_USERNAME to the ACL:
|
||||
# $username to the ACL:
|
||||
echo "auth=yes" | sudo tee --append $qpid_conf_file
|
||||
if [ -z "$AMQP1_PASSWORD" ]; then
|
||||
read_password AMQP1_PASSWORD "ENTER A PASSWORD FOR QPID USER $AMQP1_USERNAME"
|
||||
local passwd
|
||||
passwd=$(echo "$url" | cut -d' ' -f4)
|
||||
if [ -z "$passwd" ]; then
|
||||
read_password password "ENTER A PASSWORD FOR QPID USER $username"
|
||||
fi
|
||||
# Create ACL to allow $AMQP1_USERNAME full access
|
||||
# Create ACL to allow $username full access
|
||||
cat <<EOF | sudo tee $qpid_acl_file
|
||||
group admin ${AMQP1_USERNAME}@QPID
|
||||
group admin ${username}@QPID
|
||||
acl allow admin all
|
||||
acl deny all all
|
||||
EOF
|
||||
# Add user to SASL database
|
||||
local sasl_conf_file=/etc/sasl2/qpidd.conf
|
||||
local sasl_conf_file
|
||||
sasl_conf_file=/etc/sasl2/qpidd.conf
|
||||
cat <<EOF | sudo tee $sasl_conf_file
|
||||
pwcheck_method: auxprop
|
||||
auxprop_plugin: sasldb
|
||||
|
@ -143,7 +191,7 @@ EOF
|
|||
if [ ! -e $sasl_db ]; then
|
||||
sudo mkdir -p -m 755 `dirname $sasl_db`
|
||||
fi
|
||||
echo $AMQP1_PASSWORD | sudo saslpasswd2 -c -p -f $sasl_db -u QPID $AMQP1_USERNAME
|
||||
echo $passwd | sudo saslpasswd2 -c -p -f $sasl_db -u QPID $username
|
||||
sudo chmod o+r $sasl_db
|
||||
fi
|
||||
|
||||
|
@ -154,7 +202,8 @@ EOF
|
|||
if ! $QPIDD --help | grep -q "queue-patterns"; then
|
||||
exit_distro_not_supported "qpidd with AMQP 1.0 support"
|
||||
fi
|
||||
local log_file=$LOGDIR/qpidd.log
|
||||
local log_file
|
||||
log_file=$LOGDIR/qpidd.log
|
||||
cat <<EOF | sudo tee --append $qpid_conf_file
|
||||
queue-patterns=exclusive
|
||||
queue-patterns=unicast
|
||||
|
@ -180,6 +229,9 @@ EOF
|
|||
# Set up the various configuration files used by the qpid-dispatch-router (qdr)
|
||||
function _configure_qdr {
|
||||
|
||||
local url
|
||||
url=$(_parse_transport_url $1)
|
||||
|
||||
# the location of the configuration is /etc/qpid-dispatch
|
||||
local qdr_conf_file
|
||||
if [ -e /etc/qpid-dispatch/qdrouterd.conf ]; then
|
||||
|
@ -207,13 +259,17 @@ router {
|
|||
EOF
|
||||
|
||||
# Create a listener for incoming connect to the router
|
||||
local port
|
||||
port=$(echo "$url" | cut -d' ' -f2)
|
||||
cat <<EOF | sudo tee --append $qdr_conf_file
|
||||
listener {
|
||||
addr: 0.0.0.0
|
||||
port: ${AMQP1_DEFAULT_PORT}
|
||||
port: ${port}
|
||||
role: normal
|
||||
EOF
|
||||
if [ -z "$AMQP1_USERNAME" ]; then
|
||||
local username
|
||||
username=$(echo "$url" | cut -d' ' -f3)
|
||||
if [ -z "$username" ]; then
|
||||
#no user configured, so disable authentication
|
||||
cat <<EOF | sudo tee --append $qdr_conf_file
|
||||
authenticatePeer: no
|
||||
|
@ -222,8 +278,10 @@ EOF
|
|||
EOF
|
||||
else
|
||||
# configure to use PLAIN authentication
|
||||
if [ -z "$AMQP1_PASSWORD" ]; then
|
||||
read_password AMQP1_PASSWORD "ENTER A PASSWORD FOR QPID DISPATCH USER $AMQP1_USERNAME"
|
||||
local passwd
|
||||
passwd=$(echo "$url" | cut -d' ' -f4)
|
||||
if [ -z "$passwd" ]; then
|
||||
read_password passwd "ENTER A PASSWORD FOR QPID DISPATCH USER $username"
|
||||
fi
|
||||
cat <<EOF | sudo tee --append $qdr_conf_file
|
||||
authenticatePeer: yes
|
||||
|
@ -231,7 +289,8 @@ EOF
|
|||
|
||||
EOF
|
||||
# Add user to SASL database
|
||||
local sasl_conf_file=/etc/sasl2/qdrouterd.conf
|
||||
local sasl_conf_file
|
||||
sasl_conf_file=/etc/sasl2/qdrouterd.conf
|
||||
cat <<EOF | sudo tee $sasl_conf_file
|
||||
pwcheck_method: auxprop
|
||||
auxprop_plugin: sasldb
|
||||
|
@ -244,7 +303,7 @@ EOF
|
|||
if [ ! -e $sasl_db ]; then
|
||||
sudo mkdir -p -m 755 `dirname $sasl_db`
|
||||
fi
|
||||
echo $AMQP1_PASSWORD | sudo saslpasswd2 -c -p -f $sasl_db $AMQP1_USERNAME
|
||||
echo $passwd | sudo saslpasswd2 -c -p -f $sasl_db $username
|
||||
sudo chmod o+r $sasl_db
|
||||
fi
|
||||
|
||||
|
@ -297,8 +356,8 @@ address {
|
|||
|
||||
EOF
|
||||
|
||||
local log_file=$LOGDIR/qdrouterd.log
|
||||
|
||||
local log_file
|
||||
log_file=$LOGDIR/qdrouterd.log
|
||||
sudo touch $log_file
|
||||
sudo chmod a+rw $log_file # qdrouterd user can write to it
|
||||
|
||||
|
@ -319,39 +378,35 @@ EOF
|
|||
# (qpidd broker and optionally dispatch-router for hybrid)
|
||||
function _install_amqp1_backend {
|
||||
|
||||
local qdrouterd_package
|
||||
local qpidd_package
|
||||
if is_fedora; then
|
||||
# expects epel is already added to the yum repos
|
||||
install_package cyrus-sasl-lib
|
||||
install_package cyrus-sasl-plain
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
install_package qpid-cpp-server
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
install_package qpid-dispatch-router
|
||||
fi
|
||||
qdrouterd_package="qpid-dispatch-router"
|
||||
qpidd_package="qpid-cpp-server"
|
||||
elif is_ubuntu; then
|
||||
install_package sasl2-bin
|
||||
# newer qpidd and proton only available via the qpid PPA
|
||||
sudo add-apt-repository -y ppa:qpid/released
|
||||
#sudo apt-get update
|
||||
REPOS_UPDATED=False
|
||||
update_package_repo
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
install_package qpidd
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
install_package qdrouterd
|
||||
fi
|
||||
qdrouterd_package="qdrouterd"
|
||||
qpidd_package="qpidd"
|
||||
else
|
||||
exit_distro_not_supported "amqp1 qpid installation"
|
||||
fi
|
||||
|
||||
_install_pyngus
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
_configure_qpid
|
||||
|
||||
if [ "$AMQP1_RPC" == "qdrouterd" ]; then
|
||||
install_package $qdrouterd_package
|
||||
_configure_qdr $AMQP1_RPC_TRANSPORT_URL
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
_configure_qdr
|
||||
if [ "$AMQP1_NOTIFY" == "qpidd" ]; then
|
||||
install_package $qpidd_package
|
||||
_configure_qpid $AMQP1_NOTIFY_TRANSPORT_URL
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -359,36 +414,30 @@ function _install_amqp1_backend {
|
|||
function _start_amqp1_backend {
|
||||
echo_summary "Starting amqp1 backends"
|
||||
# restart, since qpid* may already be running
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
restart_service qpidd
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
if [ "$AMQP1_RPC" == "qdrouterd" ]; then
|
||||
restart_service qdrouterd
|
||||
fi
|
||||
if [ "$AMQP1_NOTIFY" == "qpidd" ]; then
|
||||
restart_service qpidd
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function _cleanup_amqp1_backend {
|
||||
if is_fedora; then
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
uninstall_package qpid-cpp-server
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
if [ "$AMQP1_RPC" == "qdrouterd" ]; then
|
||||
uninstall_package qpid-dispatch-router
|
||||
fi
|
||||
# TODO(kgiusti) can we pull these, or will that break other
|
||||
# packages that depend on them?
|
||||
|
||||
# install_package cyrus_sasl_lib
|
||||
# install_package cyrus_sasl_plain
|
||||
elif is_ubuntu; then
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
uninstall_package qpidd
|
||||
if [ "$AMQP1_NOTIFY" == "qpidd" ]; then
|
||||
uninstall_package qpid-cpp-server
|
||||
fi
|
||||
if [ "$AMQP1_SERVICE" != "qpid" ]; then
|
||||
elif is_ubuntu; then
|
||||
if [ "$AMQP1_RPC" == "qdrouterd" ]; then
|
||||
uninstall_package qdrouterd
|
||||
fi
|
||||
# install_package sasl2-bin
|
||||
if [ "$AMQP1_NOTIFY" == "qpidd" ]; then
|
||||
uninstall_package qpidd
|
||||
fi
|
||||
else
|
||||
exit_distro_not_supported "amqp1 qpid installation"
|
||||
fi
|
||||
|
@ -399,28 +448,70 @@ function _cleanup_amqp1_backend {
|
|||
|
||||
# iniset configuration for amqp rpc_backend
|
||||
function _iniset_amqp1_backend {
|
||||
local package=$1
|
||||
local file=$2
|
||||
local section=${3:-DEFAULT}
|
||||
local package
|
||||
local file
|
||||
local section
|
||||
|
||||
if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
|
||||
iniset $file $section transport_url $(get_transport_url)
|
||||
iniset $file oslo_messaging_notifications transport_url $(_get_amqp1_notify_transport_url)
|
||||
elif [ "$AMQP1_SERVICE" == "qpid-hybrid" ]; then
|
||||
iniset $file $section transport_url $(get_transport_url)
|
||||
package=$1
|
||||
file=$2
|
||||
section=${3:-DEFAULT}
|
||||
|
||||
iniset $file $section transport_url $(get_transport_url)
|
||||
if [ "$AMQP1_NOTIFY" == "rabbit" ]; then
|
||||
iniset $file oslo_messaging_notifications transport_url $(_get_rabbit_transport_url)
|
||||
else
|
||||
iniset $file $section transport_url $(get_transport_url)
|
||||
iniset $file oslo_messaging_notifications transport_url $(_get_amqp1_notify_transport_url)
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if is_service_enabled amqp1; then
|
||||
# @TODO (ansmith) check is for qdr or qpid for now
|
||||
if [[ "$AMQP1_SERVICE" != "qpid" && "$AMQP1_SERVICE" != "qpid-dual" && "$AMQP1_SERVICE" != "qpid-hybrid" ]]; then
|
||||
die $LINENO "AMQP 1.0 requires qpid, qpid-dual or qpid-hybrid - $AMQP1_SERVICE not supported"
|
||||
|
||||
# for backward compatibility - generate the transport urls from the old env vars if not set
|
||||
if [[ -z "$AMQP1_RPC_TRANSPORT_URL" ]]; then
|
||||
AMQP1_DEFAULT_PORT=${AMQP1_DEFAULT_PORT:=$([[ "$AMQP1_SERVICE" == "qpid" ]] && echo 5672 || echo 45672)}
|
||||
if [ -n "$AMQP1_USERNAME" ]; then
|
||||
AMQP1_RPC_TRANSPORT_URL="amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:$AMQP1_DEFAULT_PORT"
|
||||
else
|
||||
AMQP1_RPC_TRANSPORT_URL="amqp://$AMQP1_HOST:$AMQP1_DEFAULT_PORT"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$AMQP1_NOTIFY_TRANSPORT_URL" ]]; then
|
||||
AMQP1_NOTIFY_PORT=${AMQP1_NOTIFY_PORT:=5672}
|
||||
if [ -n "$AMQP1_USERNAME" ]; then
|
||||
AMQP1_NOTIFY_TRANSPORT_URL="amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:$AMQP1_NOTIFY_PORT"
|
||||
else
|
||||
AMQP1_NOTIFY_TRANSPORT_URL="amqp://$AMQP1_HOST:$AMQP1_NOTIFY_PORT"
|
||||
fi
|
||||
fi
|
||||
|
||||
case $AMQP1_SERVICE in
|
||||
"qpid")
|
||||
# Use qpidd for both notifications and RPC messages
|
||||
AMQP1_RPC="qpidd"
|
||||
AMQP1_NOTIFY="qpidd"
|
||||
;;
|
||||
"qpid-dual")
|
||||
# Use qpidd for notifications and qdrouterd for RPC messages
|
||||
AMQP1_RPC="qdrouterd"
|
||||
AMQP1_NOTIFY="qpidd"
|
||||
;;
|
||||
"qpid-hybrid")
|
||||
# Use rabbitmq for notifications and qdrouterd for RPC messages
|
||||
AMQP1_RPC="qdrouterd"
|
||||
AMQP1_NOTIFY="rabbit"
|
||||
;;
|
||||
"external")
|
||||
# Use a pre-provisioned message bus @ AMQP1_NOTIFY/RPC_TRANSPORT_URLs
|
||||
AMQP1_RPC="external"
|
||||
AMQP1_NOTIFY="external"
|
||||
;;
|
||||
*)
|
||||
die $LINENO "Set AMQP1_SERVICE to one of: qpid, qpid-dual, qpid-hybrid or external - $AMQP1_SERVICE not supported"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Save rabbit get_transport_url for notifications if necessary
|
||||
if [ ! $(type -t _get_rabbit_transport_url) ]; then
|
||||
get_transport_url_definition=$(declare -f get_transport_url)
|
||||
|
@ -439,20 +530,6 @@ if is_service_enabled amqp1; then
|
|||
}
|
||||
export -f iniset_rpc_backend
|
||||
export -f get_transport_url
|
||||
fi
|
||||
|
||||
|
||||
# check for amqp1 service
|
||||
if is_service_enabled amqp1; then
|
||||
|
||||
if [ "$AMQP1_SERVICE" != "qpid-hybrid" ]; then
|
||||
available_port=5672
|
||||
else
|
||||
available_port=15672
|
||||
fi
|
||||
|
||||
AMQP1_DEFAULT_PORT=${AMQP1_DEFAULT_PORT:=$available_port}
|
||||
AMQP1_NOTIFY_PORT=${AMQP1_NOTIFY_PORT:=5671}
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
||||
# nothing needed here
|
||||
|
|
Loading…
Reference in New Issue