Using new `["openstack"]["mq"]` attributes

Added grizzly rabbbit HA functionality, and switched to the
new mq attributes. Attributes were updated to allow global
and local overrides.

Change-Id: I10f92932fbe1bd256c5a6e10cd357a8ac5e5f1e0
This commit is contained in:
John Dewey 2013-07-03 20:49:32 -07:00
parent 0e25355340
commit be498fa94c
9 changed files with 131 additions and 73 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
.bundle/
.berkshelf
.kitchen

View File

@ -9,63 +9,57 @@
"openstack-image": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-image.git",
"ref": "5cc19cee1cb0becba653cdf7781e492bbe5f84e7"
"ref": "c4af085fd62b542fee13d3a8a4ffdc1885ce37ed"
},
"openstack-identity": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-identity.git",
"ref": "a1ae0fd1d2bba23975b3c6852411383be982faa5"
"ref": "029fe8a648939f832f844562d0e18af2a951c783"
},
"openstack-common": {
"locked_version": "0.2.6",
"locked_version": "0.3.0",
"git": "git://github.com/stackforge/cookbook-openstack-common.git",
"ref": "f8781d13de30fb3a191e97e91b13a3ccac139d6f"
"ref": "25b183f2362fa501cfee4db331491b3d984a5c05"
},
"apt": {
"locked_version": "1.10.0"
},
"database": {
"locked_version": "1.4.0"
},
"mysql": {
"locked_version": "3.0.0",
"constraint": ">= 1.3.0"
},
"openssl": {
"locked_version": "1.0.2"
},
"build-essential": {
"locked_version": "1.4.0"
},
"postgresql": {
"locked_version": "3.0.0",
"constraint": ">= 1.0.0"
},
"aws": {
"locked_version": "0.101.0"
},
"xfs": {
"locked_version": "1.1.0"
},
"openssh": {
"locked_version": "1.1.4"
"locked_version": "2.0.0"
},
"rabbitmq": {
"locked_version": "2.1.0"
"locked_version": "2.1.2"
},
"erlang": {
"locked_version": "1.3.0",
"constraint": ">= 0.9.0"
},
"yum": {
"locked_version": "2.2.2",
"locked_version": "2.3.0",
"constraint": ">= 0.5.0"
},
"build-essential": {
"locked_version": "1.4.0"
},
"selinux": {
"locked_version": "0.5.6"
},
"iptables": {
"locked_version": "0.12.0"
"database": {
"locked_version": "1.4.0"
},
"mysql": {
"locked_version": "3.0.2",
"constraint": ">= 1.3.0"
},
"openssl": {
"locked_version": "1.0.2"
},
"postgresql": {
"locked_version": "3.0.2",
"constraint": ">= 1.0.0"
},
"aws": {
"locked_version": "0.101.2"
},
"xfs": {
"locked_version": "1.1.0"
}
}
}

View File

@ -19,8 +19,6 @@ The following cookbooks are dependencies:
* openstack-common
* openstack-identity
* openstack-image
* openssh
* rabbitmq
* selinux (Fedora)
Usage
@ -47,6 +45,9 @@ Attributes
* `openstack["block-storage"]["db"]["username"]` - cinder username for database
* `openstack["block-storage"]["rabbit"]["username"]` - Username for cinder rabbit access
* `openstack["block-storage"]["rabbit"]["vhost"]` - The rabbit vhost to use
* `openstack["block-storage"]["rabbit"]["port"]` - The rabbit port to use
* `openstack["block-storage"]["rabbit"]["host"]` - The rabbit host to use (must set when `openstack["block-storage"]["rabbit"]["ha"]` false).
* `openstack["block-storage"]["rabbit"]["ha"]` - Whether or not to use rabbit ha
* `openstack["block-storage"]["service_tenant_name"]` - name of tenant to use for the cinder service account in keystone
* `openstack["block-storage"]["service_user"]` - cinder service user in keystone
* `openstack["block-storage"]["service_role"]` - role for the cinder service user in keystone

View File

