Browse Source

Enable qpid-dispatch-router as alternative amqp backend

Update to the AMPQ1 plugin enables the optional use of the Apached QPID
Dispatch Router (qdr) as an alternative to the QPID C++ broker for the
rpc backend. The modifications to the plugin account for the installation
and configuration of the qdrouterd service.

Review Changes

Updated README for description and variable usage

Support for Ubuntu plugin deployment

Change-Id: I0f9f42fe942697526af70570f05a43be79f9f411
Andrew Smith 3 years ago
parent
commit
142d975ac3
2 changed files with 175 additions and 9 deletions
  1. 6
    2
      README.rst
  2. 169
    7
      devstack/plugin.sh

+ 6
- 2
README.rst View File

@@ -2,7 +2,7 @@
2 2
  Enabling in Devstack
3 3
 ======================
4 4
 
5
-Devstack plugin for AMQP 1.0 olso.messaging driver
5
+Devstack plugin for AMQP 1.0 olso.messaging driver - This plugin supports the QPID C++ broker and QPID Dispatch Router messaging systems for the rpc backend. Additional information on these messaging systems can be found at the Apache QPID homepage (https://qpid.apache.org).
6 6
 
7 7
 1. Download DevStack
8 8
 
@@ -17,6 +17,10 @@ Devstack plugin for AMQP 1.0 olso.messaging driver
17 17
      AMQP1_USERNAME=queueuser
18 18
      AMQP1_PASSWORD=queuepassword     
19 19
 
20
-4. run ``stack.sh``
20
+4. Optionally set the service variable for the configuration if the QPID Dispatch Router is to be used as an alternative AMQP1 service::
21
+
22
+     AMQP1_SERVICE=qdr
23
+   
24
+5. run ``stack.sh``
21 25
 
22 26
     

+ 169
- 7
devstack/plugin.sh View File

@@ -153,6 +153,117 @@ EOF
153 153
 }
154 154
 
155 155
 
156
+# Set up the various configuration files used by the qpid-dispatch-router (qdr)
157
+function _configure_qdr {
158
+
159
+    # the location of the configuration is /etc/qpid-dispatch
160
+    local qdr_conf_file
161
+    if [ -e /etc/qpid-dispatch/qdrouterd.conf ]; then
162
+        qdr_conf_file=/etc/qpid-dispatch/qdrouterd.conf
163
+    else
164
+        exit_distro_not_supported "qdrouterd.conf file not found!"
165
+    fi
166
+
167
+    # ensure that the qpid-dispatch-router service can read its config
168
+    sudo chmod o+r $qdr_conf_file
169
+
170
+    # qdouterd.conf file customization for devstack deployment
171
+    # Define attributes related to the AMQP container
172
+    cat <<EOF | sudo tee $qdr_conf_file
173
+container {
174
+    workerThreads: 4
175
+    containerName: Qpid.Dispatch.Router.A
176
+    saslConfigPath: /etc/sasl2
177
+    saslConfigName: qdrouterd
178
+    debugDump: /opt/stack/amqp1
179
+}
180
+
181
+EOF
182
+
183
+    # Create stand alone router
184
+    cat <<EOF | sudo tee --append $qdr_conf_file
185
+router {
186
+    mode: standalone
187
+    routerId: Router.A
188
+}
189
+
190
+EOF
191
+
192
+    # Create a listener for incoming connect to the router
193
+    cat <<EOF | sudo tee --append $qdr_conf_file
194
+listener {
195
+    addr: 0.0.0.0
196
+    port: amqp
197
+    role: normal
198
+EOF
199
+    if [ -z "$AMQP1_USERNAME" ]; then
200
+	#no user configured, so disable authentication
201
+        cat <<EOF | sudo tee --append $qdr_conf_file
202
+    authenticatePeer: no
203
+}
204
+
205
+EOF
206
+    else
207
+        # configure to use PLAIN authentication
208
+        if [ -z "$AMQP1_PASSWORD" ]; then
209
+            read_password AMQP1_PASSWORD "ENTER A PASSWORD FOR QPID DISPATCH USER $AMQP1_USERNAME"
210
+        fi
211
+        cat <<EOF | sudo tee --append $qdr_conf_file
212
+        authenticatePeer: yes
213
+}
214
+
215
+EOF
216
+        # Add user to SASL database
217
+        local sasl_conf_file=/etc/sasl2/qdrouterd.conf
218
+        sudo sed -i.bak '/PLAIN/!s/mech_list: /mech_list: PLAIN /' $sasl_conf_file
219
+        local sasl_db
220
+        sasl_db=`sudo grep sasldb_path $sasl_conf_file | cut -f 2 -d ":" | tr -d [:blank:]`
221
+        if [ ! -e $sasl_db ]; then
222
+            sudo mkdir -p -m 755 `dirname $sasl_db`
223
+        fi
224
+        echo $AMQP1_PASSWORD | sudo saslpasswd2 -c -p -f $sasl_db $AMQP1_USERNAME
225
+        sudo chmod o+r $sasl_db
226
+    fi
227
+
228
+    # Create fixed address prefixes
229
+    cat <<EOF | sudo tee --append $qdr_conf_file
230
+fixedAddress {
231
+    prefix: /unicast
232
+    fanout: single
233
+    bias: closest
234
+}
235
+
236
+fixedAddress {
237
+    prefix: /exclusive
238
+    fanout: single
239
+    bias: closest
240
+}
241
+
242
+fixedAddress {
243
+    prefix: /broadcast
244
+    fanout: multiple
245
+}
246
+
247
+EOF
248
+
249
+    local log_file=$LOGDIR/qdrouterd.log
250
+
251
+    sudo touch $log_file
252
+    sudo chmod a+rw $log_file  # qdrouterd user can write to it
253
+
254
+    # Create log file configuration
255
+    cat <<EOF | sudo tee --append $qdr_conf_file
256
+log {
257
+    module: DEFAULT
258
+    enable: info+
259
+    output: $log_file
260
+}
261
+
262
+EOF
263
+
264
+}
265
+
266
+
156 267
 # install and configure the qpidd broker
