diff --git a/attributes/default.rb b/attributes/default.rb index ac5e8213..2acaf908 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -147,6 +147,7 @@ default['openstack']['network']['service_plugins'] = [] # # - neutron.agent.linux.interface.OVSInterfaceDriver # - neutron.agent.linux.interface.BridgeInterfaceDriver +# - neutron.agent.linux.interface.Ml2InterfaceDriver # default['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.OVSInterfaceDriver' @@ -154,12 +155,14 @@ default['openstack']['network']['interface_driver'] = 'neutron.agent.linux.inter # maps the above driver to a plugin name default['openstack']['network']['interface_driver_map'] = { 'ovsinterfacedriver' => 'openvswitch', - 'bridgeinterfacedriver' => 'linuxbridge' + 'bridgeinterfacedriver' => 'linuxbridge', + 'ml2interfacedriver' => 'ml2' } default['openstack']['network']['plugin_conf_map'] = { 'ovsinterfacedriver' => 'openvswitch/ovs_neutron_plugin.ini', - 'bridgeinterfacedriver' => 'linuxbridge/linuxbridge_conf.ini' + 'bridgeinterfacedriver' => 'linuxbridge/linuxbridge_conf.ini', + 'ml2interfacedriver' => 'ml2/ml2_conf.ini' } # The agent can use other DHCP drivers. Dnsmasq is the simplest and requires diff --git a/recipes/common.rb b/recipes/common.rb index 796bb19b..e07defca 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -191,15 +191,6 @@ end # physical servers like the l3 agent, so we assume # the plugin configuration is a "common" file -template '/etc/neutron/plugins/ml2/ml2_conf.ini' do - source 'plugins/ml2/ml2_conf.ini.erb' - owner node['openstack']['network']['platform']['user'] - group node['openstack']['network']['platform']['group'] - mode 00644 - - notifies :restart, 'service[neutron-server]', :delayed -end - template_file = nil plugin_file = '/etc/neutron/plugin.ini' @@ -300,6 +291,20 @@ when 'midonet' notifies :restart, 'service[neutron-server]', :delayed end +when 'ml2' + + template_file = '/etc/neutron/plugins/ml2/ml2_conf.ini' + + 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 + + notifies :create, "link[#{plugin_file}]", :immediately + notifies :restart, 'service[neutron-server]', :delayed + end + when 'nec' template_file = '/etc/neutron/plugins/nec/nec.ini' diff --git a/recipes/server.rb b/recipes/server.rb index d4fff67b..734a186f 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -43,9 +43,11 @@ end # Migrate network database # If the database has never migrated, make the current version of alembic_version to havana, # else migrate the database to latest version. +# The node['openstack']['network']['plugin_config_file'] attribute is set in the common.rb recipe + bash 'migrate network database' do plugin_config_file = node['openstack']['network']['plugin_config_file'] - migrate_command = "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --config-file #{plugin_config_file}" + migrate_command = "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file #{plugin_config_file}" code <<-EOF current_version_line=`#{migrate_command} current 2>&1 | tail -n 1` # determine if the $current_version_line ends with ": None" diff --git a/spec/server_spec.rb b/spec/server_spec.rb index f444c5e7..0511df93 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -521,9 +521,17 @@ describe 'openstack-network::server' do describe '/etc/neutron/plugins/ml2/ml2_conf.ini' do before do + @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS + @chef_run.node.set['openstack']['compute']['network']['service_type'] = 'neutron' + @chef_run.node.set['openstack']['network']['interface_driver'] = 'neutron.agent.linux.interface.Ml2InterfaceDriver' + @chef_run.converge 'openstack-network::server' @file = @chef_run.template('/etc/neutron/plugins/ml2/ml2_conf.ini') end + it 'create template ml2_conf.ini' do + expect(@chef_run).to render_file(@file.name) + end + it 'has proper owner' do expect(@file.owner).to eq('neutron') expect(@file.group).to eq('neutron')