@ -42,7 +42,7 @@ default["openstack"]["block-storage"]["region"] = "RegionOne"
# The name of the Chef role that knows about the message queue server
# that Cinder uses
default["openstack"]["block-storage"]["rabbit_server_chef_role"] = "rabbitmq-server"
default["openstack"]["block-storage"]["rabbit_server_chef_role"] = node["openstack"]["mq"]["server_role"]
# This is the name of the Chef role that will install the Keystone Service API
default["openstack"]["block-storage"]["keystone_service_chef_role"] = "keystone"
@ -73,8 +73,11 @@ default["openstack"]["block-storage"]["quota_driver"] = "cinder.quota.DbQuotaDri
# and accessed with openstack-common cookbook library's
# user_password routine. You are expected to create
# the user, pass, vhost in a wrapper rabbitmq cookbook.
default["openstack"]["block-storage"]["rabbit"]["username"] = "rabbit"
default["openstack"]["block-storage"]["rabbit"]["vhost"] = "/nova"
default["openstack"]["block-storage"]["rabbit"]["username"] = node["openstack"]["mq"]["user"]
default["openstack"]["block-storage"]["rabbit"]["vhost"] = node["openstack"]["mq"]["vhost"]
default["openstack"]["block-storage"]["rabbit"]["port"] = node["openstack"]["mq"]["port"]
default["openstack"]["block-storage"]["rabbit"]["host"] = node["openstack"]["mq"]["host"]
default["openstack"]["block-storage"]["rabbit"]["ha"] = false
default["openstack"]["block-storage"]["db"]["username"] = "cinder"

View File

@ -20,6 +20,4 @@ depends "apt"
depends "openstack-common", "~> 0.3.0"
depends "openstack-identity", "~> 7.0.0"
depends "openstack-image", "~> 7.0.0"
depends "openssh"
depends "rabbitmq"
depends "selinux"

View File

@ -26,12 +26,10 @@ db_user = node["openstack"]["block-storage"]["db"]["username"]
db_pass = db_password "cinder"
sql_connection = db_uri("volume", db_user, db_pass)
rabbit_server_role = node["openstack"]["block-storage"]["rabbit_server_chef_role"]
rabbit_info = config_by_role rabbit_server_role, "queue"
rabbit_user = node["openstack"]["block-storage"]["rabbit"]["username"]
rabbit_pass = user_password "rabbit"
rabbit_vhost = node["openstack"]["block-storage"]["rabbit"]["vhost"]
if node["openstack"]["block-storage"]["rabbit"]["ha"]
rabbit_hosts = rabbit_servers
end
rabbit_pass = user_password node["openstack"]["block-storage"]["rabbit"]["username"]
glance_api_endpoint = endpoint "image-api"
@ -49,13 +47,9 @@ template "/etc/cinder/cinder.conf" do
mode 00644
variables(
:sql_connection => sql_connection,
:rabbit_ipaddress => rabbit_info["host"],
:rabbit_user => rabbit_user,
:rabbit_password => rabbit_pass,
:rabbit_port => rabbit_info["port"],
:rabbit_virtual_host => rabbit_vhost,
:rabbit_hosts => rabbit_hosts,
:glance_host => glance_api_endpoint.host,
:glance_port => glance_api_endpoint.port
)
end

View File

@ -4,6 +4,9 @@ describe "openstack-block-storage::cinder-common" do
before { block_storage_stubs }
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["mq"] = {
"host" => "127.0.0.1"
}
n.set["openstack"]["block-storage"]["syslog"]["use"] = true
end
@chef_run.converge "openstack-block-storage::cinder-common"
@ -35,5 +38,69 @@ describe "openstack-block-storage::cinder-common" do
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
end
it "has rabbit_host" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_host=127.0.0.1"
end
it "does not have rabbit_hosts" do
expect(@chef_run).not_to create_file_with_content @file.name,
"rabbit_hosts="
end
it "does not have rabbit_ha_queues" do
expect(@chef_run).not_to create_file_with_content @file.name,
"rabbit_ha_queues="
end
it "has rabbit_port" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_port=5672"
end
it "has rabbit_userid" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_userid=guest"
end
it "has rabbit_password" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_password=rabbit-pass"
end
it "has rabbit_virtual_host" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_virtual_host=/"
end
describe "rabbit ha" do
before do
@chef_run = ::ChefSpec::ChefRunner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["block-storage"]["rabbit"]["ha"] = true
end
@chef_run.converge "openstack-block-storage::cinder-common"
end
it "has rabbit_hosts" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672"
end
it "has rabbit_ha_queues" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_ha_queues=True"
end
it "does not have rabbit_host" do
expect(@chef_run).not_to create_file_with_content @file.name,
"rabbit_host=127.0.0.1"
end
it "does not have rabbit_port" do
expect(@chef_run).not_to create_file_with_content @file.name,
"rabbit_port=5672"
end
end
end
end

