Merge "Enable Distributed Virtual Router"

This commit is contained in:
Jenkins 2015-03-07 00:17:16 +00:00 committed by Gerrit Code Review
commit 09410efea6
12 changed files with 137 additions and 16 deletions

View File

@ -142,6 +142,8 @@ L3 Agent Configuration
* `openstack['openstack']['network']['l3']['ha']['l3_ha']` - (BoolOpt) If True, virtual router will be created as ha by default. (default False)
* `openstack['openstack']['network']['l3']['ha']['max_l3_agents_per_router']` - (IntOpt) The maximum number of l3 agents for each ha router. (default 3)
* `openstack['openstack']['network']['l3']['ha']['ha_vrrp_advert_int']` - (IntOpt) The advertisement interval in seconds. (default 2)
* `openstack['openstack']['network']['l3']['router_distributed'] - Both true(bool) and 'true'(str) will set DVR(Distributed Virtual Router) configure enabled. Setting 'auto' will do a simple check then decide whether or not to enable DVR, default is enabled with OVS.
* `openstack['openstack']['network']['l3']['router_delete_namespaces'] - (StrOpt) If True, namespaces will be deleted when a router is destroyed.
VPN Agent Configuration
----------------------

View File

@ -330,6 +330,13 @@ default['openstack']['network']['dhcp']['dhcp_agents_per_network'] = 1
# ============================= L3 Agent Configuration =====================
# For DVR(Disributed Virtual Router) is still not stable and rubost,
# so it make sense to set DVR disabled by default. User can set this
# attribute ture(bool) or 'ture'(bool) to enable DVR if they what
# they are doing. Set this 'auto', cookbook will do a simple check
# to decide whether or not to enable DVR, default is enabled with OVS.
default['openstack']['network']['l3']['router_distributed'] = 'False'
# The scheduler class to use for scheduling routers to L3 agents
default['openstack']['network']['l3']['scheduler'] = 'neutron.scheduler.l3_agent_scheduler.ChanceScheduler'

13
libraries/utils.rb Normal file
View File

@ -0,0 +1,13 @@
# encoding: UTF-8
#
# Library:: utils
module ::Utils
def recipe_included?(recipe)
if node['recipes'].include?(recipe)
return true
else
return false
end
end
end

View File

@ -30,6 +30,7 @@ require 'uri'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
include ::Utils
end
# Make Openstack object available in Chef::Resource::RubyBlock
@ -186,6 +187,21 @@ ruby_block 'query service tenant uuid' do
end
end
if node['openstack']['network']['l3']['router_distributed'] == 'auto'
if node['openstack']['network']['interface_driver'].split('.').last != 'OVSInterfaceDriver'
node.set['openstack']['network']['l3']['router_distributed'] = 'false'
Chef::Log.warn('OVSInterfaceDirver is not used as interface_driver, DVR is not supported without OVS')
end
end
router_distributed = 'False'
if ['auto', 'true', true].include?(node['openstack']['network']['l3']['router_distributed'])
if recipe_included? 'openstack-network::server'
router_distributed = 'True'
else
router_distributed = 'False'
end
end
template '/etc/neutron/neutron.conf' do
source 'neutron.conf.erb'
owner node['openstack']['network']['platform']['user']
@ -203,7 +219,8 @@ template '/etc/neutron/neutron.conf' do
service_pass: service_pass,
sql_connection: sql_connection,
nova_endpoint: nova_endpoint,
nova_admin_pass: nova_admin_pass
nova_admin_pass: nova_admin_pass,
router_distributed: router_distributed
)
notifies :restart, 'service[neutron-server]', :delayed
@ -335,12 +352,19 @@ when 'midonet'
when 'ml2'
template_file = '/etc/neutron/plugins/ml2/ml2_conf.ini'
mechanism_drivers = node['openstack']['network']['ml2']['mechanism_drivers']
if node['openstack']['network']['l3']['router_distributed'] == 'auto'
mechanism_drivers = 'openvswitch,l2population'
end
template template_file do
source 'plugins/ml2/ml2_conf.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
variables(
mechanism_drivers: mechanism_drivers
)
notifies :restart, 'service[neutron-server]', :delayed
end
@ -375,6 +399,14 @@ when 'openvswitch'
openvswitch_endpoint = endpoint 'network-openvswitch'
template_file = '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini'
tunnel_types = node['openstack']['network']['openvswitch']['tunnel_types']
l2_population = 'False'
enable_distributed_routing = 'False'
if ['auto', 'true', true].include?(node['openstack']['network']['l3']['router_distributed'])
tunnel_types = 'gre, vxlan'
l2_population = 'True'
enable_distributed_routing = 'True'
end
template template_file do
source 'plugins/openvswitch/ovs_neutron_plugin.ini.erb'
@ -382,7 +414,10 @@ when 'openvswitch'
group node['openstack']['network']['platform']['group']
mode 00644
variables(
local_ip: openvswitch_endpoint.host
local_ip: openvswitch_endpoint.host,
tunnel_types: tunnel_types,
l2_population: l2_population,
enable_distributed_routing: enable_distributed_routing
)
notifies :restart, 'service[neutron-server]', :delayed
if node.run_list.expand(node.chef_environment).recipes.include?('openstack-network::openvswitch')

