From ed595d5fe63688c3e2f26d36252c4ad11ec86105 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Thu, 16 Jan 2014 15:42:20 +0000 Subject: [PATCH] Clean up cookbook for bp/clean-up-attr-for-mq-and-db This change removes the attributes we'll be moving to openstack-common and changes reference of those attributes to reflect new (more consistent) namespace. We also fix a test which isn't converging after having node attributes set. Lastly, we handle the rabbit mq attribute use_ssl. Change-Id: Ic9bfc769781c222b84d1e6e86df4306755c64e70 Implements: blueprint clean-up-attr-for-mq-and-db --- attributes/default.rb | 33 -------------------------- recipes/nova-common.rb | 10 ++++---- spec/nova-common-redhat_spec.rb | 2 +- spec/nova-common_spec.rb | 6 +++-- templates/default/nova.conf.erb | 41 +++++++++++++++++---------------- 5 files changed, 31 insertions(+), 61 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index f887c7eb..3a889de8 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -22,11 +22,6 @@ default['openstack']['compute']['debug'] = 'False' # The name of the Chef role that sets up the Keystone Service API default['openstack']['compute']['identity_service_chef_role'] = 'os-identity' -# This user's password is stored in an encrypted databag -# and accessed with openstack-common cookbook library's -# get_password routine. -default['openstack']['compute']['db']['username'] = 'nova' - # Common rpc definitions default['openstack']['compute']['rpc_thread_pool_size'] = 64 default['openstack']['compute']['rpc_conn_pool_size'] = 30 @@ -38,16 +33,6 @@ when 'qpid' default['openstack']['compute']['rpc_backend'] = 'nova.openstack.common.rpc.impl_qpid' end -# This user's password is stored in an encrypted databag -# and accessed with openstack-common cookbook library's -# get_password routine. You are expected to create -# the user, pass, vhost in a wrapper rabbitmq cookbook. -default['openstack']['compute']['rabbit']['username'] = 'guest' -default['openstack']['compute']['rabbit']['vhost'] = '/' -default['openstack']['compute']['rabbit']['port'] = 5672 -default['openstack']['compute']['rabbit']['host'] = '127.0.0.1' -default['openstack']['compute']['rabbit']['ha'] = false - default['openstack']['compute']['service_tenant_name'] = 'service' default['openstack']['compute']['service_user'] = 'nova' default['openstack']['compute']['service_role'] = 'admin' @@ -78,24 +63,6 @@ default['openstack']['compute']['network']['service_type'] = 'nova' # plugins from openstack-network default['openstack']['compute']['network']['plugins'] = ['openvswitch'] -# MQ options -default['openstack']['compute']['mq']['service_type'] = node['openstack']['mq']['service_type'] -default['openstack']['compute']['mq']['qpid']['host'] = '127.0.0.1' -default['openstack']['compute']['mq']['qpid']['port'] = '5672' -default['openstack']['compute']['mq']['qpid']['qpid_hosts'] = ['127.0.0.1:5672'] - -default['openstack']['compute']['mq']['qpid']['username'] = '' -default['openstack']['compute']['mq']['qpid']['password'] = '' -default['openstack']['compute']['mq']['qpid']['sasl_mechanisms'] = '' -default['openstack']['compute']['mq']['qpid']['reconnect_timeout'] = 0 -default['openstack']['compute']['mq']['qpid']['reconnect_limit'] = 0 -default['openstack']['compute']['mq']['qpid']['reconnect_interval_min'] = 0 -default['openstack']['compute']['mq']['qpid']['reconnect_interval_max'] = 0 -default['openstack']['compute']['mq']['qpid']['reconnect_interval'] = 0 -default['openstack']['compute']['mq']['qpid']['heartbeat'] = 60 -default['openstack']['compute']['mq']['qpid']['protocol'] = 'tcp' -default['openstack']['compute']['mq']['qpid']['tcp_nodelay'] = true - # Neutron options default['openstack']['compute']['network']['neutron']['network_api_class'] = 'nova.network.neutronv2.api.API' default['openstack']['compute']['network']['neutron']['auth_strategy'] = 'keystone' diff --git a/recipes/nova-common.rb b/recipes/nova-common.rb index 264206b5..cda5161a 100644 --- a/recipes/nova-common.rb +++ b/recipes/nova-common.rb @@ -41,7 +41,7 @@ platform_options["common_packages"].each do |pkg| end end -db_type = node['openstack']['db']['compute']['db_type'] +db_type = node['openstack']['db']['compute']['service_type'] platform_options["#{db_type}_python_packages"].each do |pkg| package pkg do action :install @@ -63,15 +63,15 @@ directory "/etc/nova" do action :create end -db_user = node["openstack"]["compute"]["db"]["username"] +db_user = node["openstack"]["db"]["compute"]["username"] db_pass = get_password "db", "nova" sql_connection = db_uri("compute", db_user, db_pass) -if node["openstack"]["compute"]["mq"]["service_type"] == "rabbitmq" - if node["openstack"]["compute"]["rabbit"]["ha"] +if node["openstack"]["mq"]["compute"]["service_type"] == "rabbitmq" + if node["openstack"]["mq"]["compute"]["rabbit"]["ha"] rabbit_hosts = rabbit_servers end - rabbit_pass = get_password "user", node["openstack"]["compute"]["rabbit"]["username"] + rabbit_pass = get_password "user", node["openstack"]["mq"]["compute"]["rabbit"]["userid"] end # check attributes before search diff --git a/spec/nova-common-redhat_spec.rb b/spec/nova-common-redhat_spec.rb index 1ac7bd25..62e559e8 100644 --- a/spec/nova-common-redhat_spec.rb +++ b/spec/nova-common-redhat_spec.rb @@ -23,7 +23,7 @@ describe "openstack-compute::nova-common" do it "installs db2 python packages if explicitly told" do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["compute"]["db_type"] = "db2" + node.set["openstack"]["db"]["compute"]["service_type"] = "db2" chef_run.converge "openstack-compute::nova-common" ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb index c562fc21..5e491c68 100644 --- a/spec/nova-common_spec.rb +++ b/spec/nova-common_spec.rb @@ -74,6 +74,7 @@ describe "openstack-compute::nova-common" do /^rabbit_virtual_host=\/$/, /^rabbit_host=127.0.0.1$/, /^rabbit_port=5672$/, + /^rabbit_use_ssl=false$/, /^allow_resize_to_same_host=false$/, /^vncserver_listen=127.0.1.1$/, /^vncserver_proxyclient_address=127.0.1.1$/, @@ -130,7 +131,8 @@ describe "openstack-compute::nova-common" do context "qpid" do before { - @chef_run.node.set['openstack']['compute']['mq']['service_type'] = "qpid" + @chef_run.node.set['openstack']['mq']['compute']['service_type'] = "qpid" + @chef_run.converge "openstack-compute::nova-common" } array = [/^qpid_hostname=127.0.0.1$/, @@ -157,7 +159,7 @@ describe "openstack-compute::nova-common" do describe "rabbit ha" do before do @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| - n.set["openstack"]["compute"]["rabbit"]["ha"] = true + n.set["openstack"]["mq"]["compute"]["rabbit"]["ha"] = true n.set["cpu"] = { "total" => "2" } diff --git a/templates/default/nova.conf.erb b/templates/default/nova.conf.erb index 13eda6cd..dc881efc 100644 --- a/templates/default/nova.conf.erb +++ b/templates/default/nova.conf.erb @@ -21,37 +21,38 @@ rpc_conn_pool_size=<%= node["openstack"]["compute"]["rpc_conn_pool_size"] %> rpc_response_timeout=<%= node["openstack"]["compute"]["rpc_response_timeout"] %> rpc_backend=<%= node["openstack"]["compute"]["rpc_backend"] %> -<% if node["openstack"]["compute"]["mq"]["service_type"] == "rabbitmq" %> +<% if node["openstack"]["mq"]["compute"]["service_type"] == "rabbitmq" %> ##### RABBITMQ ##### -rabbit_userid=<%= node["openstack"]["compute"]["rabbit"]["username"] %> +rabbit_userid=<%= node["openstack"]["mq"]["compute"]["rabbit"]["userid"] %> rabbit_password=<%= @rabbit_password %> -rabbit_virtual_host=<%= node["openstack"]["compute"]["rabbit"]["vhost"] %> -<% if node["openstack"]["compute"]["rabbit"]["ha"] -%> +rabbit_virtual_host=<%= node["openstack"]["mq"]["compute"]["rabbit"]["vhost"] %> +<% if node["openstack"]["mq"]["compute"]["rabbit"]["ha"] -%> rabbit_hosts=<%= @rabbit_hosts %> rabbit_ha_queues=True <% else -%> -rabbit_host=<%= node["openstack"]["compute"]["rabbit"]["host"] %> -rabbit_port=<%= node["openstack"]["compute"]["rabbit"]["port"] %> +rabbit_host=<%= node["openstack"]["mq"]["compute"]["rabbit"]["host"] %> +rabbit_port=<%= node["openstack"]["mq"]["compute"]["rabbit"]["port"] %> +rabbit_use_ssl=<%= node["openstack"]["mq"]["compute"]["rabbit"]["use_ssl"] %> <% end -%> <% end -%> -<% if node["openstack"]["compute"]["mq"]["service_type"] == "qpid" %> +<% if node["openstack"]["mq"]["compute"]["service_type"] == "qpid" %> ##### QPID ##### -qpid_hostname=<%= node["openstack"]["compute"]["mq"]["qpid"]["host"] %> -qpid_port=<%= node["openstack"]["compute"]["mq"]["qpid"]["port"] %> +qpid_hostname=<%= node["openstack"]["mq"]["compute"]["qpid"]["host"] %> +qpid_port=<%= node["openstack"]["mq"]["compute"]["qpid"]["port"] %> -qpid_password=<%= node["openstack"]["compute"]["mq"]["qpid"]["password"] %> -qpid_username=<%= node["openstack"]["compute"]["mq"]["qpid"]["username"] %> -qpid_sasl_mechanisms=<%= node["openstack"]["compute"]["mq"]["qpid"]["sasl_mechanisms"] %> -qpid_reconnect_timeout=<%= node["openstack"]["compute"]["mq"]["qpid"]["reconnect_timeout"] %> -qpid_reconnect_limit=<%= node["openstack"]["compute"]["mq"]["qpid"]["reconnect_limit"] %> -qpid_reconnect_interval_min=<%= node["openstack"]["compute"]["mq"]["qpid"]["reconnect_interval_min"] %> -qpid_reconnect_interval_max=<%= node["openstack"]["compute"]["mq"]["qpid"]["reconnect_interval_max"] %> -qpid_reconnect_interval=<%= node["openstack"]["compute"]["mq"]["qpid"]["reconnect_interval"] %> -qpid_heartbeat=<%= node["openstack"]["compute"]["mq"]["qpid"]["heartbeat"] %> +qpid_password=<%= node["openstack"]["mq"]["compute"]["qpid"]["password"] %> +qpid_username=<%= node["openstack"]["mq"]["compute"]["qpid"]["username"] %> +qpid_sasl_mechanisms=<%= node["openstack"]["mq"]["compute"]["qpid"]["sasl_mechanisms"] %> +qpid_reconnect_timeout=<%= node["openstack"]["mq"]["compute"]["qpid"]["reconnect_timeout"] %> +qpid_reconnect_limit=<%= node["openstack"]["mq"]["compute"]["qpid"]["reconnect_limit"] %> +qpid_reconnect_interval_min=<%= node["openstack"]["mq"]["compute"]["qpid"]["reconnect_interval_min"] %> +qpid_reconnect_interval_max=<%= node["openstack"]["mq"]["compute"]["qpid"]["reconnect_interval_max"] %> +qpid_reconnect_interval=<%= node["openstack"]["mq"]["compute"]["qpid"]["reconnect_interval"] %> +qpid_heartbeat=<%= node["openstack"]["mq"]["compute"]["qpid"]["heartbeat"] %> # qpid protocol. default 'tcp'. set to 'ssl' to enable SSL -qpid_protocol=<%= node["openstack"]["compute"]["mq"]["qpid"]["protocol"] %> -qpid_tcp_nodelay=<%= node["openstack"]["compute"]["mq"]["qpid"]["tcp_nodelay"] %> +qpid_protocol=<%= node["openstack"]["mq"]["compute"]["qpid"]["protocol"] %> +qpid_tcp_nodelay=<%= node["openstack"]["mq"]["compute"]["qpid"]["tcp_nodelay"] %> <% end %>