diff --git a/manifests/messaging/zmq.pp b/manifests/messaging/zmq.pp new file mode 100644 index 0000000..89cb8d8 --- /dev/null +++ b/manifests/messaging/zmq.pp @@ -0,0 +1,119 @@ +# == Define: oslo::messaging::zmq +# +# Configure ZeroMQ messaging options +# +# This resource configures ZeroMQ messaging resources for an OpenStack service. +# It will manage the [DEFAULT] section in the given config resource. +# +# == Parameters +# +# [*rpc_cast_timeout*] +# (optional) Seconds to wait before a cast expires (TTL). +# The default value of -1 specifies an infinite linger +# period. The value of 0 specifies no linger period. +# Pending messages shall be discarded immediately +# when the socket is closed. Only supported by impl_zmq. +# Defaults to $::os_service_default. +# +# [*rpc_poll_timeout*] +# (optional) The default number of seconds that poll should wait. +# Poll raises timeout exception when timeout expired. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_bind_address*] +# (optional) ZeroMQ bind address. +# Should be a wildcard (*), an ethernet interface, or IP. +# The "host" option should point or resolve to this address. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_bind_port_retries*] +# (optional) Number of retries to find free port number +# before fail with ZMQBindError. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_concurrency*] +# (optional) Type of concurrency used. +# Either "native" or "eventlet". +# Defaults to $::os_service_default. +# +# [*rpc_zmq_contexts*] +# (optional) Number of ZeroMQ contexts. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_host*] +# (optional) Name of this node. +# Must be a valid hostname, FQDN, or IP address. +# Must match "host" option, if running Nova. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_ipc_dir*] +# (optional) Directory for holding IPC sockets. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_matchmaker*] +# (optional) MatchMaker driver. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_max_port*] +# (optional) Maximal port number for random ports range. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_min_port*] +# (optional) Minimal port number for random ports range. +# Defaults to $::os_service_default. +# +# [*rpc_zmq_topic_backlog*] +# (optional) Maximum number of ingress messages to locally buffer per topic. +# Defaults to $::os_service_default. +# +# [*use_pub_sub*] +# (optional) Use PUB/SUB pattern for fanout methods. +# PUB/SUB always uses proxy. +# Defaults to $::os_service_default. +# +# [*zmq_target_expire*] +# (optional) Expiration timeout in seconds of a name service +# record about existing target ( < 0 means no timeout). +# Defaults to $::os_service_default. +# +define oslo::messaging::zmq( + $rpc_cast_timeout = $::os_service_default, + $rpc_poll_timeout = $::os_service_default, + $rpc_zmq_bind_address = $::os_service_default, + $rpc_zmq_bind_port_retries = $::os_service_default, + $rpc_zmq_concurrency = $::os_service_default, + $rpc_zmq_contexts = $::os_service_default, + $rpc_zmq_host = $::os_service_default, + $rpc_zmq_ipc_dir = $::os_service_default, + $rpc_zmq_matchmaker = $::os_service_default, + $rpc_zmq_max_port = $::os_service_default, + $rpc_zmq_min_port = $::os_service_default, + $rpc_zmq_topic_backlog = $::os_service_default, + $use_pub_sub = $::os_service_default, + $zmq_target_expire = $::os_service_default, +) { + + if ! ( is_service_default($rpc_zmq_concurrency) or $rpc_zmq_concurrency in [ 'eventlet', 'native' ] ) { + fail('Unsupported type of zmq concurrency is used.') + } + + $zmq_options = { + 'DEFAULT/rpc_cast_timeout' => { value => $rpc_cast_timeout }, + 'DEFAULT/rpc_poll_timeout' => { value => $rpc_poll_timeout }, + 'DEFAULT/rpc_zmq_bind_address' => { value => $rpc_zmq_bind_address }, + 'DEFAULT/rpc_zmq_bind_port_retries' => { value => $rpc_zmq_bind_port_retries }, + 'DEFAULT/rpc_zmq_concurrency' => { value => $rpc_zmq_concurrency }, + 'DEFAULT/rpc_zmq_contexts' => { value => $rpc_zmq_contexts }, + 'DEFAULT/rpc_zmq_host' => { value => $rpc_zmq_host }, + 'DEFAULT/rpc_zmq_ipc_dir' => { value => $rpc_zmq_ipc_dir }, + 'DEFAULT/rpc_zmq_matchmaker' => { value => $rpc_zmq_matchmaker }, + 'DEFAULT/rpc_zmq_max_port' => { value => $rpc_zmq_max_port }, + 'DEFAULT/rpc_zmq_min_port' => { value => $rpc_zmq_min_port }, + 'DEFAULT/rpc_zmq_topic_backlog' => { value => $rpc_zmq_topic_backlog }, + 'DEFAULT/use_pub_sub' => { value => $use_pub_sub }, + 'DEFAULT/zmq_target_expire' => { value => $zmq_target_expire }, + 'DEFAULT/rpc_backend' => { value => 'zmq' }, + } + + create_resources($name, $zmq_options) +} diff --git a/releasenotes/notes/add_zmq_messaging-7ea20df747c78035.yaml b/releasenotes/notes/add_zmq_messaging-7ea20df747c78035.yaml new file mode 100644 index 0000000..d54157a --- /dev/null +++ b/releasenotes/notes/add_zmq_messaging-7ea20df747c78035.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add possibility to configure ZeroMQ messaging system. diff --git a/spec/defines/oslo_messaging_zmq_spec.rb b/spec/defines/oslo_messaging_zmq_spec.rb new file mode 100644 index 0000000..a74abe8 --- /dev/null +++ b/spec/defines/oslo_messaging_zmq_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe 'oslo::messaging::zmq' do + + let (:title) { 'keystone_config' } + + shared_examples 'oslo-messaging-zmq' do + + context 'with default parameters' do + it 'configure zmq default params' do + is_expected.to contain_keystone_config('DEFAULT/rpc_cast_timeout').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_poll_timeout').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_bind_address').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_bind_port_retries').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_concurrency').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_contexts').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_host').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_ipc_dir').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_matchmaker').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_max_port').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_min_port').with_value('') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_topic_backlog').with_value('') + is_expected.to contain_keystone_config('DEFAULT/use_pub_sub').with_value('') + is_expected.to contain_keystone_config('DEFAULT/zmq_target_expire').with_value('') + end + + end + + context 'with overridden parameters' do + let :params do + { :rpc_zmq_bind_address => '0.0.0.0', + :rpc_zmq_bind_port_retries => '10', + :rpc_zmq_concurrency => 'native', + :rpc_zmq_contexts => '2', + } + end + + it 'configure zmq with overriden values' do + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_bind_address').with_value('0.0.0.0') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_bind_port_retries').with_value('10') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_concurrency').with_value('native') + is_expected.to contain_keystone_config('DEFAULT/rpc_zmq_contexts').with_value('2') + end + end + + context 'with wrong zmq concurrency' do + let :params do + { :rpc_zmq_concurrency => 'some_another' } + end + + it_raises 'a Puppet::Error', /Unsupported type of zmq concurrency is used/ + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_behaves_like 'oslo-messaging-zmq' + end + end +end