Files
63d874e4af67893effbd1ef9daf150fc41d15eec
devstack /lib /rpc_backend

181 lines
6.0 KiB
Plaintext
Raw Normal View History

#
# Dependencies:
# - ``functions`` file
# ``stack.sh`` calls the entry points in this order:
#
# - install_rpc_backend
# - restart_rpc_backend
#
# Note: if implementing an out of tree plugin for an RPC backend, you
# should install all services through normal plugin methods, then
# redefine ``iniset_rpc_backend`` in your code. That's the one portion
# of this file which is a standard interface.
# Save trace setting
RABBIT_HOST=${RABBIT_HOST:-$SERVICE_HOST}
fi
# ---------
# produces a clean switch
function cleanup_rpc_backend {
if is_service_enabled rabbit; then
# Obliterate rabbitmq-server
uninstall_package rabbitmq-server
sudo killall epmd || sudo killall -9 epmd || /bin/true
# And the Erlang runtime too
# Install rabbitmq-server
# install) then rabbit_setuser triggers epmd@0.0.0.0.socket with
# socket activation. This fails the first time and does not get
# cleared. It is benign, but the workaround is to start rabbitmq a
# bit earlier for RPM based distros.
sudo systemctl --now enable rabbitmq-server
# restart the rpc backend
# Start rabbitmq-server
echo_summary "Starting RabbitMQ"
# the fact that sometimes it fails to start properly.
# See: https://bugs.launchpad.net/devstack/+bug/1449056 for details on
# why this is needed. This can bee seen on vivid and Debian unstable
# (May 2015)
# TODO(tonyb): Remove this when Debian and Ubuntu have a fixed systemd
# service file.
restart_service rabbitmq-server
fi
rabbit_setuser "$RABBIT_USERID" "$RABBIT_PASSWORD" || rc=$?
if [ $rc -ne 0 ]; then
continue
fi
$RABBIT_USERID $RABBIT_PASSWORD || rc=$?
if [ $rc -ne 0 ]; then
continue;
fi
break
sudo rabbitmqctl delete_user guest || true
}
# adds a vhost to the rpc backend
function rpc_backend_add_vhost {
local vhost="1ドル"
if is_service_enabled rabbit; then
if [ -z `sudo rabbitmqctl list_vhosts | grep $vhost` ]; then
sudo rabbitmqctl add_vhost $vhost
sudo rabbitmqctl set_permissions -p $vhost $RABBIT_USERID ".*" ".*" ".*"
echo 'RPC backend does not support vhosts'
return 1
}
}
# should be used to set the transport_url option in the
# oslo_messaging_notifications group.
local virtual_host=1ドル
if is_service_enabled rabbit || { [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; }; then
echo "rabbit://$RABBIT_USERID:$RABBIT_PASSWORD@$RABBIT_HOST:5672/$virtual_host"
fi
}
local file=2ドル
iniset $file oslo_messaging_rabbit heartbeat_timeout_threshold $RABBIT_HEARTBEAT_TIMEOUT_THRESHOLD
fi
if [ -n "$RABBIT_HEARTBEAT_RATE" ]; then
iniset $file oslo_messaging_rabbit heartbeat_rate $RABBIT_HEARTBEAT_RATE
fi
}
local user="1ドル" pass="2ドル" found="" out=""
out=$(sudo rabbitmqctl list_users) ||
{ echo "failed to list users" 1>&2; return 1; }
found=$(echo "$out" | awk '1ドル == user { print 1ドル }' "user=$user")
if [ "$found" = "$user" ]; then
sudo rabbitmqctl change_password "$user" "$pass" ||
{ echo "failed changing pass for '$user'" 1>&2; return 1; }
else
sudo rabbitmqctl add_user "$user" "$pass" ||
{ echo "failed changing pass for $user"; return 1; }
fi
sudo rabbitmqctl set_permissions "$user" ".*" ".*" ".*"
}
## Local variables:
## mode: shell-script
## End: