Merge "Add ability to specify IP for service"
This commit is contained in:
@@ -70,39 +70,49 @@
|
|||||||
# across many zones.
|
# across many zones.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# ******************** Database Endpoint **************************************
|
||||||
|
default['openstack']['endpoints']['db']['host'] = '127.0.0.1'
|
||||||
|
default['openstack']['endpoints']['db']['scheme'] = nil
|
||||||
|
default['openstack']['endpoints']['db']['port'] = '3306'
|
||||||
|
default['openstack']['endpoints']['db']['path'] = nil
|
||||||
|
default['openstack']['endpoints']['db']['bind_interface'] = nil
|
||||||
|
|
||||||
# Default database attributes
|
# Default database attributes
|
||||||
default['openstack']['db']['server_role'] = 'os-ops-database'
|
default['openstack']['db']['server_role'] = 'os-ops-database'
|
||||||
default['openstack']['db']['service_type'] = 'mysql'
|
default['openstack']['db']['service_type'] = 'mysql'
|
||||||
default['openstack']['db']['host'] = '127.0.0.1'
|
# Note that the openstack:db:host and openstack:db:port attributes are being
|
||||||
default['openstack']['db']['port'] = '3306'
|
# deprecated in favor of the db endpoint and will be removed in a future
|
||||||
|
# patch set.
|
||||||
|
default['openstack']['db']['host'] = default['openstack']['endpoints']['db']['host']
|
||||||
|
default['openstack']['db']['port'] = default['openstack']['endpoints']['db']['port']
|
||||||
|
|
||||||
# Database used by the OpenStack Compute (Nova) service
|
# Database used by the OpenStack Compute (Nova) service
|
||||||
default['openstack']['db']['compute']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['compute']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['compute']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['compute']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['compute']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['compute']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['compute']['db_name'] = 'nova'
|
default['openstack']['db']['compute']['db_name'] = 'nova'
|
||||||
default['openstack']['db']['compute']['username'] = 'nova'
|
default['openstack']['db']['compute']['username'] = 'nova'
|
||||||
|
|
||||||
# Database used by the OpenStack Identity (Keystone) service
|
# Database used by the OpenStack Identity (Keystone) service
|
||||||
default['openstack']['db']['identity']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['identity']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['identity']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['identity']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['identity']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['identity']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['identity']['db_name'] = 'keystone'
|
default['openstack']['db']['identity']['db_name'] = 'keystone'
|
||||||
default['openstack']['db']['identity']['username'] = 'keystone'
|
default['openstack']['db']['identity']['username'] = 'keystone'
|
||||||
default['openstack']['db']['identity']['migrate'] = true
|
default['openstack']['db']['identity']['migrate'] = true
|
||||||
|
|
||||||
# Database used by the OpenStack Image (Glance) service
|
# Database used by the OpenStack Image (Glance) service
|
||||||
default['openstack']['db']['image']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['image']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['image']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['image']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['image']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['image']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['image']['db_name'] = 'glance'
|
default['openstack']['db']['image']['db_name'] = 'glance'
|
||||||
default['openstack']['db']['image']['username'] = 'glance'
|
default['openstack']['db']['image']['username'] = 'glance'
|
||||||
default['openstack']['db']['image']['migrate'] = true
|
default['openstack']['db']['image']['migrate'] = true
|
||||||
|
|
||||||
# Database used by the OpenStack Network (Neutron) service
|
# Database used by the OpenStack Network (Neutron) service
|
||||||
default['openstack']['db']['network']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['network']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['network']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['network']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['network']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['network']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['network']['db_name'] = 'neutron'
|
default['openstack']['db']['network']['db_name'] = 'neutron'
|
||||||
default['openstack']['db']['network']['username'] = 'neutron'
|
default['openstack']['db']['network']['username'] = 'neutron'
|
||||||
# The SQLAlchemy connection string used to connect to the slave database
|
# The SQLAlchemy connection string used to connect to the slave database
|
||||||
@@ -129,23 +139,23 @@ default['openstack']['db']['network']['pool_timeout'] = 10
|
|||||||
|
|
||||||
# Database used by the OpenStack Block Storage (Cinder) service
|
# Database used by the OpenStack Block Storage (Cinder) service
|
||||||
default['openstack']['db']['block-storage']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['block-storage']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['block-storage']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['block-storage']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['block-storage']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['block-storage']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['block-storage']['db_name'] = 'cinder'
|
default['openstack']['db']['block-storage']['db_name'] = 'cinder'
|
||||||
default['openstack']['db']['block-storage']['username'] = 'cinder'
|
default['openstack']['db']['block-storage']['username'] = 'cinder'
|
||||||
|
|
||||||
# Database used by the OpenStack Dashboard (Horizon)
|
# Database used by the OpenStack Dashboard (Horizon)
|
||||||
default['openstack']['db']['dashboard']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['dashboard']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['dashboard']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['dashboard']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['dashboard']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['dashboard']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['dashboard']['db_name'] = 'horizon'
|
default['openstack']['db']['dashboard']['db_name'] = 'horizon'
|
||||||
default['openstack']['db']['dashboard']['username'] = 'dash'
|
default['openstack']['db']['dashboard']['username'] = 'dash'
|
||||||
default['openstack']['db']['dashboard']['migrate'] = true
|
default['openstack']['db']['dashboard']['migrate'] = true
|
||||||
|
|
||||||
# Database used by OpenStack Metering (Ceilometer)
|
# Database used by OpenStack Metering (Ceilometer)
|
||||||
default['openstack']['db']['metering']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['metering']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['metering']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['metering']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['metering']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['metering']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['metering']['db_name'] = 'ceilometer'
|
default['openstack']['db']['metering']['db_name'] = 'ceilometer'
|
||||||
default['openstack']['db']['metering']['username'] = 'ceilometer'
|
default['openstack']['db']['metering']['username'] = 'ceilometer'
|
||||||
default['openstack']['db']['metering']['nosql']['used'] = false
|
default['openstack']['db']['metering']['nosql']['used'] = false
|
||||||
@@ -153,8 +163,8 @@ default['openstack']['db']['metering']['nosql']['port'] = '27017'
|
|||||||
|
|
||||||
# Database used by OpenStack Orchestration (Heat)
|
# Database used by OpenStack Orchestration (Heat)
|
||||||
default['openstack']['db']['orchestration']['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db']['orchestration']['service_type'] = node['openstack']['db']['service_type']
|
||||||
default['openstack']['db']['orchestration']['host'] = node['openstack']['db']['host']
|
default['openstack']['db']['orchestration']['host'] = node['openstack']['endpoints']['db']['host']
|
||||||
default['openstack']['db']['orchestration']['port'] = node['openstack']['db']['port']
|
default['openstack']['db']['orchestration']['port'] = node['openstack']['endpoints']['db']['port']
|
||||||
default['openstack']['db']['orchestration']['db_name'] = 'heat'
|
default['openstack']['db']['orchestration']['db_name'] = 'heat'
|
||||||
default['openstack']['db']['orchestration']['username'] = 'heat'
|
default['openstack']['db']['orchestration']['username'] = 'heat'
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,13 @@
|
|||||||
# expected to create the user, pass, vhost in a wrapper rabbitmq cookbook.
|
# expected to create the user, pass, vhost in a wrapper rabbitmq cookbook.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# ******************** RabbitMQ Endpoint **************************************
|
||||||
|
default['openstack']['endpoints']['mq']['host'] = '127.0.0.1'
|
||||||
|
default['openstack']['endpoints']['mq']['scheme'] = nil
|
||||||
|
default['openstack']['endpoints']['mq']['port'] = '5672'
|
||||||
|
default['openstack']['endpoints']['mq']['path'] = nil
|
||||||
|
default['openstack']['endpoints']['mq']['bind_interface'] = nil
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
# Services to assign mq attributes for
|
# Services to assign mq attributes for
|
||||||
###################################################################
|
###################################################################
|
||||||
@@ -34,8 +41,11 @@ services = %w{block-storage compute image metering network orchestration}
|
|||||||
###################################################################
|
###################################################################
|
||||||
default['openstack']['mq']['server_role'] = 'os-ops-messaging'
|
default['openstack']['mq']['server_role'] = 'os-ops-messaging'
|
||||||
default['openstack']['mq']['service_type'] = 'rabbitmq'
|
default['openstack']['mq']['service_type'] = 'rabbitmq'
|
||||||
default['openstack']['mq']['host'] = '127.0.0.1'
|
# Note that the openstack:mq:host and openstack:mq:port attributes are being
|
||||||
default['openstack']['mq']['port'] = '5672'
|
# deprecated in favor of the mq endpoint and will be removed in a future
|
||||||
|
# patch set.
|
||||||
|
default['openstack']['mq']['host'] = default['openstack']['endpoints']['mq']['host']
|
||||||
|
default['openstack']['mq']['port'] = default['openstack']['endpoints']['mq']['port']
|
||||||
default['openstack']['mq']['user'] = 'guest'
|
default['openstack']['mq']['user'] = 'guest'
|
||||||
default['openstack']['mq']['vhost'] = '/'
|
default['openstack']['mq']['vhost'] = '/'
|
||||||
|
|
||||||
@@ -55,16 +65,16 @@ qpid_defaults = {
|
|||||||
heartbeat: 60,
|
heartbeat: 60,
|
||||||
protocol: 'tcp',
|
protocol: 'tcp',
|
||||||
tcp_nodelay: true,
|
tcp_nodelay: true,
|
||||||
host: node['openstack']['mq']['host'],
|
host: node['openstack']['endpoints']['mq']['host'],
|
||||||
port: node['openstack']['mq']['port'],
|
port: node['openstack']['endpoints']['mq']['port'],
|
||||||
qpid_hosts: ["#{node['openstack']['mq']['host']}:#{node['openstack']['mq']['port']}"]
|
qpid_hosts: ["#{node['openstack']['endpoints']['mq']['host']}:#{node['openstack']['endpoints']['mq']['port']}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
rabbit_defaults = {
|
rabbit_defaults = {
|
||||||
userid: node['openstack']['mq']['user'],
|
userid: node['openstack']['mq']['user'],
|
||||||
vhost: node['openstack']['mq']['vhost'],
|
vhost: node['openstack']['mq']['vhost'],
|
||||||
port: node['openstack']['mq']['port'],
|
port: node['openstack']['endpoints']['mq']['port'],
|
||||||
host: node['openstack']['mq']['host'],
|
host: node['openstack']['endpoints']['mq']['host'],
|
||||||
ha: false,
|
ha: false,
|
||||||
use_ssl: false
|
use_ssl: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,20 @@ module ::Openstack # rubocop:disable Documentation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return the IPv4 address for the hash.
|
||||||
|
#
|
||||||
|
# If the bind_interface is set, then return the first IP on the interface.
|
||||||
|
# otherwise return the IP specified in the host attribute.
|
||||||
|
def address(hash)
|
||||||
|
bind_interface = hash['bind_interface'] if hash['bind_interface']
|
||||||
|
|
||||||
|
if bind_interface
|
||||||
|
return address_for bind_interface
|
||||||
|
else
|
||||||
|
return hash['host']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Instead of specifying the verbose node['openstack']['endpoints'][name],
|
# Instead of specifying the verbose node['openstack']['endpoints'][name],
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ module ::Openstack # rubocop:disable Documentation
|
|||||||
def rabbit_servers # rubocop:disable MethodLength
|
def rabbit_servers # rubocop:disable MethodLength
|
||||||
if node['openstack']['mq']['servers']
|
if node['openstack']['mq']['servers']
|
||||||
servers = node['openstack']['mq']['servers']
|
servers = node['openstack']['mq']['servers']
|
||||||
port = node['openstack']['mq']['port']
|
port = node['openstack']['endpoints']['mq']['port']
|
||||||
|
|
||||||
servers.map { |s| "#{s}:#{port}" }.join ','
|
servers.map { |s| "#{s}:#{port}" }.join ','
|
||||||
else
|
else
|
||||||
@@ -80,7 +80,7 @@ module ::Openstack # rubocop:disable Documentation
|
|||||||
# in the wrapper cookbook. See the reference cookbook
|
# in the wrapper cookbook. See the reference cookbook
|
||||||
# openstack-ops-messaging.
|
# openstack-ops-messaging.
|
||||||
address = n['openstack']['mq']['listen']
|
address = n['openstack']['mq']['listen']
|
||||||
port = n['openstack']['mq']['port']
|
port = n['openstack']['endpoints']['mq']['port']
|
||||||
|
|
||||||
"#{address}:#{port}"
|
"#{address}:#{port}"
|
||||||
end.sort.join ','
|
end.sort.join ','
|
||||||
|
|||||||
@@ -24,19 +24,23 @@ require 'uri'
|
|||||||
module ::Openstack # rubocop:disable Documentation
|
module ::Openstack # rubocop:disable Documentation
|
||||||
# Returns a uri::URI from a hash. If the hash has a 'uri' key, the value
|
# Returns a uri::URI from a hash. If the hash has a 'uri' key, the value
|
||||||
# of that is returned. If not, then the routine attempts to construct
|
# of that is returned. If not, then the routine attempts to construct
|
||||||
# the URI from other parts of the hash, notably looking for keys of
|
# the URI from other parts of the hash. The values of the 'port' and 'path'
|
||||||
# 'host', 'port', 'scheme', and 'path' to construct the URI.
|
# keys are used directly from the hash. For the host, if the
|
||||||
|
# 'bind_interface' key is non-nil then it will use the first IP address on
|
||||||
|
# the specified interface, otherwise it will use the value of the 'host' key
|
||||||
|
# from the hash.
|
||||||
#
|
#
|
||||||
# Returns nil if neither 'uri' or 'host' keys exist in the supplied
|
# Returns nil if the 'uri' key does not exist in the supplied hash and if
|
||||||
# hash.
|
# the determined host is nil (both the values of the 'bind_interface' and
|
||||||
|
# 'host' keys are nil).
|
||||||
def uri_from_hash(hash)
|
def uri_from_hash(hash)
|
||||||
if hash['uri']
|
if hash['uri']
|
||||||
::URI.parse hash['uri']
|
::URI.parse hash['uri']
|
||||||
else
|
else
|
||||||
return nil unless hash['host']
|
host = address hash
|
||||||
|
return nil unless host
|
||||||
|
|
||||||
scheme = hash['scheme'] ? hash['scheme'] : 'http'
|
scheme = hash['scheme'] ? hash['scheme'] : 'http'
|
||||||
host = hash['host']
|
|
||||||
port = hash['port'] # Returns nil if missing, which is fine.
|
port = hash['port'] # Returns nil if missing, which is fine.
|
||||||
path = hash['path'] # Returns nil if missing, which is fine.
|
path = hash['path'] # Returns nil if missing, which is fine.
|
||||||
::URI::Generic.new scheme, nil, host, port, nil, path, nil, nil, nil
|
::URI::Generic.new scheme, nil, host, port, nil, path, nil, nil, nil
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ end
|
|||||||
# iterate over the endpoints, look for bind_interface to set the host
|
# iterate over the endpoints, look for bind_interface to set the host
|
||||||
node['openstack']['endpoints'].keys.each do |component|
|
node['openstack']['endpoints'].keys.each do |component|
|
||||||
unless node['openstack']['endpoints'][component]['bind_interface'].nil?
|
unless node['openstack']['endpoints'][component]['bind_interface'].nil?
|
||||||
ip_address = address_for node['openstack']['endpoints'][component]['bind_interface']
|
ip_address = address node['openstack']['endpoints'][component]
|
||||||
node.default['openstack']['endpoints'][component]['host'] = ip_address
|
node.default['openstack']['endpoints'][component]['host'] = ip_address
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -183,5 +183,28 @@ describe 'openstack-common::set_endpoints_by_interface' do
|
|||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#address' do
|
||||||
|
it 'returns interface IP if bind_interface specified' do
|
||||||
|
ep_hash = {
|
||||||
|
'bind_interface' => 'eth0',
|
||||||
|
'host' => '5.6.7.8'
|
||||||
|
}
|
||||||
|
subject.stub('address_for').and_return('1.2.3.4')
|
||||||
|
expect(
|
||||||
|
subject.address(ep_hash)
|
||||||
|
).to eq('1.2.3.4')
|
||||||
|
end
|
||||||
|
it 'returns host IP if bind_interface not specified' do
|
||||||
|
ep_hash = {
|
||||||
|
'bind_interface' => nil,
|
||||||
|
'host' => '5.6.7.8'
|
||||||
|
}
|
||||||
|
subject.stub('address_for').and_return('1.2.3.4')
|
||||||
|
expect(
|
||||||
|
subject.address(ep_hash)
|
||||||
|
).to eq('5.6.7.8')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe 'openstack-common::default' do
|
|||||||
let(:node) { runner.node }
|
let(:node) { runner.node }
|
||||||
let(:chef_run) do
|
let(:chef_run) do
|
||||||
node.set['openstack']['mq']['server_role'] = 'openstack-ops-mq'
|
node.set['openstack']['mq']['server_role'] = 'openstack-ops-mq'
|
||||||
node.set['openstack']['mq']['port'] = 5672
|
node.set['openstack']['endpoints']['mq']['port'] = 5672
|
||||||
|
|
||||||
runner.converge(described_recipe)
|
runner.converge(described_recipe)
|
||||||
end
|
end
|
||||||
@@ -103,8 +103,8 @@ describe 'openstack-common::default' do
|
|||||||
describe '#rabbit_servers' do
|
describe '#rabbit_servers' do
|
||||||
it 'returns rabbit servers' do
|
it 'returns rabbit servers' do
|
||||||
nodes = [
|
nodes = [
|
||||||
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1', 'port' => '5672' } } },
|
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||||
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2', 'port' => '5672' } } }
|
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
|
||||||
]
|
]
|
||||||
subject.stub(:node).and_return(chef_run.node)
|
subject.stub(:node).and_return(chef_run.node)
|
||||||
subject.stub(:search_for)
|
subject.stub(:search_for)
|
||||||
@@ -115,9 +115,9 @@ describe 'openstack-common::default' do
|
|||||||
|
|
||||||
it 'returns sorted rabbit servers' do
|
it 'returns sorted rabbit servers' do
|
||||||
nodes = [
|
nodes = [
|
||||||
{ 'openstack' => { 'mq' => { 'listen' => '3.3.3.3', 'port' => '5672' } } },
|
{ 'openstack' => { 'mq' => { 'listen' => '3.3.3.3' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||||
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1', 'port' => '5672' } } },
|
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||||
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2', 'port' => '5672' } } }
|
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
|
||||||
]
|
]
|
||||||
subject.stub(:node).and_return(chef_run.node)
|
subject.stub(:node).and_return(chef_run.node)
|
||||||
subject.stub(:search_for)
|
subject.stub(:search_for)
|
||||||
|
|||||||
Reference in New Issue
Block a user