diff --git a/attributes/default.rb b/attributes/default.rb index b2ad9925..6da69cde 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -110,6 +110,11 @@ default["openstack"]["network"]["interface_driver_map"] = { 'bridgeinterfacedriver' => 'linuxbridge' } +default["openstack"]["network"]["plugin_conf_map"] = { + 'ovsinterfacedriver' => 'openvswitch/ovs_quantum_plugin.ini', + 'bridgeinterfacedriver' => 'linuxbridge/linuxbridge_conf.ini' +} + # The agent can use other DHCP drivers. Dnsmasq is the simplest and requires # no additional setup of the DHCP server. default["openstack"]["network"]["dhcp_driver"] = 'quantum.agent.linux.dhcp.Dnsmasq' diff --git a/recipes/openvswitch.rb b/recipes/openvswitch.rb index 2ea3bbd4..cc3a7035 100644 --- a/recipes/openvswitch.rb +++ b/recipes/openvswitch.rb @@ -48,6 +48,12 @@ platform_options["quantum_openvswitch_packages"].each do |pkg| end end +service "quantum-server" do + service_name node["openstack"]["network"]["platform"]["quantum_server_service"] + supports :status => true, :restart => true + action :nothing +end + service "quantum-openvswitch-switch" do service_name platform_options["quantum_openvswitch_service"] supports :status => true, :restart => true diff --git a/recipes/server.rb b/recipes/server.rb index a36bd58f..140c3814 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -70,3 +70,17 @@ if node["openstack"]["network"]["quantum_ha_cmd_cron"] command "sleep #{sleep_time} ; . /root/openrc && #{node["openstack"]["network"]["quantum_ha_cmd"]} --replicate-dhcp > /dev/null 2>&1" end end + +# the default SUSE initfile uses this sysconfig file to determine the +# quantum plugin to use +template "/etc/sysconfig/quantum" do + only_if { platform? "suse" } + source "quantum.sysconfig.erb" + owner "root" + group "root" + mode 00644 + variables( + :plugin_conf => node["openstack"]["network"]["plugin_conf_map"][driver_name] + ) + notifies :restart, "service[quantum-server]" +end diff --git a/spec/server-opensuse_spec.rb b/spec/server-opensuse_spec.rb index 89b326d5..b08d5643 100644 --- a/spec/server-opensuse_spec.rb +++ b/spec/server-opensuse_spec.rb @@ -28,5 +28,36 @@ describe 'openstack-network::server' do expect(chef_run).not_to install_package "openstack-quantum-openvswitch" end + + describe "/etc/sysconfig/quantum" do + before do + @file = @chef_run.template("/etc/sysconfig/quantum") + end + + it "has proper owner" do + expect(@file).to be_owned_by "root", "root" + end + + it "has proper modes" do + expect(sprintf("%o", @file.mode)).to eq "644" + end + + it "has the correct plugin config location - ovs by default" do + expect(@chef_run).to create_file_with_content( + @file.name, "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini") + end + + it "uses linuxbridge when configured to use it" do + chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS do |n| + n.set["openstack"]["network"]["interface_driver"] = "quantum.agent.linux.interface.BridgeInterfaceDriver" + end + chef_run.converge "openstack-network::server" + + expect(chef_run).to create_file_with_content( + "/etc/sysconfig/quantum", + "/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini" + ) + end + end end end diff --git a/spec/server_spec.rb b/spec/server_spec.rb index a360039a..659068a1 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -196,5 +196,13 @@ describe 'openstack-network::server' do @file.name, "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini") end end + + it "does not install sysconfig template" do + chef_run = ::ChefSpec::ChefRunner.new( + ::UBUNTU_OPTS.merge(:evaluate_guards => true)) + chef_run.stub_command(/python/, true) + chef_run.converge "openstack-network::server" + expect(chef_run).not_to create_file "/etc/sysconfig/quantum" + end end end diff --git a/templates/default/quantum.sysconfig.erb b/templates/default/quantum.sysconfig.erb new file mode 100644 index 00000000..f6408ce3 --- /dev/null +++ b/templates/default/quantum.sysconfig.erb @@ -0,0 +1,5 @@ +## Type: string +# +# location of the plugin configuration file + +QUANTUM_PLUGIN_CONF="/etc/quantum/plugins/<%= @plugin_conf %>" \ No newline at end of file