From af56ea08c960dafd8d95de145fc554a08414ed1a Mon Sep 17 00:00:00 2001 From: Oleksiy Molchanov Date: Fri, 10 Mar 2017 17:50:09 +0200 Subject: [PATCH] Add transport_url handling Change-Id: I1868473bff4f6e4b91354d8da34d35bf488ab948 Closes-Bug: 1670324 --- deployment_scripts/rabbitmq_hiera_override.pp | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/deployment_scripts/rabbitmq_hiera_override.pp b/deployment_scripts/rabbitmq_hiera_override.pp index 0b9ebbe..a6a9c5b 100644 --- a/deployment_scripts/rabbitmq_hiera_override.pp +++ b/deployment_scripts/rabbitmq_hiera_override.pp @@ -6,20 +6,30 @@ $detach_rabbitmq_plugin = hiera($plugin_name, undef) if ($detach_rabbitmq_plugin) { $hiera_plugins_dir = '/etc/hiera/plugins' $plugin_yaml = "${hiera_plugins_dir}/${plugin_name}.yaml" + + $amqp_port = hiera('amqp_port', '5673') + $amqp_hosts = hiera('amqp_hosts') + $network_metadata = hiera_hash('network_metadata') - $rabbitmq_roles = [ 'primary-standalone-rabbitmq', 'standalone-rabbitmq' ] - $rabbit_nodes = get_nodes_hash_by_roles($network_metadata, $rabbitmq_roles) + $rabbitmq_roles = [ 'primary-standalone-rabbitmq', 'standalone-rabbitmq' ] + $rabbit_nodes = get_nodes_hash_by_roles($network_metadata, $rabbitmq_roles) - $rabbit_address_map = get_node_to_ipaddr_map_by_network_role( - $rabbit_nodes, - 'mgmt/messaging' - ) + $rabbit_hash = hiera_hash('rabbit', {}) - $rabbit_nodes_ips = values($rabbit_address_map) - $rabbit_nodes_names = keys($rabbit_address_map) + if !$rabbit_hash['user'] { + $real_rabbit_hash = merge($rabbit_hash, { 'user' => 'nova' }) + } else { + $real_rabbit_hash = $rabbit_hash + } - $amqp_hosts = $rabbit_nodes_ips - $amqp_port = hiera('amqp_port', '5673') + $rabbit_user = $real_rabbit_hash['user'] + $rabbit_password = $real_rabbit_hash['password'] + $transport_url = os_transport_url({ + 'transport' => 'rabbit', + 'hosts' => strip(split($amqp_hosts,',')), + 'username' => $rabbit_user, + 'password' => $rabbit_password, + }) case hiera_array('roles', 'none') { /standalone-rabbitmq/: { @@ -36,9 +46,9 @@ if ($detach_rabbitmq_plugin) { $calculated_content = inline_template('<% require "yaml" -amqp_hosts = @amqp_hosts.map {|x| x + ":" + @amqp_port}.join(",") data = { - "amqp_hosts" => amqp_hosts, + "amqp_hosts" => @amqp_hosts, + "transport_url" => @transport_url, "rabbit" => { "enabled" => @rabbit_enabled, },