View File

@ -22,6 +22,12 @@
include_recipe 'openstack-network'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
include ::Openstack
include ::Utils
end
ruby_block 'query gateway external network uuid' do
block do
begin
@ -69,11 +75,22 @@ service 'neutron-l3-agent' do
end
end
agent_mode = 'legacy'
if [true, 'true', 'auto'].include?(node['openstack']['network']['l3']['router_distributed'])
if recipe_included? 'openstack-network::server'
agent_mode = 'dvr_snat'
elsif recipe_included? 'openstack-compute::compute'
agent_mode = 'dvr'
end
end
template '/etc/neutron/l3_agent.ini' do
source 'l3_agent.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00640
variables(
agent_mode: agent_mode
)
unless node['openstack']['network']['enable_vpn']
notifies :restart, 'service[neutron-l3-agent]', :immediately
end

View File

@ -106,13 +106,24 @@ directory '/etc/neutron/plugins/openvswitch' do
end
openvswitch_endpoint = endpoint 'network-openvswitch'
tunnel_types = node['openstack']['network']['openvswitch']['tunnel_types']
l2_population = 'False'
enable_distributed_routing = 'False'
if ['auto', 'true', true].include?(node['openstack']['network']['l3']['router_distributed'])
tunnel_types = 'gre, vxlan'
l2_population = 'True'
enable_distributed_routing = 'True'
end
template '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini' do
source 'plugins/openvswitch/ovs_neutron_plugin.ini.erb'
owner node['openstack']['network']['platform']['user']
group node['openstack']['network']['platform']['group']
mode 00644
variables(
local_ip: openvswitch_endpoint.host
local_ip: openvswitch_endpoint.host,
tunnel_types: tunnel_types,
l2_population: l2_population,
enable_distributed_routing: enable_distributed_routing
)
only_if { platform_family?('rhel') }
end
@ -162,3 +173,9 @@ unless ['nicira', 'plumgrid', 'bigswitch'].include?(main_plugin)
end
end
end
if [true, 'true', 'auto'].include?(node['openstack']['network']['l3']['router_distributed'])
if !node['recipes'].include?('openstack-network::server') && node['recipes'].include?('openstack-compute::compute')
include_recipe 'openstack-network::l3_agent'
end
end

View File

@ -298,8 +298,7 @@ describe 'openstack-network' do
tunnel_bridge: 'br-tun',
int_peer_patch_port: '',
tun_peer_patch_port: '',
bridge_mappings: '',
tunnel_types: ''
bridge_mappings: ''
}.each do |attr, value|
it "sets the default #{attr} when present" do
if value.present?
@ -330,6 +329,17 @@ describe 'openstack-network' do
node.set['openstack']['network']['openvswitch']['fw_driver'] = 'fw_driver_value'
expect(chef_run).to render_file(file.name).with_content(/^firewall_driver = fw_driver_value$/)
end
it 'sets related attributes for distributed routers' do
node.set['openstack']['network']['l3']['router_distributed'] = true
[
/^enable_distributed_routing = True$/,
/^l2_population = True$/,
/^tunnel_types = gre, vxlan$/
].each do |line|
expect(chef_run).to render_config_file(file.name).with_section_content('agent', line)
end
end
end
it_behaves_like 'core plugin common configurator',
@ -414,6 +424,18 @@ describe 'openstack-network' do
expect(chef_run).not_to render_file(file.name).with_content(%r(^log_config = /etc/openstack/logging.conf$))
end
it 'set the router_distributed attribute for network node' do
node.set['openstack']['network']['l3']['router_distributed'] = true
allow_any_instance_of(Chef::Recipe).to receive(:recipe_included?).with('openstack-network::server').and_return(true)
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^router_distributed = True$/)
end
it 'set the router_distributed attribute for compute node' do
node.set['openstack']['network']['l3']['router_distributed'] = true
allow_any_instance_of(Chef::Recipe).to receive(:recipe_included?).with('openstack-network::server').and_return(false)
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^router_distributed = False$/)
end
%w(host port).each do |attr|
it "sets the bind #{attr} attribute" do
expect(chef_run).to render_file(file.name).with_content(/^bind_#{attr} = network_#{attr}$/)

View File

@ -83,6 +83,19 @@ describe 'openstack-network::l3_agent' do
end
end
it 'sets the agent_mode attribute to dvr_snat' do
node.set['openstack']['network']['l3']['router_distributed'] = true
allow_any_instance_of(Chef::Recipe).to receive(:recipe_included?).with('openstack-network::server').and_return(true)
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^agent_mode = dvr_snat$/)
end
it 'sets the agent_mode attribute to dvr' do
node.set['openstack']['network']['l3']['router_distributed'] = true
allow_any_instance_of(Chef::Recipe).to receive(:recipe_included?).with('openstack-network::server').and_return(false)
allow_any_instance_of(Chef::Recipe).to receive(:recipe_included?).with('openstack-compute::compute').and_return(true)
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^agent_mode = dvr$/)
end
it 'sets the ha_vrrp_advert_int attribute' do
node.set['openstack']['network']['l3']['ha']['ha_vrrp_advert_int'] = 'ha_vrrp_advert_int_value'
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^ha_vrrp_advert_int = ha_vrrp_advert_int_value$/)

