summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devstack/plugin.sh89
-rw-r--r--devstack/settings8
2 files changed, 77 insertions, 20 deletions
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index 5c4c4f2..da0dab0 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -24,10 +24,12 @@
24# Notification transport wil be kafka:// 24# Notification transport wil be kafka://
25# 25#
26# Environment Configuration 26# Environment Configuration
27# RPC_SERVICE - the messaging backend service for RPC
27# RPC_HOST - the host used to connect to the RPC messaging service. 28# RPC_HOST - the host used to connect to the RPC messaging service.
28# RPC_PORT - the port used to connect to the RPC messaging service. 29# RPC_PORT - the port used to connect to the RPC messaging service.
29# Defaults to 5672. 30# Defaults to 5672.
30# RPC_{USERNAME,PASSWORD} - for authentication with RPC messaging service. 31# RPC_{USERNAME,PASSWORD} - for authentication with RPC messaging service.
32# NOTIFY_SERVICE - the messaging backend service for Notification
31# NOTIFY_HOST - the host used to connect to the Notification messaging service. 33# NOTIFY_HOST - the host used to connect to the Notification messaging service.
32# NOTIFY_PORT - the port used to connect to the Notification messaging service. 34# NOTIFY_PORT - the port used to connect to the Notification messaging service.
33# Defaults to 9092. 35# Defaults to 9092.
@@ -41,23 +43,38 @@ set +o xtrace
41# builds rpc transport url string 43# builds rpc transport url string
42function _get_rpc_transport_url { 44function _get_rpc_transport_url {
43 local virtual_host=$1 45 local virtual_host=$1
44 if [ -z "$RPC_USERNAME" ]; then 46
45 echo "amqp://$RPC_HOST:${RPC_PORT}/$virtual_host" 47 if [ "$RPC_SERVICE" == "rabbit" ]; then
48 echo $(_get_rabbit_transport_url $virtual_host)
49 elif [ -z "$RPC_USERNAME" ]; then
50 echo "$RPC_SERVICE://$RPC_HOST:${RPC_PORT}/$virtual_host"
46 else 51 else
47 echo "amqp://$RPC_USERNAME:$RPC_PASSWORD@$RPC_HOST:${RPC_PORT}/$virtual_host" 52 echo "$RPC_SERVICE://$RPC_USERNAME:$RPC_PASSWORD@$RPC_HOST:${RPC_PORT}/$virtual_host"
48 fi 53 fi
49} 54}
50 55
51# builds notify transport url string 56# builds notify transport url string
52function _get_notify_transport_url { 57function _get_notify_transport_url {
53 local virtual_host=$1 58 local virtual_host=$1
59
54 if [ -z "$NOTIFY_USERNAME" ]; then 60 if [ -z "$NOTIFY_USERNAME" ]; then
55 echo "kafka://$NOTIFY_HOST:${NOTIFY_PORT}/$virtual_host" 61 echo "$NOTIFY_SERVICE://$NOTIFY_HOST:${NOTIFY_PORT}/$virtual_host"
56 else 62 else
57 echo "kafka://$NOTIFY_USERNAME:$NOTIFY_PASSWORD@$NOTIFY_HOST:${NOTIFY_PORT}/$virtual_host" 63 echo "$NOTIFY_SERVICE://$NOTIFY_USERNAME:$NOTIFY_PASSWORD@$NOTIFY_HOST:${NOTIFY_PORT}/$virtual_host"
58 fi 64 fi
59} 65}
60 66
67# override the default in devstack
68function _rpc_add_vhost {
69
70 if [ "$RPC_SERVICE" == "rabbit" ]; then
71 _rabbit_rpc_backend_add_vhost $@
72 fi
73
74 # no configuration necessary for amqp backend
75 return 0
76}
77
61# Functions 78# Functions
62# ------------ 79# ------------
63# _download_kafka() - downloading kafka 80# _download_kafka() - downloading kafka
@@ -72,7 +89,9 @@ function _download_kafka {
72# driver 89# driver
73function _install_kafka_python { 90function _install_kafka_python {
74 # Install kafka client API 91 # Install kafka client API
92 # TODO(ansmith) remove kafka-python library following switch
75 pip_install_gr kafka-python 93 pip_install_gr kafka-python
94 pip_install_gr confluent-kafka
76} 95}
77 96
78# _install_kafka_backend() - installing Kafka with Scala and Zookeeper 97# _install_kafka_backend() - installing Kafka with Scala and Zookeeper
@@ -81,9 +100,11 @@ function _install_kafka_backend {
81 local scala_version=${SCALA_VERSION}.0 100 local scala_version=${SCALA_VERSION}.0
82 101
83 if is_ubuntu; then 102 if is_ubuntu; then
84 sudo apt-get install -y scala 103 sudo apt-get install -y scala librdkafka1
85 elif is_fedora; then 104 elif is_fedora; then
86 105
106 install_package librdkafka
107
87 is_package_installed java-1.8.0-openjdk-headless || install_package java-1.8.0-openjdk-headless 108 is_package_installed java-1.8.0-openjdk-headless || install_package java-1.8.0-openjdk-headless
88 109
89 if [ ! -f ${FILES}/scala-${scala_version}.tar.gz ]; then 110 if [ ! -f ${FILES}/scala-${scala_version}.tar.gz ]; then
@@ -142,6 +163,14 @@ function _cleanup_kafka {
142 echo_summary "Clean up kafka service" 163 echo_summary "Clean up kafka service"
143 rm ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz 164 rm ${FILES}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz
144 rm -rf ${KAFKA_DEST}/kafka 165 rm -rf ${KAFKA_DEST}/kafka
166
167 if is_ubuntu; then
168 uninstall_package librdkafka1
169 elif is_fedora; then
170 uninstall_package librdkafka
171 else
172 exit_distro_not_supported "kafka installation"
173 fi
145} 174}
146 175
147# Set up the various configuration files used by the qpid-dispatch-router (qdr) 176# Set up the various configuration files used by the qpid-dispatch-router (qdr)
@@ -361,9 +390,22 @@ function _cleanup_qdr_backend {
361 390
362if is_service_enabled kafka; then 391if is_service_enabled kafka; then
363 392
364 # Note: this is the only tricky part about out of tree 393 # this plugin can be configured to use rabbit for rpc,
365 # oslo.messaging plugins, you must overwrite the functions 394 # so save a copy of the original
366 # so that the correct settings files are made. 395 if [ ! $(type -t _get_rabbit_transport_url) ]; then
396 get_transport_url_definition=$(declare -f get_transport_url)
397 eval "_get_rabbit_transport_url() ${get_transport_url_definition#*\()}"
398 export -f _get_rabbit_transport_url
399 fi
400
401 # we will need original if using rabbit for rpc
402 if [ ! $(type -t _rabbit_rpc_backend_add_vhost) ]; then
403 rpc_backend_add_vhost_definition=$(declare -f rpc_backend_add_vhost)
404 eval "_rabbit_rpc_backend_add_vhost() ${rpc_backend_add_vhost_definition#*\()}"
405 export -f _rabbit_rpc_backend_add_vhost
406 fi
407
408 # export the overridden functions
367 function iniset_rpc_backend { 409 function iniset_rpc_backend {
368 local package=$1 410 local package=$1
369 local file=$2 411 local file=$2
@@ -373,21 +415,24 @@ if is_service_enabled kafka; then
373 iniset $file $section transport_url $(_get_rpc_transport_url "$virtual_host") 415 iniset $file $section transport_url $(_get_rpc_transport_url "$virtual_host")
374 iniset $file oslo_messaging_notifications transport_url $(_get_notify_transport_url "$virtual_host") 416 iniset $file oslo_messaging_notifications transport_url $(_get_notify_transport_url "$virtual_host")
375 } 417 }
418 export -f iniset_rpc_backend
419
376 function get_transport_url { 420 function get_transport_url {
377 # TODO (ansmith) introduce separate get_*_transport calls in devstak 421 # TODO (ansmith) introduce separate get_*_transport calls in devstak
378 _get_rpc_transport_url $@ 422 _get_rpc_transport_url $@
379 } 423 }
424 export -f get_transport_url
425
380 function get_notification_url { 426 function get_notification_url {
381 _get_notify_transport_url $@ 427 _get_notify_transport_url $@
382 } 428 }
429 export -f get_notification_url
430
383 function rpc_backend_add_vhost { 431 function rpc_backend_add_vhost {
384 return 0 432 _rpc_add_vhost $@
385 } 433 }
386
387 export -f iniset_rpc_backend
388 export -f get_transport_url
389 export -f get_notification_url
390 export -f rpc_backend_add_vhost 434 export -f rpc_backend_add_vhost
435
391fi 436fi
392 437
393# check for kafka service 438# check for kafka service
@@ -403,24 +448,32 @@ if is_service_enabled kafka; then
403 elif [[ "$1" == "stack" && "$2" == "install" ]]; then 448 elif [[ "$1" == "stack" && "$2" == "install" ]]; then
404 # Install and configure the messaging services 449 # Install and configure the messaging services
405 _install_kafka_backend 450 _install_kafka_backend
406 _install_qdr_backend 451 if [ "$RPC_SERVICE" == "amqp" ]; then
452 _install_qdr_backend
453 fi
407 454
408 elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then 455 elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
409 # Start the messaging service processes, this happens before 456 # Start the messaging service processes, this happens before
410 # any services start 457 # any services start
411 _start_kafka_backend 458 _start_kafka_backend
412 _start_qdr_backend 459 if [ "$RPC_SERVICE" == "amqp" ]; then
460 _start_qdr_backend
461 fi
413 462
414 elif [[ "$1" == "unstack" ]]; then 463 elif [[ "$1" == "unstack" ]]; then
415 # Shut down messaging services 464 # Shut down messaging services
416 _stop_kafka 465 _stop_kafka
417 _stop_qdr 466 if [ "$RPC_SERVICE" == "amqp" ]; then
467 _stop_qdr
468 fi
418 469
419 elif [[ "$1" == "clean" ]]; then 470 elif [[ "$1" == "clean" ]]; then
420 # Remove state and transient data 471 # Remove state and transient data
421 # Remember clean.sh first calls unstack.sh 472 # Remember clean.sh first calls unstack.sh
422 _cleanup_kafka 473 _cleanup_kafka
423 _cleanup_qdr 474 if [ "$RPC_SERVICE" == "amqp" ]; then
475 _cleanup_qdr
476 fi
424 fi 477 fi
425fi 478fi
426 479
diff --git a/devstack/settings b/devstack/settings
index 80027bc..a71f446 100644
--- a/devstack/settings
+++ b/devstack/settings
@@ -6,7 +6,7 @@ enable_service kafka
6KAFKA_DEST=${KAFKA_DEST:-/opt/stack/devstack-plugin-kafka} 6KAFKA_DEST=${KAFKA_DEST:-/opt/stack/devstack-plugin-kafka}
7 7
8# Specify Kafka version 8# Specify Kafka version
9KAFKA_VERSION=${KAFKA_VERSION:-1.1.0} 9KAFKA_VERSION=${KAFKA_VERSION:-2.0.0}
10KAFKA_BASEURL=${KAFKA_BASEURL:-http://www.apache.org/dist/kafka} 10KAFKA_BASEURL=${KAFKA_BASEURL:-http://www.apache.org/dist/kafka}
11 11
12# Specify Scala version 12# Specify Scala version
@@ -14,11 +14,15 @@ SCALA_VERSION=${SCALA_VERSION:-2.12}
14SCALA_BASEURL=${SCALA_BASEURL:-http://www.scala-lang.org/files/archive} 14SCALA_BASEURL=${SCALA_BASEURL:-http://www.scala-lang.org/files/archive}
15 15
16# RPC 16# RPC
17RPC_SERVICE=${RPC_SERVICE:-rabbit}
17RPC_HOST=${RPC_HOST:-$SERVICE_HOST} 18RPC_HOST=${RPC_HOST:-$SERVICE_HOST}
18RPC_PORT=${RPC_PORT:-5672} 19RPC_PORT=${RPC_PORT:-5672}
19 20
20# Notify 21# Notify
22NOTIFY_SERVICE=${NOTIFY_SERVICE:-kafka}
21NOTIFY_HOST=${NOTIFY_HOST:-$SERVICE_HOST} 23NOTIFY_HOST=${NOTIFY_HOST:-$SERVICE_HOST}
22NOTIFY_PORT=${NOTIFY_PORT:-9092} 24NOTIFY_PORT=${NOTIFY_PORT:-9092}
23 25
24disable_service rabbit 26if [ "$RPC_SERVICE" != "rabbit" ]; then
27 disable_service rabbit
28fi