Browse Source

amqp1 plugin update to use environment vars for transport_url

This patch uses just the configuration variables to generate
transport_url for the dual backend deployments (per amrith
suggestion). This patch also checks whether username var has been
set for transport_url generation.

Closes-Bug: 1646208
Change-Id: Ib82dfc0805a7dacbb61993df7e79d901d41bea42
Andrew Smith 2 years ago
parent
commit
dfe92694d3
2 changed files with 40 additions and 20 deletions
  1. 5
    0
      README.rst
  2. 35
    20
      devstack/plugin.sh

+ 5
- 0
README.rst View File

@@ -21,6 +21,11 @@ Devstack plugin for AMQP 1.0 olso.messaging driver - This plugin supports the QP
21 21
 
22 22
      AMQP1_SERVICE=qpid-dual
23 23
    
24
+5. Optionally set the network ports used to connect to the messaging service. If dual backends are to be configured, a separate Notify port must be used::
25
+
26
+     AMQP1_DEFAULT_PORT=5672
27
+     AMQP1_NOTIFY_PORT=5671
28
+
24 29
 5. run ``stack.sh``
25 30
 
26 31
     

+ 35
- 20
devstack/plugin.sh View File

@@ -26,15 +26,29 @@
26 26
 # AMQP1_SERVICE - identifies the messaging backend to use.  Should be
27 27
 #    one of 'qpid' for broker backend or 'qpid-dual' for hybrid router-broker.
28 28
 #    @TODO(kgiusti) add qpid-dispatch, rabbitmq, etc
29
-# AMQP1_HOST - the host:port used to connect to the messaging service.
30
-#    Defaults to 127.0.0.1:5672
29
+# AMQP1_HOST - the host used to connect to the messaging service.
30
+#    Defaults to 127.0.0.1
31
+# AMQP1_{DEFAULT_PORT, NOTIFY_PORT} - the port used to connect to the messaging
32
+#    service. Defaults to 5672 and 5671.
31 33
 # AMQP1_{USERNAME,PASSWORD} - for authentication with AMQP1_HOST
32 34
 #
33 35
 
34
-# builds transport url string
35
-function _get_amqp1_transport_url {
36
-    local port=${1:-5672}
37
-    echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:$port/"
36
+# builds default transport url string
37
+function _get_amqp1_default_transport_url {
38
+    if [ -z "$AMQP1_USERNAME" ]; then
39
+        echo "amqp://$AMQP1_HOST:${AMQP1_DEFAULT_PORT}/"
40
+    else
41
+        echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_DEFAULT_PORT}/"
42
+    fi
43
+}
44
+
45
+# builds notify transport url string
46
+function _get_amqp1_notify_transport_url {
47
+    if [ -z "$AMQP1_USERNAME" ]; then
48
+        echo "amqp://$AMQP1_HOST:${AMQP1_NOTIFY_PORT}/"
49
+    else
50
+        echo "amqp://$AMQP1_USERNAME:$AMQP1_PASSWORD@$AMQP1_HOST:${AMQP1_NOTIFY_PORT}/"
51
+    fi
38 52
 }
39 53
 
40 54
 # install packages necessary for support of the oslo.messaging AMQP
@@ -88,6 +102,11 @@ function _configure_qpid {
88 102
     fi
89 103
     echo "acl-file=$qpid_acl_file" | sudo tee $qpid_conf_file
90 104
 
105
+    # map broker port for dual backend config
106
+    if [ "$AMQP1_SERVICE" == "qpid-dual" ]; then
107
+        echo "port=${AMQP1_NOTIFY_PORT}" | sudo tee --append $qpid_conf_file
108
+    fi
109
+
91 110
     if [ -z "$AMQP1_USERNAME" ]; then
92 111
         # no QPID user configured, so disable authentication
93 112
         # and access control
@@ -117,6 +136,7 @@ sasldb_path: /var/lib/qpidd/qpidd.sasldb
117 136
 mech_list: PLAIN
118 137
 sql_select: dummy select
119 138
 EOF
139
+
120 140
         local sasl_db
121 141
         sasl_db=`sudo grep sasldb_path $sasl_conf_file | cut -f 2 -d ":" | tr -d [:blank:]`
122 142
         if [ ! -e $sasl_db ]; then
@@ -185,11 +205,10 @@ router {
185 205
 EOF
186 206
 
187 207
     # Create a listener for incoming connect to the router
188
-    # assign router to amqps port
189 208
     cat <<EOF | sudo tee --append $qdr_conf_file
190 209
 listener {
191 210
     addr: 0.0.0.0
192
-    port: amqps
211
+    port: ${AMQP1_DEFAULT_PORT}
193 212
     role: normal
194 213
 EOF
195 214
     if [ -z "$AMQP1_USERNAME" ]; then
@@ -369,20 +388,12 @@ function _iniset_amqp1_backend {
369 388
     local package=$1
370 389
     local file=$2
371 390
     local section=${3:-DEFAULT}
372
-    local port=5672
373
-
374
-    iniset $file $section rpc_backend "amqp"
375
-    iniset $file $section qpid_hostname ${AMQP1_HOST}
376
-    if [ -n "$AMQP1_USERNAME" ]; then
377
-        iniset $file oslo_messaging_amqp username $AMQP1_USERNAME
378
-        iniset $file oslo_messaging_amqp password $AMQP1_PASSWORD
379
-    fi
380 391
 
381 392
     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")
393
+        iniset $file $section transport_url $(get_transport_url)
394
+        iniset $file oslo_messaging_notifications transport_url $(_get_amqp1_notify_transport_url)
384 395
     else
385
-        iniset $file $section transport_url $(get_transport_url "5672")
396
+        iniset $file $section transport_url $(get_transport_url)
386 397
     fi
387 398
 }
388 399
 
@@ -400,7 +411,7 @@ if is_service_enabled amqp1; then
400 411
         _iniset_amqp1_backend $@
401 412
     }
402 413
     function get_transport_url {
403
-        _get_amqp1_transport_url $@
414
+        _get_amqp1_default_transport_url $@
404 415
     }
405 416
     export -f iniset_rpc_backend
406 417
     export -f get_transport_url
@@ -409,6 +420,10 @@ fi
409 420
 
410 421
 # check for amqp1 service
411 422
 if is_service_enabled amqp1; then
423
+
424
+    AMQP1_DEFAULT_PORT=${AMQP1_DEFAULT_PORT:=5672}
425
+    AMQP1_NOTIFY_PORT=${AMQP1_NOTIFY_PORT:=5671}
426
+
412 427
     if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
413 428
         # nothing needed here
414 429
         :

Loading…
Cancel
Save