View File

@ -90,7 +90,7 @@ router_delete_namespaces = <%= node['openstack']['network']['l3']['router_delete
# - dvr_snat: this enables centralized SNAT support in conjunction with
# DVR. This mode must be used for an L3 agent running on a centralized
# node (or in single-host deployments, e.g. devstack).
# agent_mode = legacy
agent_mode = <%= @agent_mode %>
# Location to store keepalived and all HA configurations
# ha_confs_path = $state_path/ha_confs
@ -103,4 +103,3 @@ router_delete_namespaces = <%= node['openstack']['network']['l3']['router_delete
# The advertisement interval in seconds
ha_vrrp_advert_int = <%= node['openstack']['network']['l3']['ha']['ha_vrrp_advert_int'] %>

View File

@ -9,7 +9,7 @@ verbose = <%= node["openstack"]["network"]["verbose"] %>
# the type of the router on the create request (admin-only attribute). Default
# value is "False" to support legacy mode (centralized) routers.
#
# router_distributed = False
router_distributed = <%= @router_distributed %>
#
# ===========End Global Config Option for Distributed L3 Router===============

View File

@ -23,7 +23,7 @@ tenant_network_types = <%= node['openstack']['network']['ml2']['tenant_network_t
# Example: mechanism_drivers = cisco,logger
# Example: mechanism_drivers = openvswitch,brocade
# Example: mechanism_drivers = linuxbridge,brocade
mechanism_drivers = <%= node['openstack']['network']['ml2']['mechanism_drivers'] %>
mechanism_drivers = <%= @mechanism_drivers %>
[ml2_type_flat]
# (ListOpt) List of physical_network names with which flat networks

View File

@ -131,9 +131,7 @@ polling_interval = <%= node['openstack']['network']['openvswitch']['polling_inte
# Example: tunnel_types = gre
# Example: tunnel_types = vxlan
# Example: tunnel_types = vxlan, gre
<% if node["openstack"]["network"]["openvswitch"]["tunnel_types"] -%>
tunnel_types = <%= node["openstack"]["network"]["openvswitch"]["tunnel_types"] %>
<% end -%>
tunnel_types = <%= @tunnel_types %>
# (IntOpt) The port number to utilize if tunnel_types includes 'vxlan'. By
# default, this will make use of the Open vSwitch default value of '4789' if
@ -154,8 +152,7 @@ veth_mtu = <%= node["openstack"]["network"]["openvswitch"]["veth_mtu"] %>
# enable plugin to populate remote ports macs and IPs (using fdb_add/remove
# RPC calbbacks instead of tunnel_sync/update) on OVS agents in order to
# optimize tunnel management.
#
# l2_population = False
l2_population = <%= @l2_population %>
# Enable local ARP responder. Requires OVS 2.1. This is only used by the l2
# population ML2 MechanismDriver.
@ -169,8 +166,7 @@ veth_mtu = <%= node["openstack"]["network"]["openvswitch"]["veth_mtu"] %>
# (BoolOpt) Set to True on L2 agents to enable support
# for distributed virtual routing.
#
# enable_distributed_routing = False
enable_distributed_routing = <%= @enable_distributed_routing %>
[securitygroup]
# Firewall driver for realizing neutron security group function.