From 7ba8bd88f0f0c6ce2fd1744c88d1d91772272c18 Mon Sep 17 00:00:00 2001 From: danehans Date: Thu, 11 Jul 2013 18:56:35 +0000 Subject: [PATCH] Adds support for RabbitMQ Clustering Previsouly, the openstack module only supported a single RabbitMQ Broker. This change adds the rabbit_hosts and cluster_disk_nodes parameters used by the core modules to manage rabbit clustering. Defaults to false to disable rabbit clustering and for backwards compatibility. Change-Id: Iaae1ce3ec8864f43365bcf600ae3fa5c374d9b17 --- manifests/cinder/controller.pp | 2 +- manifests/cinder/storage.pp | 2 +- manifests/compute.pp | 5 +++++ manifests/controller.pp | 11 +++++++++++ manifests/nova/controller.pp | 18 ++++++++++++++---- spec/classes/openstack_compute_spec.rb | 6 ++++++ spec/classes/openstack_controller_spec.rb | 14 ++++++++++---- spec/classes/openstack_nova_controller_spec.rb | 10 ++++++---- 8 files changed, 54 insertions(+), 14 deletions(-) diff --git a/manifests/cinder/controller.pp b/manifests/cinder/controller.pp index c7fa303..38b5b20 100644 --- a/manifests/cinder/controller.pp +++ b/manifests/cinder/controller.pp @@ -12,7 +12,7 @@ class openstack::cinder::controller( $keystone_service_port = '5000', $rabbit_userid = 'guest', $rabbit_host = '127.0.0.1', - $rabbit_hosts = undef, + $rabbit_hosts = false, $rabbit_port = '5672', $rabbit_virtual_host = '/', # Database. Currently mysql is the only option. diff --git a/manifests/cinder/storage.pp b/manifests/cinder/storage.pp index 61f88d3..acf45db 100644 --- a/manifests/cinder/storage.pp +++ b/manifests/cinder/storage.pp @@ -3,7 +3,7 @@ class openstack::cinder::storage( $rabbit_password, $rabbit_userid = 'guest', $rabbit_host = '127.0.0.1', - $rabbit_hosts = undef, + $rabbit_hosts = false, $rabbit_port = '5672', $rabbit_virtual_host = '/', $package_ensure = 'present', diff --git a/manifests/compute.pp b/manifests/compute.pp index 7ffbee3..93c97ea 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -11,6 +11,9 @@ # Driver used to implement Quantum firewalling. # (optional) Defaults to false. # +# [rabbit_hosts] An array of IP addresses or Virttual IP address for connecting to a RabbitMQ Cluster. +# Optional. Defaults to false. +# # === Examples # # class { 'openstack::nova::compute': @@ -60,6 +63,7 @@ class openstack::compute ( $libvirt_vif_driver = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver', # Rabbit $rabbit_host = '127.0.0.1', + $rabbit_hosts = false, $rabbit_user = 'openstack', $rabbit_virtual_host = '/', # Glance @@ -123,6 +127,7 @@ class openstack::compute ( glance_api_servers => $glance_api_servers, verbose => $verbose, rabbit_host => $rabbit_host, + rabbit_hosts => $rabbit_hosts, rabbit_virtual_host => $rabbit_virtual_host, } diff --git a/manifests/controller.pp b/manifests/controller.pp index b3e86ed..84a7cb5 100644 --- a/manifests/controller.pp +++ b/manifests/controller.pp @@ -31,6 +31,11 @@ # # [rabbit_password] Rabbit password. # [rabbit_user] Rabbit User. Optional. Defaults to openstack. +# [rabbit_host] IP address to connect to the RabbitMQ Broker. Optional. Defaults to '127.0.0.1'. +# [rabbit_hosts] An array of IP addresses or Virttual IP address for connecting to a RabbitMQ Cluster. +# Optional. Defaults to false. +# [rabbit_cluster_nodes] An array of Rabbit Broker IP addresses within the Cluster. +# Optional. Defaults to false. # [rabbit_virtual_host] Rabbit virtual host path for Nova. Defaults to '/'. # [network_manager] Nova network manager to use. # [fixed_range] Range of ipv4 network for vms. @@ -166,6 +171,8 @@ class openstack::controller ( $network_config = {}, # Rabbit $rabbit_host = '127.0.0.1', + $rabbit_hosts = false, + $rabbit_cluster_nodes = false, $rabbit_user = 'openstack', $rabbit_virtual_host = '/', # Horizon @@ -362,6 +369,8 @@ class openstack::controller ( # Rabbit rabbit_user => $rabbit_user, rabbit_password => $rabbit_password, + rabbit_hosts => $rabbit_hosts, + rabbit_cluster_nodes => $rabbit_cluster_nodes, rabbit_virtual_host => $rabbit_virtual_host, # Glance glance_api_servers => $glance_api_servers, @@ -397,6 +406,7 @@ class openstack::controller ( rabbit_host => $rabbit_host, rabbit_user => $rabbit_user, rabbit_password => $rabbit_password, + rabbit_hosts => $rabbit_hosts, rabbit_virtual_host => $rabbit_virtual_host, # Quantum OVS ovs_local_ip => $ovs_local_ip_real, @@ -444,6 +454,7 @@ class openstack::controller ( rabbit_userid => $rabbit_user, rabbit_password => $rabbit_password, rabbit_host => $rabbit_host, + rabbit_hosts => $rabbit_hosts, db_password => $cinder_db_password, db_dbname => $cinder_db_dbname, db_user => $cinder_db_user, diff --git a/manifests/nova/controller.pp b/manifests/nova/controller.pp index f252a8b..27918fe 100644 --- a/manifests/nova/controller.pp +++ b/manifests/nova/controller.pp @@ -15,6 +15,12 @@ # IP address to use for binding Nova API's. # (optional) Defaults to '0.0.0.0'. # +# [rabbit_hosts] An array of IP addresses or Virttual IP address for connecting to a RabbitMQ Cluster. +# Optional. Defaults to false. +# +# [rabbit_cluster_nodes] An array of Rabbit Broker IP addresses within the Cluster. +# Optional. Defaults to false. +# # [quantum] # Specifies if nova should be configured to use quantum. # (optional) Defaults to false (indicating nova-networks should be used) @@ -79,6 +85,8 @@ class openstack::nova::controller ( # Rabbit $rabbit_user = 'openstack', $rabbit_virtual_host = '/', + $rabbit_hosts = false, + $rabbit_cluster_nodes = false, # Database $db_type = 'mysql', $sql_idle_timeout = '3600', @@ -121,10 +129,11 @@ class openstack::nova::controller ( # Install / configure rabbitmq class { 'nova::rabbitmq': - userid => $rabbit_user, - password => $rabbit_password, - enabled => $enabled, - virtual_host => $rabbit_virtual_host, + userid => $rabbit_user, + password => $rabbit_password, + enabled => $enabled, + cluster_disk_nodes => $rabbit_cluster_nodes, + virtual_host => $rabbit_virtual_host, } # Configure Nova @@ -140,6 +149,7 @@ class openstack::nova::controller ( debug => $debug, verbose => $verbose, rabbit_host => $rabbit_connection, + rabbit_hosts => $rabbit_hosts, } # Configure nova-api diff --git a/spec/classes/openstack_compute_spec.rb b/spec/classes/openstack_compute_spec.rb index 8c158ad..a43d252 100644 --- a/spec/classes/openstack_compute_spec.rb +++ b/spec/classes/openstack_compute_spec.rb @@ -9,6 +9,7 @@ describe 'openstack::compute' do :nova_user_password => 'nova_pass', :rabbit_password => 'rabbit_pw', :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_virtual_host => '/', :nova_admin_tenant_name => 'services', :nova_admin_user => 'nova', @@ -32,6 +33,7 @@ describe 'openstack::compute' do should contain_class('nova').with( :sql_connection => 'mysql://nova:pass@127.0.0.1/nova', :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_userid => 'openstack', :rabbit_password => 'rabbit_pw', :rabbit_virtual_host => '/', @@ -71,6 +73,7 @@ describe 'openstack::compute' do :rabbit_password => 'rabbit_pw', :rabbit_userid => 'openstack', :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_virtual_host => '/', :volume_group => 'cinder-volumes', :iscsi_ip_address => '127.0.0.1', @@ -92,6 +95,7 @@ describe 'openstack::compute' do :nova_db_user => 'nova_user', :nova_db_name => 'novadb', :rabbit_host => 'my_host', + :rabbit_hosts => ['rabbit:5673', 'rabbit2:5674'], :rabbit_password => 'my_rabbit_pw', :rabbit_user => 'my_rabbit_user', :rabbit_virtual_host => '/foo', @@ -106,6 +110,7 @@ describe 'openstack::compute' do should contain_class('nova').with( :sql_connection => 'mysql://nova_user:pass@127.0.0.1/novadb', :rabbit_host => 'my_host', + :rabbit_hosts => ['rabbit:5673', 'rabbit2:5674'], :rabbit_userid => 'my_rabbit_user', :rabbit_password => 'my_rabbit_pw', :rabbit_virtual_host => '/foo', @@ -283,6 +288,7 @@ describe 'openstack::compute' do :db_host => '127.0.0.1', :ovs_local_ip => params[:internal_address], :rabbit_host => params[:rabbit_host], + :rabbit_hosts => params[:rabbit_hosts], :rabbit_user => 'openstack', :rabbit_password => params[:rabbit_password], :enable_ovs_agent => true, diff --git a/spec/classes/openstack_controller_spec.rb b/spec/classes/openstack_controller_spec.rb index 62a795c..4aba747 100644 --- a/spec/classes/openstack_controller_spec.rb +++ b/spec/classes/openstack_controller_spec.rb @@ -12,6 +12,7 @@ describe 'openstack::controller' do :admin_email => 'some_user@some_fake_email_address.foo', :admin_password => 'ChangeMe', :rabbit_password => 'rabbit_pw', + :rabbit_cluster_nodes => false, :rabbit_virtual_host => '/', :keystone_db_password => 'keystone_pass', :keystone_admin_token => 'keystone_admin_token', @@ -374,14 +375,16 @@ describe 'openstack::controller' do it 'should contain enabled nova services' do should_not contain_resources('nova_config').with_purge(true) should contain_class('nova::rabbitmq').with( - :userid => 'openstack', - :password => 'rabbit_pw', - :virtual_host => '/', - :enabled => true + :userid => 'openstack', + :password => 'rabbit_pw', + :cluster_disk_nodes => false, + :virtual_host => '/', + :enabled => true ) should contain_class('nova').with( :sql_connection => 'mysql://nova:nova_pass@127.0.0.1/nova', :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_userid => 'openstack', :rabbit_password => 'rabbit_pw', :rabbit_virtual_host => '/', @@ -498,6 +501,8 @@ describe 'openstack::controller' do default_params.merge( :debug => true, :verbose => true, + :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_user => 'rabbituser', :rabbit_password => 'rabbit_pw2', :cinder_user_password => 'foo', @@ -550,6 +555,7 @@ describe 'openstack::controller' do :db_host => '127.0.0.1', :sql_idle_timeout => '30', :rabbit_host => '127.0.0.1', + :rabbit_hosts => false, :rabbit_user => 'openstack', :rabbit_password => 'rabbit_pw', :rabbit_virtual_host => '/', diff --git a/spec/classes/openstack_nova_controller_spec.rb b/spec/classes/openstack_nova_controller_spec.rb index 57a3bf1..3c08218 100644 --- a/spec/classes/openstack_nova_controller_spec.rb +++ b/spec/classes/openstack_nova_controller_spec.rb @@ -32,10 +32,11 @@ describe 'openstack::nova::controller' do it 'should configure nova with quantum' do should contain_class('nova::rabbitmq').with( - :userid => 'openstack', - :password => 'rabbit_pass', - :enabled => true, - :virtual_host => '/' + :userid => 'openstack', + :password => 'rabbit_pass', + :enabled => true, + :cluster_disk_nodes => false, + :virtual_host => '/' ) should contain_class('nova').with( :sql_connection => 'mysql://nova:nova_db_pass@127.0.0.1/nova', @@ -46,6 +47,7 @@ describe 'openstack::nova::controller' do :glance_api_servers => '127.0.0.1:9292', :debug => false, :verbose => false, + :rabbit_hosts => false, :rabbit_host => '127.0.0.1' )