Allow nova interactions attributes

Enable attributes for neutron interaction with nova.
This uses the new Common CLI method in change:
I2b2f1d94dbd67550ad3a352c2205a532173f6065

The default is to make a call into keystone CLI to query the service tenant
UUID and use that in the neuton.conf file. If the UUID is overridden, no
CLI call is made.  This does not pre-req any Compute recipes, just new Common
method.
Also see this bug: 1298640 for how the nova_url is handled, not obvious.
Added TODO's to look at handling this type of url situation better from Common.

Implements: blueprint neutron-icehouse-default-changes
Change-Id: I89dd47c802a544bdd998059b36884cb10f628223
This commit is contained in:
Mark Vanderwiel 2014-03-27 14:59:26 -05:00
parent 72be6bc841
commit e725b99b04
5 changed files with 214 additions and 1 deletions

View File

@ -187,6 +187,31 @@ default['openstack']['network']['rpc_thread_pool_size'] = 64
default['openstack']['network']['rpc_conn_pool_size'] = 30
default['openstack']['network']['rpc_response_timeout'] = 60
# ======== Neutron Nova interactions ==========
# Send notification to nova when port status is active.
default['openstack']['network']['nova']['notify_nova_on_port_status_changes'] = 'True'
# Send notifications to nova when port data (fixed_ips/floatingips) change
# so nova can update it's cache.
default['openstack']['network']['nova']['notify_nova_on_port_data_changes'] = 'True'
# Name of nova region to use. Useful if keystone manages more than one region
default['openstack']['network']['nova']['region_name'] = node['openstack']['region']
# Username for connection to nova in admin context
default['openstack']['network']['nova']['admin_username'] = 'nova'
# Version for connection to nova
# TODO: (MRV) Need to allow for this in Common.
default['openstack']['network']['nova']['url_version'] = '/v2'
# The uuid of the nova tenant
# Nil will cause the uuid to be queried from keystone.
default['openstack']['network']['nova']['admin_tenant_id'] = nil
# Number of seconds between sending events to nova if there are any events to send
default['openstack']['network']['nova']['send_events_interval'] = 2
# ============================= DHCP Agent Configuration ===================
# The scheduler class to use for scheduling to DHCP agents

View File

@ -29,6 +29,11 @@ class ::Chef::Recipe
include ::Openstack
end
# Make Openstack object available in Chef::Resource::RubyBlock
class ::Chef::Resource::RubyBlock
include ::Openstack
end
platform_options = node['openstack']['network']['platform']
driver_name = node['openstack']['network']['interface_driver'].split('.').last.downcase
@ -140,6 +145,39 @@ service 'neutron-server' do
action :nothing
end
# Nova interactions
nova_endpoint = endpoint 'compute-api'
# TODO(MRV): Need to allow for this in common.
# Neutron will append the admin_tenant_id for these nova interaction calls,
# remove the tenant_id so we don't end up with two of them on the url.
# Need to also allow for getting at nova endpoint version.
# https://github.com/openstack/neutron/blob/master/neutron/common/config.py#L89
# https://github.com/openstack/neutron/blob/master/neutron/notifiers/nova.py#L43
nova_version = node['openstack']['network']['nova']['url_version']
nova_endpoint = uri_from_hash('host' => nova_endpoint.host.to_s, 'port' => nova_endpoint.port.to_s, 'path' => nova_version)
nova_admin_pass = get_password 'service', 'openstack-compute'
ruby_block 'query service tenant uuid' do
# query keystone for the service tenant uuid
block do
begin
admin_user = node['openstack']['identity']['admin_user']
admin_tenant = node['openstack']['identity']['admin_tenant_name']
env = openstack_command_env admin_user, admin_tenant
tenant_id = identity_uuid 'tenant', 'name', 'service', env
Chef::Log.error('service tenant UUID for nova_admin_tenant_id not found.') if tenant_id.nil?
node.set['openstack']['network']['nova']['admin_tenant_id'] = tenant_id
rescue RuntimeError => e
Chef::Log.error("Could not query service tenant UUID for nova_admin_tenant_id. Error was #{e.message}")
end
end
action :run
only_if do
(node['openstack']['network']['nova']['notify_nova_on_port_status_changes'] == 'True' ||
node['openstack']['network']['nova']['notify_nova_on_port_data_changes'] == 'True') &&
node['openstack']['network']['nova']['admin_tenant_id'].nil?
end
end
template '/etc/neutron/neutron.conf' do
source 'neutron.conf.erb'
owner node['openstack']['network']['platform']['user']
@ -155,7 +193,9 @@ template '/etc/neutron/neutron.conf' do
auth_uri: auth_uri,
identity_admin_endpoint: identity_admin_endpoint,
service_pass: service_pass,
sql_connection: sql_connection
sql_connection: sql_connection,
nova_endpoint: nova_endpoint,
nova_admin_pass: nova_admin_pass
)
notifies :restart, 'service[neutron-server]', :delayed

View File

