Use get_password method to obtain qpid password
Currently, qpid's password is stored in an attribute in the common cookbook. This change causes the password to be looked up via get_password method, which is how we obtain the rabbitmq password. Change-Id: If95c39af79d49894503631fb8acadb4bf8cd0d45 Implements: blueprint use-data-bag-for-qpid-password
This commit is contained in:
		@@ -34,11 +34,15 @@ db_user = node['openstack']['db']['block-storage']['username']
 | 
			
		||||
db_pass = get_password 'db', 'cinder'
 | 
			
		||||
sql_connection = db_uri('block-storage', db_user, db_pass)
 | 
			
		||||
 | 
			
		||||
if node['openstack']['mq']['block-storage']['service_type'] == 'rabbitmq'
 | 
			
		||||
mq_service_type = node['openstack']['mq']['block-storage']['service_type']
 | 
			
		||||
 | 
			
		||||
if mq_service_type == 'rabbitmq'
 | 
			
		||||
  if node['openstack']['mq']['block-storage']['rabbit']['ha']
 | 
			
		||||
    rabbit_hosts = rabbit_servers
 | 
			
		||||
  end
 | 
			
		||||
  rabbit_pass = get_password 'user', node['openstack']['mq']['block-storage']['rabbit']['userid']
 | 
			
		||||
  mq_password = get_password 'user', node['openstack']['mq']['block-storage']['rabbit']['userid']
 | 
			
		||||
elsif mq_service_type == 'qpid'
 | 
			
		||||
  mq_password = get_password 'user', node['openstack']['mq']['block-storage']['qpid']['username']
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if node['openstack']['block-storage']['volume']['driver'] == 'cinder.volume.drivers.solidfire.SolidFire'
 | 
			
		||||