View File

@ -13,16 +13,16 @@ require "chefspec"
}
def block_storage_stubs
::Chef::Recipe.any_instance.stub(:config_by_role)
::Chef::Recipe.any_instance.stub(:config_by_role).
with("rabbitmq-server", "queue").and_return(
{'host' => 'rabbit-host', 'port' => 'rabbit-port'}
)
::Chef::Recipe.any_instance.stub(:rabbit_servers).
and_return "1.1.1.1:5672,2.2.2.2:5672"
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
::Chef::Recipe.any_instance.stub(:db_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).
with("guest").
and_return "rabbit-pass"
::Chef::Recipe.any_instance.stub(:service_password).and_return String.new
::Chef::Recipe.any_instance.stub(:service_password).with("cinder").
and_return "cinder-pass"

View File

@ -371,25 +371,34 @@ db_backend=sqlalchemy
# kombu_ssl_ca_certs=
#### (StrOpt) SSL certification authority file (valid only if SSL enabled)
rabbit_host=<%= @rabbit_ipaddress %>
<% if node["openstack"]["block-storage"]["rabbit"]["ha"] -%>
rabbit_hosts=<%= @rabbit_hosts %>
#### (ListOpt) RabbitMQ HA cluster host:port pairs
# rabbit_durable_queues=false
#### (BoolOpt) use durable queues in RabbitMQ
rabbit_ha_queues=True
#### (BoolOpt) use H/A queues in RabbitMQ (x-ha-policy: all).You need to
#### wipe RabbitMQ database when changing this option.
<% else -%>
rabbit_host=<%= node["openstack"]["block-storage"]["rabbit"]["host"] %>
#### (StrOpt) The RabbitMQ broker address where a single node is used
rabbit_port=<%= @rabbit_port %>
rabbit_port=<%= node["openstack"]["block-storage"]["rabbit"]["port"] %>
#### (IntOpt) The RabbitMQ broker port where a single node is used
# rabbit_hosts=$rabbit_host:$rabbit_port
#### (ListOpt) RabbitMQ HA cluster host:port pairs
<% end -%>
# rabbit_use_ssl=false
#### (BoolOpt) connect over SSL for RabbitMQ
rabbit_userid=<%= @rabbit_user %>
rabbit_userid=<%= node["openstack"]["block-storage"]["rabbit"]["username"] %>
#### (StrOpt) the RabbitMQ userid
rabbit_password=<%= @rabbit_password %>
#### (StrOpt) the RabbitMQ password
rabbit_virtual_host=<%= @rabbit_virtual_host %>
rabbit_virtual_host=<%= node["openstack"]["block-storage"]["rabbit"]["vhost"] %>
#### (StrOpt) the RabbitMQ virtual host
# rabbit_retry_interval=1
@ -403,13 +412,6 @@ rabbit_virtual_host=<%= @rabbit_virtual_host %>
#### (IntOpt) maximum retries with trying to connect to RabbitMQ (the
#### default of 0 implies an infinite retry count)
# rabbit_durable_queues=false
#### (BoolOpt) use durable queues in RabbitMQ
# rabbit_ha_queues=false
#### (BoolOpt) use H/A queues in RabbitMQ (x-ha-policy: all).You need to
#### wipe RabbitMQ database when changing this option.
######## defined in cinder.openstack.common.rpc.impl_qpid ########