157 268
 function _install_qpid_backend {
158 269
 
@@ -178,6 +289,32 @@ function _install_qpid_backend {
178 289
 }
179 290
 
180 291
 
292
+# install and configure the qpid-dispatch-router
293
+function _install_qdr_backend {
294
+
295
+    if is_fedora; then
296
+        # expects epel is already added to the yum repos
297
+        install_package cyrus-sasl-lib
298
+        install_package cyrus-sasl-plain
299
+        install_package qpid-dispatch-router
300
+    elif is_ubuntu; then
301
+        install_package sasl2-bin
302
+        # dispatch available via qpid PPA
303
+        sudo add-apt-repository -y ppa:qpid/testing
304
+        #sudo apt-get update
305
+        REPOS_UPDATED=False
306
+        update_package_repo
307
+        install_package qdrouterd
308
+    else
309
+        exit_distro_not_supported "qdrouterd installation"
310
+    fi
311
+
312
+    _install_pyngus
313
+    _configure_qdr
314
+
315
+}
316
+
317
+
181 318
 function _start_qpid_backend {
182 319
     echo_summary "Starting qpidd broker"
183 320
     # restart, since qpidd may already be running
@@ -185,6 +322,13 @@ function _start_qpid_backend {
185 322
 }
186 323
 
187 324
 
325
+function _start_qdr_backend {
326
+    echo_summary "Starting qdrouterd router"
327
+    # restart, since qdrouterd may already be running
328
+    restart_service qdrouterd
329
+}
330
+
331
+
188 332
 function _cleanup_qpid_backend {
189 333
     if is_fedora; then
190 334
         uninstall_package qpid-cpp-server
@@ -204,8 +348,27 @@ function _cleanup_qpid_backend {
204 348
 }
205 349
 
206 350
 
207
-# iniset configuration for qpid
208
-function _iniset_qpid_backend {
351
+function _cleanup_qdr_backend {
352
+    if is_fedora; then
353
+        uninstall_package qpid-dispatch-router
354
+	# TODO(kgiusti) can we pull these, or will that break other
355
+	# packages that depend on them?
356
+
357
+        # install_package cyrus_sasl_lib
358
+        # install_package cyrus_sasl_plain
359
+    elif is_ubuntu; then
360
+        uninstall_package qdrouterd
361
+        # install_package sasl2-bin
362
+    else
363
+        exit_distro_not_supported "qdrouterd installation"
364
+    fi
365
+
366
+    _remove_pyngus
367
+}
368
+
369
+
370
+# iniset configuration for amqp rpc_backend
371
+function _iniset_amqp1_backend {
209 372
     local package=$1
210 373
     local file=$2
211 374
     local section=${3:-DEFAULT}
@@ -220,17 +383,16 @@ function _iniset_qpid_backend {
220 383
 
221 384
 
222 385
 if is_service_enabled amqp1; then
223
-    # @TODO(kgiusti) hardcode qpid for now, add other service
224
-    # types as support is provided
225
-    if [ "$AMQP1_SERVICE" != "qpid" ]; then
226
-        die $LINENO "AMQP 1.0 requires qpid - $AMQP1_SERVICE not supported"
386
+    # @TODO (ansmith) check is for qdr or qpid for now
387
+    if [[ "$AMQP1_SERVICE" != "qdr" && "$AMQP1_SERVICE" != "qpid" ]]; then
388
+        die $LINENO "AMQP 1.0 requires qpid or qdr - $AMQP1_SERVICE not supported"
227 389
     fi
228 390
 
229 391
     # Note: this is the only tricky part about out of tree rpc plugins,
230 392
     # you must overwrite the iniset_rpc_backend function so that when
231 393
     # that's passed around the correct settings files are made.
232 394
     function iniset_rpc_backend {
233
-        _iniset_${AMQP1_SERVICE}_backend $@
395
+        _iniset_amqp1_backend $@
234 396
     }
235 397
     function get_transport_url {
236 398
         _get_amqp1_transport_url $@

Loading…
Cancel
Save