@@ -61,7 +65,8 @@ template '/etc/cinder/cinder.conf' do
 | 
			
		||||
  mode 00644
 | 
			
		||||
  variables(
 | 
			
		||||
    sql_connection: sql_connection,
 | 
			
		||||
    rabbit_password: rabbit_pass,
 | 
			
		||||
    mq_service_type: mq_service_type,
 | 
			
		||||
    mq_password: mq_password,
 | 
			
		||||
    rabbit_hosts: rabbit_hosts,
 | 
			
		||||
    glance_host: glance_api_endpoint.host,
 | 
			
		||||
    glance_port: glance_api_endpoint.port,
 | 
			
		||||
 
 | 
			
		||||
@@ -116,7 +116,7 @@ describe 'openstack-block-storage::cinder-common' do
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'has rabbit_password' do
 | 
			
		||||
      expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=rabbit-pass')
 | 
			
		||||
      expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=mq-pass')
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'has rabbit_virtual_host' do
 | 
			
		||||
@@ -154,10 +154,14 @@ describe 'openstack-block-storage::cinder-common' do
 | 
			
		||||
 | 
			
		||||
    describe 'qpid' do
 | 
			
		||||
      before do
 | 
			
		||||
        @file = @chef_run.template '/etc/cinder/cinder.conf'
 | 
			
		||||
        @chef_run.node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
 | 
			
		||||
        @chef_run.node.set['openstack']['block-storage']['notification_driver'] = 'cinder.test_driver'
 | 
			
		||||
        @chef_run.node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_topic'
 | 
			
		||||
        @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
 | 
			
		||||
          n.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
 | 
			
		||||
          n.set['openstack']['block-storage']['notification_driver'] = 'cinder.test_driver'
 | 
			
		||||
          n.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_topic'
 | 
			
		||||
          # we set username here since the attribute in common currently
 | 
			
		||||
          # defaults to ''
 | 
			
		||||
          n.set['openstack']['mq']['block-storage']['qpid']['username'] = 'guest'
 | 
			
		||||
        end
 | 
			
		||||
        @chef_run.converge 'openstack-block-storage::cinder-common'
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@@ -170,11 +174,11 @@ describe 'openstack-block-storage::cinder-common' do
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'has qpid_username' do
 | 
			
		||||
        expect(@chef_run).to render_file(@file.name).with_content('qpid_username=')
 | 
			
		||||
        expect(@chef_run).to render_file(@file.name).with_content('qpid_username=guest')
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'has qpid_password' do
 | 
			
		||||
        expect(@chef_run).to render_file(@file.name).with_content('qpid_password=')
 | 
			
		||||
        expect(@chef_run).to render_file(@file.name).with_content('qpid_password=mq-pass')
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'has qpid_sasl_mechanisms' do
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ def block_storage_stubs # rubocop:disable MethodLength
 | 
			
		||||
    .and_return('b0ff3bba-e07b-49b1-beed-09a45552b1ad')
 | 
			
		||||
  ::Chef::Recipe.any_instance.stub(:get_password)
 | 
			
		||||
    .with('user', 'guest')
 | 
			
		||||
    .and_return('rabbit-pass')
 | 
			
		||||
    .and_return('mq-pass')
 | 
			
		||||
  ::Chef::Recipe.any_instance.stub(:get_password)
 | 
			
		||||
    .with('user', 'solidfire_admin')
 | 
			
		||||
    .and_return('solidfire_testpass')
 | 
			
		||||
 
 | 
			
		||||
@@ -355,7 +355,7 @@ rpc_response_timeout=<%= node["openstack"]["block-storage"]["rpc_response_timeou
 | 
			
		||||
####           receiving exception data from an rpc call.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<% if node["openstack"]["mq"]["block-storage"]["service_type"] == "rabbitmq"  %>
 | 
			
		||||
<% if @mq_service_type == "rabbitmq"  %>
 | 
			
		||||
 | 
			
		||||
# fake_rabbit=false
 | 
			
		||||
#### (BoolOpt) If passed, use a fake RabbitMQ provider
 | 
			
		||||
@@ -398,7 +398,7 @@ rabbit_use_ssl=<%= node["openstack"]["mq"]["block-storage"]["rabbit"]["use_ssl"]
 | 
			
		||||
rabbit_userid=<%= node["openstack"]["mq"]["block-storage"]["rabbit"]["userid"] %>
 | 
			
		||||
#### (StrOpt) the RabbitMQ userid
 | 
			
		||||
 | 
			
		||||
rabbit_password=<%= @rabbit_password %>
 | 
			
		||||
rabbit_password=<%= @mq_password %>
 | 
			
		||||
#### (StrOpt) the RabbitMQ password
 | 
			
		||||
 | 
			
		||||
rabbit_virtual_host=<%= node["openstack"]["mq"]["block-storage"]["rabbit"]["vhost"] %>
 | 
			
		||||
@@ -421,7 +421,7 @@ notification_topics=<%= node["openstack"]["mq"]["block-storage"]["rabbit"]["noti
 | 
			
		||||
<% end %>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<% if node["openstack"]["mq"]["block-storage"]["service_type"] == "qpid"  %>
 | 
			
		||||
<% if @mq_service_type == "qpid"  %>
 | 
			
		||||
 | 
			
		||||
##### QPID #####
 | 
			
		||||
######## defined in cinder.openstack.common.rpc.impl_qpid ########
 | 
			
		||||
@@ -436,7 +436,7 @@ qpid_port=<%= node["openstack"]["mq"]["block-storage"]["qpid"]["port"] %>
 | 
			
		||||
qpid_username=<%= node["openstack"]["mq"]["block-storage"]["qpid"]["username"] %>
 | 
			
		||||
#### (StrOpt) Username for qpid connection
 | 
			
		||||
 | 
			
		||||
qpid_password=<%= node["openstack"]["mq"]["block-storage"]["qpid"]["password"] %>
 | 
			
		||||
qpid_password=<%= @mq_password %>
 | 
			
		||||
#### (StrOpt) Password for qpid connection
 | 
			
		||||
 | 
			
		||||
qpid_sasl_mechanisms=<%= node["openstack"]["mq"]["block-storage"]["qpid"]["sasl_mechanisms"] %>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user