Added Contrail Networks support

Change-Id: I775336f2ef00358ca2ef3a7a84cb9fcc4735eb60
Partial-Bug: #1535987
This commit is contained in:
Feng Xi Yan 2016-01-20 12:20:36 +08:00
parent 8eeaeeced4
commit aa4f04c4a5
4 changed files with 65 additions and 2 deletions

View File

@ -176,7 +176,8 @@ default['openstack']['network']['core_plugin_map'] = {
'ovsneutronpluginv2' => 'openvswitch',
'linuxbridgepluginv2' => 'linuxbridge',
'ml2plugin' => 'ml2',
'nuageplugin' => 'nuage'
'nuageplugin' => 'nuage',
'neutronplugincontrailcorev2' => 'contrail'
}
# This is used by SUSE to setup the sysconfig neutron initfile

View File

@ -485,6 +485,34 @@ when 'nuage'
notifies :restart, 'service[neutron-server]', :delayed if role_match
end
when 'contrail'
# Workaround to generate a fake contrail plugin config
openvswitch_endpoint = endpoint 'network-openvswitch'
template_file = '/etc/neutron/plugins/contrail/contrail_plugin.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,
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 role_match
if node['recipes'].include?('openstack-network::openvswitch')
notifies :restart, 'service[neutron-plugin-openvswitch-agent]', :delayed
end
end
else
Chef::Log.fatal("Main plugin #{main_plugin}is not supported")
end
@ -495,6 +523,7 @@ link '/etc/neutron/plugin.ini' do
group node['openstack']['network']['platform']['group']
action :create
only_if { platform_family? %w(fedora rhel) }
not_if { main_plugin == 'contrail' }
end
node.set['openstack']['network']['plugin_config_file'] = template_file

View File

@ -28,7 +28,12 @@ shared_examples 'core plugin common configurator' do |plugin_name, file_name, at
end
it "sets the #{attr} attribute" do
node.set['openstack']['network'][plugin_name][attr] = "#{attr}_value"
if plugin_name == 'contrail'
component_name = 'ml2'
else
component_name = plugin_name
end
node.set['openstack']['network'][component_name][attr] = "#{attr}_value"
expect(chef_run).to render_file(cfg_file.name).with_content(/^#{attr} = #{attr}_value$/)
end
end
@ -373,6 +378,33 @@ describe 'openstack-network' do
end
end
describe 'contrail' do
let(:file) { chef_run.template('/etc/neutron/plugins/contrail/contrail_plugin.ini') }
before do
node.set['openstack']['network']['core_plugin'] = 'contrail'
end
it 'sends a notification to the service' do
allow_any_instance_of(Chef::Recipe).to receive(:role_included?).with('os-network-server').and_return(true)
expect(file).to notify('service[neutron-server]').to(:restart).delayed
end
it_behaves_like 'core plugin common configurator',
'contrail',
PLUGIN_MAP['contrail'],
type_drivers: 'local,flat,vlan,gre,vxlan',
tenant_network_types: 'local',
mechanism_drivers: 'openvswitch',
flat_networks: '',
network_vlan_ranges: '',
tunnel_id_ranges: '',
vni_ranges: '',
vxlan_group: '',
enable_security_group: 'True',
enable_ipset: 'True'
end
it_behaves_like 'core plugin common configurator',
'plumgrid',
PLUGIN_MAP['plumgrid'],

View File

@ -65,6 +65,7 @@ PLUGIN_MAP = {
'nec' => 'nec.ini',
'nicira' => 'nvp.ini',
'nuage' => 'nuage_plugin.ini',
'contrail' => 'contrail_plugin.ini',
'openvswitch' => 'ovs_neutron_plugin.ini',
'plumgrid' => 'plumgrid.ini',
'ryu' => 'ryu.ini'