diff --git a/attributes/default.rb b/attributes/default.rb index 897ad091..d4e9efde 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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 diff --git a/recipes/default.rb b/recipes/default.rb index 45578197..d9714293 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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 diff --git a/spec/default_spec.rb b/spec/default_spec.rb index a5e180b1..2a2cb7d9 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -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'], diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9f397e08..2714bef2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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'