From dd17718ce2f5d40d97265442f44bcf4da112c9cb Mon Sep 17 00:00:00 2001 From: salmanbaset Date: Thu, 28 Nov 2013 12:55:51 +0800 Subject: [PATCH] Adding qpid support to glance Moving all mq related parameters under default["openstack"]["image"]["mq"] so that other mq options can be added under it. Eventually, all rabbit options will be brought under it. Bumped up version to 7.1.0 Implements: blueprint qpid-activemq-support Change-Id: Ie0ed02a9262136c208d88d05f2431ff351e2edb2 --- CHANGELOG.md | 4 ++ README.md | 21 ++++++++ attributes/default.rb | 21 ++++++++ metadata.rb | 2 +- spec/api_spec.rb | 78 +++++++++++++++++++++++++++ spec/spec_helper.rb | 2 + templates/default/glance-api.conf.erb | 45 +++++++++------- 7 files changed, 153 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be06d3..7accfdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file is used to list changes made in each version of cookbook-openstack-image. +## 7.1.0 +### Blue print +* Add qpid support to glance. Default is rabbit + ## 7.0.6 ### Bug * Do not delete the sqlite database layed down by the glance packages when node.openstack.db.image.db_type is set to sqlite. diff --git a/README.md b/README.md index 9fcfbfe..55973fa 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,26 @@ Attributes for the Image service are in the ['openstack']['image'] namespace. * `openstack['image']['api']['rbd']['rbd_store_chunk_size']` - Size in MB of chunks for RADOS Store, should be a power of 2 * `openstack['image']['cron']['redirection']` - Redirection of cron output + +MQ attributes +------------- +* `openstack['image']['mq']['service_type']` - Select qpid or rabbitmq. default rabbitmq +* `openstack['image']['mq']['notifier_strategy']` - Notifier stragegy. default noop. +* `openstack['image']['mq']['qpid']['host']` - The qpid host to use +* `openstack['image']['mq']['qpid']['port']` - The qpid port to use +* `openstack['image']['mq']['qpid']['qpid_hosts']` - Qpid hosts. TODO. use only when ha is specified. +* `openstack['image']['mq']['qpid']['username']` - Username for qpid connection +* `openstack['image']['mq']['qpid']['password']` - Password for qpid connection +* `openstack['image']['mq']['qpid']['sasl_mechanisms']` - Space separated list of SASL mechanisms to use for auth +* `openstack['image']['mq']['qpid']['reconnect_timeout']` - The number of seconds to wait before deciding that a reconnect attempt has failed. +* `openstack['image']['mq']['qpid']['reconnect_limit']` - The limit for the number of times to reconnect before considering the connection to be failed. +* `openstack['image']['mq']['qpid']['reconnect_interval_min']` - Minimum number of seconds between connection attempts. +* `openstack['image']['mq']['qpid']['reconnect_interval_max']` - Maximum number of seconds between connection attempts. +* `openstack['image']['mq']['qpid']['reconnect_interval']` - Equivalent to setting qpid_reconnect_interval_min and qpid_reconnect_interval_max to the same value. +* `openstack['image']['mq']['qpid']['heartbeat']` - Seconds between heartbeat messages sent to ensure that the connection is still alive. +* `openstack['image']['mq']['qpid']['protocol']` - Protocol to use. Default tcp. +* `openstack['image']['mq']['qpid']['tcp_nodelay']` - Disable the Nagle algorithm. default disabled. + Testing ===== @@ -149,6 +169,7 @@ Author:: John Dewey () Author:: Craig Tracey () Author:: Sean Gallagher () Author:: Mark Vanderwiel () +Author:: Salman Baset () Copyright 2012, Rackspace US, Inc. Copyright 2012-2013, Opscode, Inc. diff --git a/attributes/default.rb b/attributes/default.rb index d5440a7..9e91236 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -53,6 +53,27 @@ default["openstack"]["image"]["rabbit"]["vhost"] = "/" default["openstack"]["image"]["rabbit"]["port"] = 5672 default["openstack"]["image"]["rabbit"]["host"] = "127.0.0.1" +# MQ options +default["openstack"]["image"]["mq"]["service_type"] = node["openstack"]["mq"]["service_type"] +default["openstack"]["image"]["mq"]["notifier_strategy"] = "noop" +default["openstack"]["image"]["mq"]["qpid"]["host"] = "127.0.0.1" +default["openstack"]["image"]["mq"]["qpid"]["port"] = "5672" +default["openstack"]["image"]["mq"]["qpid"]["qpid_hosts"] = ['127.0.0.1:5672'] + +default["openstack"]["image"]["mq"]["qpid"]["username"] = "" +default["openstack"]["image"]["mq"]["qpid"]["password"] = "" +default["openstack"]["image"]["mq"]["qpid"]["sasl_mechanisms"] = "" +default["openstack"]["image"]["mq"]["qpid"]["reconnect"] = true +default["openstack"]["image"]["mq"]["qpid"]["reconnect_timeout"] = 0 +default["openstack"]["image"]["mq"]["qpid"]["reconnect_limit"] = 0 +default["openstack"]["image"]["mq"]["qpid"]["reconnect_interval_min"] = 0 +default["openstack"]["image"]["mq"]["qpid"]["reconnect_interval_max"] = 0 +default["openstack"]["image"]["mq"]["qpid"]["reconnect_interval"] = 0 +default["openstack"]["image"]["mq"]["qpid"]["heartbeat"] = 60 +default["openstack"]["image"]["mq"]["qpid"]["protocol"] = "tcp" +default["openstack"]["image"]["mq"]["qpid"]["tcp_nodelay"] = true + + default["openstack"]["image"]["service_tenant_name"] = "service" default["openstack"]["image"]["service_user"] = "glance" default["openstack"]["image"]["service_role"] = "admin" diff --git a/metadata.rb b/metadata.rb index 250f596..13d339e 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer "Opscode, Inc." license "Apache 2.0" description "Installs and configures the Glance Image Registry and Delivery Service" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "7.0.6" +version "7.1.0" recipe "openstack-image::api", "Installs packages required for a glance api server" recipe "openstack-image::registry", "Installs packages required for a glance registry server" recipe "openstack-image::identity_registration", "Registers Glance endpoints and service with Keystone" diff --git a/spec/api_spec.rb b/spec/api_spec.rb index dcfe2c7..bb4c019 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -154,6 +154,84 @@ describe "openstack-image::api" do end end + + describe "qpid" do + before do + @file = @chef_run.template "/etc/glance/glance-api.conf" + @chef_run.node.set['openstack']['image']['mq']['service_type'] = "qpid" + end + + it "has qpid_hostname" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_hostname=127.0.0.1" + end + + it "has qpid_port" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_port=5672" + end + + it "has qpid_username" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_username=" + end + + it "has qpid_password" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_password=" + end + + it "has qpid_sasl_mechanisms" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_sasl_mechanisms=" + end + + it "has qpid_reconnect" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect=true" + end + + it "has qpid_reconnect_timeout" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect_timeout=0" + end + + it "has qpid_reconnect_limit" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect_limit=0" + end + + it "has qpid_reconnect_interval_min" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect_interval_min=0" + end + + it "has qpid_reconnect_interval_max" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect_interval_max=0" + end + + it "has qpid_reconnect_interval" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_reconnect_interval=0" + end + + it "has qpid_heartbeat" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_heartbeat=60" + end + + it "has qpid_protocol" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_protocol=tcp" + end + + it "has qpid_tcp_nodelay" do + expect(@chef_run).to create_file_with_content @file.name, + "qpid_tcp_nodelay=true" + end + end + describe "glance-api-paste.ini" do before do @file = @chef_run.template "/etc/glance/glance-api-paste.ini" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b658ccf..676cfd8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,5 @@ require "chefspec" +require "chef/application" ::LOG_LEVEL = :fatal ::REDHAT_OPTS = { @@ -27,6 +28,7 @@ def image_stubs ::Chef::Recipe.any_instance.stub(:user_password).and_return String.new ::Chef::Recipe.any_instance.stub(:service_password).with("openstack-image"). and_return "glance-pass" + ::Chef::Application.stub(:fatal!) end def expect_runs_openstack_common_logging_recipe diff --git a/templates/default/glance-api.conf.erb b/templates/default/glance-api.conf.erb index f409d4f..6e585d9 100644 --- a/templates/default/glance-api.conf.erb +++ b/templates/default/glance-api.conf.erb @@ -95,10 +95,10 @@ registry_client_protocol = http # There are three methods of sending notifications, logging (via the # log_file directive), rabbit (via a rabbitmq queue), qpid (via a Qpid # message queue), or noop (no notifications sent, the default) -notifier_strategy = noop +notifier_strategy = <%= node["openstack"]["image"]["mq"]["notifier_strategy"] %> -# Configuration options if sending notifications via rabbitmq (these are -# the defaults) +<% if node["openstack"]["image"]["mq"]["service_type"] == "rabbitmq" %> +#### RABBITMQ ##### rabbit_host = localhost rabbit_port = 5672 rabbit_use_ssl = false @@ -107,25 +107,32 @@ rabbit_password = guest rabbit_virtual_host = / rabbit_notification_exchange = glance rabbit_notification_topic = glance_notifications +<% end %> -# Configuration options if sending notifications via Qpid (these are -# the defaults) +<% if node["openstack"]["image"]["mq"]["service_type"] == "qpid" %> +##### QPID ##### +rpc_backend=nova.openstack.common.rpc.impl_qpid qpid_notification_exchange = glance qpid_notification_topic = glance_notifications -qpid_host = localhost -qpid_port = 5672 -qpid_username = -qpid_password = -qpid_sasl_mechanisms = -qpid_reconnect_timeout = 0 -qpid_reconnect_limit = 0 -qpid_reconnect_interval_min = 0 -qpid_reconnect_interval_max = 0 -qpid_reconnect_interval = 0 -qpid_heartbeat = 5 -# Set to 'ssl' to enable SSL -qpid_protocol = tcp -qpid_tcp_nodelay = True + +qpid_hostname=<%= node["openstack"]["image"]["mq"]["qpid"]["host"] %> +qpid_port=<%= node["openstack"]["image"]["mq"]["qpid"]["port"] %> + +qpid_password=<%= node["openstack"]["image"]["mq"]["qpid"]["password"] %> +qpid_username=<%= node["openstack"]["image"]["mq"]["qpid"]["username"] %> +qpid_sasl_mechanisms=<%= node["openstack"]["image"]["mq"]["qpid"]["sasl_mechanisms"] %> +qpid_reconnect=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect"] %> +qpid_reconnect_timeout=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect_timeout"] %> +qpid_reconnect_limit=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect_limit"] %> +qpid_reconnect_interval_min=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect_interval_min"] %> +qpid_reconnect_interval_max=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect_interval_max"] %> +qpid_reconnect_interval=<%= node["openstack"]["image"]["mq"]["qpid"]["reconnect_interval"] %> +qpid_heartbeat=<%= node["openstack"]["image"]["mq"]["qpid"]["heartbeat"] %> +# qpid protocol. default 'tcp'. set to 'ssl' to enable SSL +qpid_protocol=<%= node["openstack"]["image"]["mq"]["qpid"]["protocol"] %> +qpid_tcp_nodelay=<%= node["openstack"]["image"]["mq"]["qpid"]["tcp_nodelay"] %> + +<% end %> # ============ Filesystem Store Options ========================