@ -472,6 +472,114 @@ describe 'openstack-network::server' do
expect(chef_run).to render_file(file.name).with_content(
'service_provider = provider2')
end
it 'has the overridable default nova interaction values' do
expect(chef_run).to render_file(file.name).with_content(
'notify_nova_on_port_status_changes = True')
expect(chef_run).to render_file(file.name).with_content(
'notify_nova_on_port_data_changes = True')
expect(chef_run).to render_file(file.name).with_content(
'nova_url = http://127.0.0.1:8774/v2')
expect(chef_run).to render_file(file.name).with_content(
'nova_region_name = RegionOne')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_username = nova')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id =')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_password = nova-pass')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_auth_url = http://127.0.0.1:35357/v2.0')
expect(chef_run).to render_file(file.name).with_content(
'send_events_interval = 2')
expect(chef_run).to run_ruby_block('query service tenant uuid')
end
describe 'query service tenant uuid' do
it 'has queried service tenant uuid for nova interactions' do
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('000-UUID-FROM-CLI')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 000-UUID-FROM-CLI')
end
it 'has status changes for nova interactions disabled without id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_status_changes'] = 'False'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('000-UUID-FROM-CLI')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 000-UUID-FROM-CLI')
end
it 'has data changes for nova interactions disabled without id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_data_changes'] = 'False'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('000-UUID-FROM-CLI')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 000-UUID-FROM-CLI')
end
it 'has all changes for nova interactions disabled without id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_status_changes'] = 'False'
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_data_changes'] = 'False'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq(nil)
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id =')
end
it 'has status changes for nova interactions disabled with id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_status_changes'] = 'False'
chef_run.node.set['openstack']['network']['nova']['admin_tenant_id'] = '111-UUID-OVERRIDE'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('111-UUID-OVERRIDE')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 111-UUID-OVERRIDE')
end
it 'has data changes for nova interactions disabled with id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_data_changes'] = 'False'
chef_run.node.set['openstack']['network']['nova']['admin_tenant_id'] = '111-UUID-OVERRIDE'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('111-UUID-OVERRIDE')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 111-UUID-OVERRIDE')
end
it 'has all changes for nova interactions disabled with id override' do
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_status_changes'] = 'False'
chef_run.node.set['openstack']['network']['nova']['notify_nova_on_port_data_changes'] = 'False'
chef_run.node.set['openstack']['network']['nova']['admin_tenant_id'] = '111-UUID-OVERRIDE'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('111-UUID-OVERRIDE')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 111-UUID-OVERRIDE')
end
it 'has overriden service tenant uuid for nova interactions' do
chef_run.node.set['openstack']['network']['nova']['admin_tenant_id'] = '111-UUID-OVERRIDE'
# run actual ruby_block resource
chef_run.find_resource(:ruby_block, 'query service tenant uuid').old_run_action(:create)
nova_tenant_id = chef_run.node['openstack']['network']['nova']['admin_tenant_id']
expect(nova_tenant_id).to eq('111-UUID-OVERRIDE')
expect(chef_run).to render_file(file.name).with_content(
'nova_admin_tenant_id = 111-UUID-OVERRIDE')
end
end
end
describe '/etc/default/neutron-server' do

View File

@ -75,6 +75,15 @@ shared_context 'neutron-stubs' do
.with('user', 'guest')
.and_return('mq-pass')
Chef::Application.stub(:fatal!)
Chef::Recipe.any_instance.stub(:get_password)
.with('service', 'openstack-compute')
.and_return('nova-pass')
Chef::Resource::RubyBlock.any_instance.stub(:openstack_command_env)
.with('admin', 'admin')
.and_return({})
Chef::Resource::RubyBlock.any_instance.stub(:identity_uuid)
.with('tenant', 'name', 'service', {})
.and_return('000-UUID-FROM-CLI')
stub_command('dpkg -l | grep openvswitch-switch | grep 1.10.2-1').and_return(true)
stub_command('ovs-vsctl br-exists br-int').and_return(false)

View File

@ -270,6 +270,37 @@ router_scheduler_driver = <%= node["openstack"]["network"]["l3"]["scheduler"] %>
#ssl_ca_file = /path/to/cafile
# ======== end of WSGI parameters related to the API server ==========
# ======== neutron nova interactions ==========
# Send notification to nova when port status is active.
notify_nova_on_port_status_changes = <%= node["openstack"]["network"]["nova"]["notify_nova_on_port_status_changes"] %>
# Send notifications to nova when port data (fixed_ips/floatingips) change
# so nova can update it's cache.
notify_nova_on_port_data_changes = <%= node["openstack"]["network"]["nova"]["notify_nova_on_port_data_changes"] %>
# URL for connection to nova (Only supports one nova region currently).
nova_url = <%= @nova_endpoint %>
# Name of nova region to use. Useful if keystone manages more than one region
nova_region_name = <%= node["openstack"]["network"]["nova"]["region_name"] %>
# Username for connection to nova in admin context
nova_admin_username = <%= node["openstack"]["network"]["nova"]["admin_username"] %>
# The uuid of the admin nova tenant
nova_admin_tenant_id = <%= node["openstack"]["network"]["nova"]["admin_tenant_id"] %>
# Password for connection to nova in admin context.
nova_admin_password = <%= @nova_admin_pass %>
# Authorization URL for connection to nova in admin context.
nova_admin_auth_url = <%= @identity_admin_endpoint.to_s %>
# Number of seconds between sending events to nova if there are any events to send
send_events_interval = <%= node["openstack"]["network"]["nova"]["send_events_interval"] %>
# ======== end of neutron nova interactions ==========
[QUOTAS]
# resource name(s) that are supported in quota features
quota_items = <%= node["openstack"]["network"]["quota"]["items"] %>