Browse Source

Enable Dual Messaging System Backends

This patch enables the AMQP 1.0 plugin to deploy either a single
broker (RPC and Notifications) or a dual dispatch-router (RPC) and
broker (Notification) configuration.

Change-Id: I8e52c58a3f7f9aa1bce55bd91bf9b71d504da813
Andrew Smith 2 years ago
parent
commit
a9891fe766
2 changed files with 49 additions and 77 deletions
  1. 3
    3
      README.rst
  2. 46
    74
      devstack/plugin.sh

+ 3
- 3
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 - 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).
5
+Devstack plugin for AMQP 1.0 olso.messaging driver - This plugin supports the QPID C++ broker for RPC and Notification backends  and the QPID Dispatch Router messaging system 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,9 +17,9 @@ Devstack plugin for AMQP 1.0 olso.messaging driver - This plugin supports the QP
17 17
      AMQP1_USERNAME=queueuser
18 18
      AMQP1_PASSWORD=queuepassword     
19 19
 
20
-4. Optionally set the service variable for the configuration if the QPID Dispatch Router is to be used as an alternative AMQP1 service::
20
+4. Optionally set the service variable for the configuration. The default is for the broker to provide both the RPC and Notification backends. If dual backends are to be used as an alternative AMQP1 service::
21 21
 
22
-     AMQP1_SERVICE=qdr
22
+     AMQP1_SERVICE=qpid-dual
23 23
    
24 24
 5. run ``stack.sh``
25 25
 

+ 46
- 74
devstack/plugin.sh View File

@@ -24,7 +24,7 @@
24 24
 # Environment Configuration
25 25
 #
26 26
 # AMQP1_SERVICE - identifies the messaging backend to use.  Should be
27
-#    one of 'qpid', ...
27
+#    one of 'qpid' for broker backend or 'qpid-dual' for hybrid router-broker.
28 28
 #    @TODO(kgiusti) add qpid-dispatch, rabbitmq, etc
29 29
 # AMQP1_HOST - the host:port used to connect to the messaging service.
30 30
 #    Defaults to 127.0.0.1:5672
@@ -33,10 +33,10 @@
33 33
 
34 34
 # builds transport url string
35 35
 function _get_amqp1_transport_url {
36
-    echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:5672/"
36
+    local port=$1
37
+    echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:$port/"
37 38
 }
38 39
 
39
-
40 40
 # install packages necessary for support of the oslo.messaging AMQP
41 41
 # 1.0 driver
