From fbcfd04ff35cc0a3f419b7a2cb1f7876dab6831f Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Wed, 15 Jan 2014 12:00:27 +0000 Subject: [PATCH] Move to use "get_password" instead of "{user,service,db}_password" The user_password, service_password and db_password functions are redundant since they simply call "secret". Creates a get_password function that will accept a "type" of db, service or user. All instances of these calls have been changed to call get_password Change-Id: Ic73c99034638ec092192d11e37671edbba0e48ef Partial-Bug: #1195915 --- recipes/rabbitmq-server.rb | 4 ++-- spec/spec_helper.rb | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/recipes/rabbitmq-server.rb b/recipes/rabbitmq-server.rb index 721a26d..d86a001 100644 --- a/recipes/rabbitmq-server.rb +++ b/recipes/rabbitmq-server.rb @@ -25,7 +25,7 @@ end rabbit_server_role = node["openstack"]["mq"]["server_role"] user = node["openstack"]["mq"]["user"] -pass = user_password user +pass = get_password "user", user vhost = node["openstack"]["mq"]["vhost"] bind_interface = node["openstack"]["mq"]["bind_interface"] listen_address = address_for node["openstack"]["mq"]["bind_interface"] @@ -42,7 +42,7 @@ node.override["rabbitmq"]["use_distro_version"] = true # Clustering if node["openstack"]["mq"]["cluster"] node.override["rabbitmq"]["cluster"] = node["openstack"]["mq"]["cluster"] - node.override["rabbitmq"]["erlang_cookie"] = service_password "rabbit_cookie" + node.override["rabbitmq"]["erlang_cookie"] = get_password "service", "rabbit_cookie" qs = "roles:#{rabbit_server_role} AND chef_environment:#{node.chef_environment}" node.override["rabbitmq"]["cluster_disk_nodes"] = search(:node, qs).map do |n| "#{user}@#{n['hostname']}" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7a744c9..00819db 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -27,9 +27,10 @@ def ops_messaging_stubs { 'hostname' => 'host2' }, { 'hostname' => 'host1' } ] - ::Chef::Recipe.any_instance.stub(:user_password). + ::Chef::Recipe.any_instance.stub(:get_password). + with("user", anything()). and_return "rabbit-pass" - ::Chef::Recipe.any_instance.stub(:service_password). - with("rabbit_cookie"). + ::Chef::Recipe.any_instance.stub(:get_password). + with("service", "rabbit_cookie"). and_return "erlang-cookie" end