1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
#!/bin/bash
#
# Usage: setup-test-env-amqp.sh <command to run>
# where AMQP1_BACKEND is the AMQP 1.0 intermediary to use. Valid
# values are "qdrouterd" for router and "qpidd" for broker.
set -e
# router requires qdrouterd, sasl2-bin/cyrus-sasl-plain+cyrus-sasl-lib
# broker requires qpidd, qpid-tools sasl2-bin/cyrus-sasl-plain+cyrus-sasl-lib
. tools/functions.sh
DATADIR=$(mktemp -d /tmp/OSLOMSG-${AMQP1_BACKEND}.XXXXX)
trap "clean_exit $DATADIR" EXIT
function _setup_qdrouterd_user {
echo secretqpid | saslpasswd2 -c -p -f ${DATADIR}/qdrouterd.sasldb stackqpid
}
function _setup_qpidd_user {
echo secretqpid | saslpasswd2 -c -p -f ${DATADIR}/qpidd.sasldb -u QPID stackqpid
}
function _configure_qdrouterd {
QDR=$(type -p qdrouterd)
if [[ ! -x "$QDR" ]]; then
echo "FAILURE: Qpid Dispatch Router (qdrouterd) not installed"
exit 1
fi
# create a stand alone router
cat > ${DATADIR}/qdrouterd.conf <<EOF
router {
mode: standalone
id: Router.A
workerThreads: 4
saslConfigPath: ${DATADIR}/sasl2
saslConfigName: qdrouterd
}
EOF
# create a listener for incoming connect to the router
# ip address field name changed to 'host' at 1.0+
local field_name
field_name=$([[ $($QDR -v) == 0.*.* ]] && echo addr || echo host)
cat >> ${DATADIR}/qdrouterd.conf <<EOF
listener {
${field_name}: 0.0.0.0
port: 65123
role: normal
authenticatePeer: yes
}
EOF
# create fixed address prefixes
cat >> ${DATADIR}/qdrouterd.conf <<EOF
address {
prefix: unicast
distribution: closest
}
address {
prefix: exclusive
distribution: closest
}
address {
prefix: broadcast
distribution: multicast
}
address {
prefix: openstack.org/om/rpc/multicast
distribution: multicast
}
address {
prefix: openstack.org/om/rpc/unicast
distribution: closest
}
address {
prefix: openstack.org/om/rpc/anycast
distribution: balanced
}
address {
prefix: openstack.org/om/notify/multicast
distribution: multicast
}
address {
prefix: openstack.org/om/notify/unicast
distribution: closest
}
address {
prefix: openstack.org/om/notify/anycast
distribution: balanced
}
EOF
# create log file configuration
cat >> ${DATADIR}/qdrouterd.conf <<EOF
log {
module: DEFAULT
enable: trace+
output: ${DATADIR}/out
}
EOF
# sasl2 config
mkdir -p ${DATADIR}/sasl2
cat > ${DATADIR}/sasl2/qdrouterd.conf <<EOF
pwcheck_method: auxprop
auxprop_plugin: sasldb
sasldb_path: ${DATADIR}/qdrouterd.sasldb
mech_list: PLAIN ANONYMOUS
EOF
}
function _configure_qpidd {
QPIDD=$(which qpidd 2>/dev/null)
if [[ ! -x "$QPIDD" ]]; then
echo "FAILURE: qpidd broker not installed"
exit 1
fi
[ -f "/usr/lib/qpid/daemon/acl.so" ] && LIBACL="load-module=/usr/lib/qpid/daemon/acl.so"
cat > ${DATADIR}/qpidd.conf <<EOF
port=65123
sasl-config=${DATADIR}/sasl2
${LIBACL}
mgmt-enable=yes
log-to-stderr=no
data-dir=${DATADIR}/.qpidd
pid-dir=${DATADIR}/.qpidd
EOF
if ! `$QPIDD --help | grep -q "sasl-service-name"`; then
echo "This version of $QPIDD does not support SASL authentication with AMQP 1.0"
cat >> ${DATADIR}/qpidd.conf <<EOF
auth=no
EOF
else
cat >> ${DATADIR}/qpidd.conf <<EOF
auth=yes
acl-file=${DATADIR}/qpidd.acl
sasl-service-name=amqp
EOF
fi
cat >> ${DATADIR}/qpidd.conf <<EOF
queue-patterns=exclusive
queue-patterns=unicast
topic-patterns=broadcast
EOF
cat > ${DATADIR}/qpidd.acl <<EOF
group admin stackqpid@QPID
acl allow admin all
acl deny all all
EOF
mkdir -p ${DATADIR}/sasl2
cat > ${DATADIR}/sasl2/qpidd.conf <<EOF
pwcheck_method: auxprop
auxprop_plugin: sasldb
sasldb_path: ${DATADIR}/qpidd.sasldb
mech_list: PLAIN ANONYMOUS
sql_select: dummy select
EOF
}
function _start_qdrouterd {
MAJOR=$(python -c 'import sys; print(sys.version_info.major)')
MINOR=$(python -c 'import sys; print(sys.version_info.minor)')
# qdrouterd needs access to global site packages
# create path file and place in virtual env working directory
SITEDIR=${WORKDIR}/${ENVNAME}/lib/python${MAJOR}.${MINOR}/site-packages
cat > ${SITEDIR}/dispatch.pth <<EOF
/usr/lib/python${MAJOR}.${MINOR}/site-packages
EOF
QDR=$(which qdrouterd 2>/dev/null)
mkfifo ${DATADIR}/out
$QDR --config ${DATADIR}/qdrouterd.conf &
wait_for_line "Router .*started" "error" ${DATADIR}/out
rm ${SITEDIR}/dispatch.pth
}
function _start_qpidd {
chmod -R a+r ${DATADIR}
QPIDD=$(which qpidd 2>/dev/null)
mkfifo ${DATADIR}/out
$QPIDD --log-enable trace+ --log-to-file ${DATADIR}/out --config ${DATADIR}/qpidd.conf &
wait_for_line "Broker .*running" "error" ${DATADIR}/out
}
_configure_${AMQP1_BACKEND}
_setup_${AMQP1_BACKEND}_user
_start_${AMQP1_BACKEND}
$*
|