Add ability to specify IP for service
The problem that this change addresses is that the address_for method will not work correctly if there are multiple IP address associated with the specified interface. The approach to solving this problem and moving towards the overall goal of having one place where service networking information is stored is to convert address_for calls into endpoints, and add a address() method to the endpoints interface for IP address resolution. The address() method has the following behavior: if the bind_interface of an endpoint is set, then the IP is looked up on the interface. Otherwise, the IP specified in the host attribute is returned. This allows the caller to choose either method of determining what IP a service will be bound to. This initial change switches both the openstack-ops-database and openstack-ops-messaging cookbooks over to use endpoints instead of address_for. The other cookbooks will be switched over time. blueprint increase-ip-binding-flexibility Change-Id: I4a610409b9542a4c802f94b557299bb97dd0781b
This commit is contained in:
parent
6c3f39ebe3
commit
0db09aba5d
11
README.md
11
README.md
|
@ -41,9 +41,18 @@ None
|
|||
|
||||
# Attributes #
|
||||
|
||||
* `openstack["mq"]["bind_interface"]` - bind to interfaces IPv4 address
|
||||
* `openstack["mq"]["cluster"]` - whether or not to cluster rabbit, defaults to 'false'
|
||||
|
||||
The following attributes are defined in attributes/messaging.rb of the common cookbook, but are documented here due to their relevance:
|
||||
|
||||
* `openstack["endpoints"]["mq"]["host"]` - The IP address to bind the rabbit service to
|
||||
* `openstack["endpoints"]["mq"]["scheme"]` - Unused at this time
|
||||
* `openstack["endpoints"]["mq"]["port"]` - The port to bind the rabbit service to
|
||||
* `openstack["endpoints"]["mq"]["path"]` - Unused at this time
|
||||
* `openstack["endpoints"]["mq"]["bind_interface"]` - The interface name to bind the rabbit service to
|
||||
|
||||
If the value of the "bind_interface" attribute is non-nil, then the rabbit service will be bound to the first IP address on that interface. If the value of the "bind_interface" attribute is nil, then the rabbit service will be bound to the IP address specified in the host attribute.
|
||||
|
||||
Testing
|
||||
=====
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
default['openstack']['mq']['bind_interface'] = 'lo'
|
||||
default['openstack']['mq']['cluster'] = false
|
||||
|
||||
if platform_family?('debian', 'suse')
|
||||
|
|
|
@ -27,12 +27,13 @@ end
|
|||
user = node['openstack']['mq']['user']
|
||||
pass = get_password 'user', user
|
||||
vhost = node['openstack']['mq']['vhost']
|
||||
listen_address = address_for node['openstack']['mq']['bind_interface']
|
||||
rabbit_endpoint = endpoint 'mq'
|
||||
listen_address = rabbit_endpoint.host
|
||||
|
||||
# Used by OpenStack#rabbit_servers/#rabbit_server
|
||||
node.set['openstack']['mq']['listen'] = listen_address
|
||||
|
||||
node.override['rabbitmq']['port'] = node['openstack']['mq']['port']
|
||||
node.override['rabbitmq']['port'] = rabbit_endpoint.port
|
||||
node.override['rabbitmq']['address'] = listen_address
|
||||
node.override['rabbitmq']['default_user'] = user
|
||||
node.override['rabbitmq']['default_pass'] = pass
|
||||
|
|
|
@ -10,7 +10,7 @@ describe 'openstack-ops-messaging::rabbitmq-server' do
|
|||
include_context 'ops_messaging_stubs'
|
||||
|
||||
it 'overrides default rabbit attributes' do
|
||||
expect(chef_run.node['openstack']['mq']['port']).to eq('5672')
|
||||
expect(chef_run.node['openstack']['endpoints']['mq']['port']).to eq('5672')
|
||||
expect(chef_run.node['openstack']['mq']['listen']).to eq('127.0.0.1')
|
||||
expect(chef_run.node['rabbitmq']['address']).to eq('127.0.0.1')
|
||||
expect(chef_run.node['rabbitmq']['default_user']).to eq('guest')
|
||||
|
@ -19,13 +19,13 @@ describe 'openstack-ops-messaging::rabbitmq-server' do
|
|||
end
|
||||
|
||||
it 'overrides rabbit and openstack image attributes' do
|
||||
node.set['openstack']['mq']['bind_interface'] = 'eth0'
|
||||
node.set['openstack']['mq']['port'] = '4242'
|
||||
node.set['openstack']['endpoints']['mq']['bind_interface'] = 'eth0'
|
||||
node.set['openstack']['endpoints']['mq']['port'] = '4242'
|
||||
node.set['openstack']['mq']['user'] = 'foo'
|
||||
node.set['openstack']['mq']['vhost'] = '/bar'
|
||||
|
||||
expect(chef_run.node['openstack']['mq']['listen']).to eq('33.44.55.66')
|
||||
expect(chef_run.node['openstack']['mq']['port']).to eq('4242')
|
||||
expect(chef_run.node['openstack']['endpoints']['mq']['port']).to eq('4242')
|
||||
expect(chef_run.node['openstack']['mq']['user']).to eq('foo')
|
||||
expect(chef_run.node['openstack']['mq']['vhost']).to eq('/bar')
|
||||
expect(chef_run.node['openstack']['mq']['image']['rabbit']['port']).to eq('4242')
|
||||
|
|
Loading…
Reference in New Issue