42 42
 function _install_pyngus {
@@ -86,10 +86,8 @@ function _configure_qpid {
86 86
         sudo touch $qpid_acl_file
87 87
         sudo chmod o+r $qpid_acl_file
88 88
     fi
89
-    sudo sed -i.bak '/^acl-file=/d' $qpid_conf_file
90
-    echo "acl-file=$qpid_acl_file" | sudo tee --append $qpid_conf_file
89
+    echo "acl-file=$qpid_acl_file" | sudo tee $qpid_conf_file
91 90
 
92
-    sudo sed -i '/^auth=/d' $qpid_conf_file
93 91
     if [ -z "$AMQP1_USERNAME" ]; then
94 92
         # no QPID user configured, so disable authentication
95 93
         # and access control
@@ -136,8 +134,7 @@ EOF
136 134
         exit_distro_not_supported "qpidd with AMQP 1.0 support"
137 135
     fi
138 136
     local log_file=$LOGDIR/qpidd.log
139
-    if ! grep -q "queue-patterns=exclusive" $qpid_conf_file; then
140
-        cat <<EOF | sudo tee --append $qpid_conf_file
137
+    cat <<EOF | sudo tee --append $qpid_conf_file
141 138
 queue-patterns=exclusive
142 139
 queue-patterns=unicast
143 140
 topic-patterns=broadcast
@@ -145,7 +142,6 @@ log-enable=info+
145 142
 log-to-file=$log_file
146 143
 log-to-syslog=yes
147 144
 EOF
148
-    fi
149 145
 
150 146
     # Set the SASL service name if the version of qpidd supports it
151 147
     if $QPIDD --help | grep -q "sasl-service-name"; then
@@ -189,10 +185,11 @@ router {
189 185
 EOF
190 186
 
191 187
     # Create a listener for incoming connect to the router
188
+    # assign router to amqps port
192 189
     cat <<EOF | sudo tee --append $qdr_conf_file
193 190
 listener {
194 191
     addr: 0.0.0.0
195
-    port: amqp
192
+    port: amqps
196 193
     role: normal
197 194
 EOF
198 195
     if [ -z "$AMQP1_USERNAME" ]; then
@@ -297,14 +294,18 @@ EOF
297 294
 }
298 295
 
299 296
 
300
-# install and configure the qpidd broker
301
-function _install_qpid_backend {
297
+# install and configure the amqp1 backends
298
+# (qpidd broker and optionally dispatch-router for hybrid)
299
+function _install_amqp1_backend {
302 300
 
303 301
     if is_fedora; then
304 302
         # expects epel is already added to the yum repos
305 303
         install_package cyrus-sasl-lib
306 304
         install_package cyrus-sasl-plain
307 305
         install_package qpid-cpp-server
306
+        if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
307
+            install_package qpid-dispatch-router
308
+        fi
308 309
     elif is_ubuntu; then
309 310
         install_package sasl2-bin
310 311
         # newer qpidd and proton only available via the qpid PPA
@@ -313,58 +314,37 @@ function _install_qpid_backend {
313 314
         REPOS_UPDATED=False
314 315
         update_package_repo
315 316
         install_package qpidd
317
+        if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
318
+            install_package qdrouterd
319
+        fi
316 320
     else
317
-        exit_distro_not_supported "qpidd installation"
321
+        exit_distro_not_supported "amqp1 qpid installation"
318 322
     fi
319 323
 
320 324
     _install_pyngus
321 325
     _configure_qpid
322
-}
323
-
324
-
325
-# install and configure the qpid-dispatch-router
326
-function _install_qdr_backend {
327
-
328
-    if is_fedora; then
329
-        # expects epel is already added to the yum repos
330
-        install_package cyrus-sasl-lib
331
-        install_package cyrus-sasl-plain
332
-        install_package qpid-dispatch-router
333
-    elif is_ubuntu; then
334
-        install_package sasl2-bin
335
-        # dispatch available via qpid PPA
336
-        sudo add-apt-repository -y ppa:qpid/testing
337
-        #sudo apt-get update
338
-        REPOS_UPDATED=False
339
-        update_package_repo
340
-        install_package qdrouterd
341
-    else
342
-        exit_distro_not_supported "qdrouterd installation"
326
+    if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
327
+        _configure_qdr
343 328
     fi
344
-
345
-    _install_pyngus
346
-    _configure_qdr
347
-
348 329
 }
349 330
 
350 331
 
351
-function _start_qpid_backend {
352
-    echo_summary "Starting qpidd broker"
353
-    # restart, since qpidd may already be running
332
+function _start_amqp1_backend {
333
+    echo_summary "Starting amqp1 backends"
334
+    # restart, since qpid* may already be running
354 335
     restart_service qpidd
336
+    if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
337
+        restart_service qdrouterd
338
+    fi
355 339
 }
356 340
 
357 341
 
358
-function _start_qdr_backend {
359
-    echo_summary "Starting qdrouterd router"
360
-    # restart, since qdrouterd may already be running
361
-    restart_service qdrouterd
362
-}
363
-
364
-
365
-function _cleanup_qpid_backend {
342
+function _cleanup_amqp1_backend {
366 343
     if is_fedora; then
367 344
         uninstall_package qpid-cpp-server
345
+        if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
346
+            uninstall_package qpid-dispatch-router
347
+        fi
368 348
 	# TODO(kgiusti) can we pull these, or will that break other
369 349
 	# packages that depend on them?
370 350
 
@@ -372,28 +352,12 @@ function _cleanup_qpid_backend {
372 352
         # install_package cyrus_sasl_plain
373 353
     elif is_ubuntu; then
374 354
         uninstall_package qpidd
355
+        if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
356
+            uninstall_package qdrouterd
357
+        fi
375 358
         # install_package sasl2-bin
376 359
     else
377
-        exit_distro_not_supported "qpid installation"
378
-    fi
379
-
380
-    _remove_pyngus
381
-}
382
-
383
-
384
-function _cleanup_qdr_backend {
385
-    if is_fedora; then
386
-        uninstall_package qpid-dispatch-router
387
-	# TODO(kgiusti) can we pull these, or will that break other
388
-	# packages that depend on them?
389
-
390
-        # install_package cyrus_sasl_lib
391
-        # install_package cyrus_sasl_plain
392
-    elif is_ubuntu; then
393
-        uninstall_package qdrouterd
394
-        # install_package sasl2-bin
395
-    else
396
-        exit_distro_not_supported "qdrouterd installation"
360
+        exit_distro_not_supported "amqp1 qpid installation"
397 361
     fi
398 362
 
399 363
     _remove_pyngus
@@ -405,6 +369,7 @@ function _iniset_amqp1_backend {
405 369
     local package=$1
406 370
     local file=$2
407 371
     local section=${3:-DEFAULT}
372
+    local port=5672
408 373
 
409 374
     iniset $file $section rpc_backend "amqp"
410 375
     iniset $file $section qpid_hostname ${AMQP1_HOST}
@@ -412,13 +377,20 @@ function _iniset_amqp1_backend {
412 377
         iniset $file oslo_messaging_amqp username $AMQP1_USERNAME
413 378
         iniset $file oslo_messaging_amqp password $AMQP1_PASSWORD
414 379
     fi
380
+
381
+    if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
382
+        iniset $file $section transport_url $(get_transport_url "5671")
383
+        iniset $file oslo_messaging_notifications transport_url $(get_transport_url "5672")
384
+    else
385
+        iniset $file $section transport_url $(get_transport_url "5672")
386
+    fi
415 387
 }
416 388
 
417 389
 
418 390
 if is_service_enabled amqp1; then
419 391
     # @TODO (ansmith) check is for qdr or qpid for now
420
-    if [[ "$AMQP1_SERVICE" != "qdr" && "$AMQP1_SERVICE" != "qpid" ]]; then
421
-        die $LINENO "AMQP 1.0 requires qpid or qdr - $AMQP1_SERVICE not supported"
392
+    if [[ "$AMQP1_SERVICE" != "qpid" && "$AMQP1_SERVICE" != "qpid-dual" ]]; then
393
+        die $LINENO "AMQP 1.0 requires qpid or qpid-dual - $AMQP1_SERVICE not supported"
422 394
     fi
423 395
 
424 396
     # Note: this is the only tricky part about out of tree rpc plugins,
@@ -444,12 +416,12 @@ if is_service_enabled amqp1; then
444 416
     elif [[ "$1" == "stack" && "$2" == "install" ]]; then
445 417
         # Installs and configures the messaging service
446 418
         echo_summary "Installing AMQP service $AMQP1_SERVICE"
447
-        _install_${AMQP1_SERVICE}_backend
419
+        _install_amqp1_backend
448 420
 
449 421
     elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
450 422
         # Start the messaging service process, this happens before any
451 423
         # services start
452
-        _start_${AMQP1_SERVICE}_backend
424
+        _start_amqp1_backend
453 425
 
454 426
     elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
455 427
         :
@@ -462,7 +434,7 @@ if is_service_enabled amqp1; then
462 434
     if [[ "$1" == "clean" ]]; then
463 435
         # Remove state and transient data
464 436
         # Remember clean.sh first calls unstack.sh
465
-        _cleanup_${AMQP1_SERVICE}_backend
437
+        _cleanup_amqp1_backend
466 438
     fi
467 439
 fi
468 440
 

Loading…
Cancel
Save