Files
4c2870b64a6f4da007f715a67e77d57eb01d5a51
devstack /lib /rpc_backend

207 lines
7.1 KiB
Plaintext
Raw Normal View History

# Interface for interactig with different rpc backend
# rpc backend settings
# Dependencies:
# ``functions`` file
# ``RABBIT_{HOST|PASSWORD}`` must be defined when RabbitMQ is used
# ``stack.sh`` calls the entry points in this order:
#
# check_rpc_backend
# install_rpc_backend
# restart_rpc_backend
# iniset_rpc_backend
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Functions
# ---------
# Also check the specified rpc backend is available on your platform.
function check_rpc_backend() {
# We rely on the fact that filenames in lib/* match the service names
# that can be passed as arguments to is_service_enabled.
# We check for a call to iniset_rpc_backend in these files, meaning
# the service needs a backend.
if is_service_enabled $c; then
rpc_needed=0
break
fi
done
for svc in qpid zeromq rabbit; do
is_service_enabled $svc &&
((rpc_backend_cnt++))
done
if [ "$rpc_backend_cnt" -gt 1 ]; then
echo "ERROR: only one rpc backend may be enabled,"
echo " set only one of 'rabbit', 'qpid', 'zeromq'"
echo " via ENABLED_SERVICES."
echo " set one of 'rabbit', 'qpid', 'zeromq'"
echo " via ENABLED_SERVICES."
fi
if is_service_enabled qpid && ! qpid_is_supported; then
}
# produces a clean switch
function cleanup_rpc_backend {
if is_service_enabled rabbit; then
# Obliterate rabbitmq-server
uninstall_package rabbitmq-server
sudo killall epmd
if is_ubuntu; then
# And the Erlang runtime too
sudo aptitude purge -y ~nerlang
fi
elif is_service_enabled qpid; then
if is_fedora; then
uninstall_package qpidd
else
exit_distro_not_supported "qpid installation"
fi
elif is_service_enabled zeromq; then
if is_fedora; then
exit_distro_not_supported "zeromq installation"
fi
# Necessary directory for socket location.
sudo mkdir -p /var/run/openstack
sudo chown $STACK_USER /var/run/openstack
}
function install_rpc_backend() {
if is_service_enabled rabbit; then
# Install rabbitmq-server
# the temp file is necessary due to LP: #878600
tfile=$(mktemp)
install_package rabbitmq-server > "$tfile" 2>&1
cat "$tfile"
rm -f "$tfile"
elif is_service_enabled qpid; then
if is_fedora; then
# RHEL6 leaves "auth=yes" in /etc/qpidd.conf, it needs to
# be no or you get GSS authentication errors as it
# attempts to default to this.
sudo sed -i.bak 's/^auth=yes$/auth=no/' /etc/qpidd.conf
fi
install_package qpidd
sudo chmod o+r /etc/qpid/qpidd.sasldb
exit_distro_not_supported "qpid installation"
fi
elif is_service_enabled zeromq; then
# but there is a matchmaker driver that works
# really well & out of the box for multi-node.
exit_distro_not_supported "zeromq installation"
fi
fi
}
# restart the rpc backend
function restart_rpc_backend() {
if is_service_enabled rabbit; then
# Start rabbitmq-server
echo_summary "Starting RabbitMQ"
if is_fedora || is_suse; then
# service is not started by default
restart_service rabbitmq-server
fi
# change the rabbit password since the default is "guest"
sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
# Add partitioned access for the child cell
if [ -z `sudo rabbitmqctl list_vhosts | grep child_cell` ]; then
sudo rabbitmqctl add_vhost child_cell
sudo rabbitmqctl set_permissions -p child_cell guest ".*" ".*" ".*"
fi
fi
echo_summary "Starting qpid"
restart_service qpidd
fi
}
# iniset cofiguration
function iniset_rpc_backend() {
local package=1ドル
local file=2ドル
local section=3ドル
if is_service_enabled zeromq; then
iniset $file $section rpc_backend ${package}.openstack.common.rpc.impl_zmq
${package}.openstack.common.rpc.matchmaker_redis.MatchMakerRedis
# Set MATCHMAKER_REDIS_HOST if running multi-node.
MATCHMAKER_REDIS_HOST=${MATCHMAKER_REDIS_HOST:-127.0.0.1}
iniset $file matchmaker_redis host $MATCHMAKER_REDIS_HOST
iniset $file $section qpid_hostname ${QPID_HOST:-$SERVICE_HOST}
QPID_PASSWORD=`sudo strings /etc/qpid/qpidd.sasldb | grep -B1 admin | head -1`
iniset $file $section qpid_password $QPID_PASSWORD
iniset $file $section qpid_username admin
fi
iniset $file $section rabbit_host $RABBIT_HOST
iniset $file $section rabbit_password $RABBIT_PASSWORD
fi
}
# Check if qpid can be used on the current distro.
# qpid_is_supported
function qpid_is_supported() {
if [[ -z "$DISTRO" ]]; then
GetDistro
fi
# Qpid was introduced to Ubuntu in precise, disallow it on oneiric; it is
# not in openSUSE either right now.
( ! ([[ "$DISTRO" = "oneiric" ]] || is_suse) )
}
$XTRACE
# Local variables:
# mode: shell-script
# End: