diff --git a/lib/puppet/provider/neutron_plugin_sriov/ini_setting.rb b/lib/puppet/provider/neutron_plugin_sriov/ini_setting.rb new file mode 100644 index 000000000..3256b3990 --- /dev/null +++ b/lib/puppet/provider/neutron_plugin_sriov/ini_setting.rb @@ -0,0 +1,10 @@ +Puppet::Type.type(:neutron_plugin_sriov).provide( + :ini_setting, + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) +) do + + def file_path + '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini' + end + +end diff --git a/lib/puppet/provider/neutron_sriov_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_sriov_agent_config/ini_setting.rb new file mode 100644 index 000000000..64e3194ae --- /dev/null +++ b/lib/puppet/provider/neutron_sriov_agent_config/ini_setting.rb @@ -0,0 +1,9 @@ +Puppet::Type.type(:neutron_sriov_agent_config).provide( + :ini_setting, + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) +) do + + def file_path + '/etc/neutron/plugins/ml2/sriov_agent.ini' + end +end diff --git a/lib/puppet/type/neutron_plugin_sriov.rb b/lib/puppet/type/neutron_plugin_sriov.rb new file mode 100644 index 000000000..55e0e88c6 --- /dev/null +++ b/lib/puppet/type/neutron_plugin_sriov.rb @@ -0,0 +1,25 @@ +Puppet::Type.newtype(:neutron_plugin_sriov) do + + ensurable + + newparam(:name, :namevar => true) do + desc 'Section/setting name to manage from /etc/neutron/plugins/ml2/ml2_conf_sriov.ini' + newvalues(/\S+\/\S+/) + end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + + autorequire(:package) do ['neutron'] end + + newproperty(:value) do + desc 'The value of the setting to be defined.' + munge do |value| + value = value.to_s.strip + value.capitalize! if value =~ /^(true|false)$/i + value + end + end +end diff --git a/lib/puppet/type/neutron_sriov_agent_config.rb b/lib/puppet/type/neutron_sriov_agent_config.rb new file mode 100644 index 000000000..b110db73c --- /dev/null +++ b/lib/puppet/type/neutron_sriov_agent_config.rb @@ -0,0 +1,25 @@ +Puppet::Type.newtype(:neutron_sriov_agent_config) do + + ensurable + + newparam(:name, :namevar => true) do + desc 'Section/setting name to manage from /etc/neutron/plugins/ml2/sriov_agent.ini' + newvalues(/\S+\/\S+/) + end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + + autorequire(:package) do ['neutron'] end + + newproperty(:value) do + desc 'The value of the setting to be defined.' + munge do |value| + value = value.to_s.strip + value.capitalize! if value =~ /^(true|false)$/i + value + end + end +end diff --git a/manifests/agents/ml2/sriov.pp b/manifests/agents/ml2/sriov.pp index 601754502..7c5a24868 100644 --- a/manifests/agents/ml2/sriov.pp +++ b/manifests/agents/ml2/sriov.pp @@ -51,6 +51,8 @@ # that should not be used for virtual networking. excluded_devices is a # semicolon separated list of virtual functions to exclude from network_device. # The network_device in the mapping should appear in the physical_device_mappings list. +# + class neutron::agents::ml2::sriov ( $package_ensure = 'present', $enabled = true, @@ -62,16 +64,15 @@ class neutron::agents::ml2::sriov ( include ::neutron::params - Neutron_plugin_ml2<||> ~> Service['neutron-sriov-nic-agent-service'] + Neutron_sriov_agent_config <||> ~> Service['neutron-sriov-nic-agent-service'] - neutron_plugin_ml2 { + neutron_sriov_agent_config { 'sriov_nic/polling_interval': value => $polling_interval; 'sriov_nic/exclude_devices': value => join($exclude_devices, ','); 'sriov_nic/physical_device_mappings': value => join($physical_device_mappings, ','); } - - Package['neutron-sriov-nic-agent'] -> Neutron_plugin_ml2<||> + Package['neutron-sriov-nic-agent'] -> Neutron_sriov_agent_config <||> package { 'neutron-sriov-nic-agent': ensure => $package_ensure, name => $::neutron::params::sriov_nic_agent_package, diff --git a/manifests/plugins/ml2/mech_driver.pp b/manifests/plugins/ml2/mech_driver.pp index 3e63cbce6..3633cf301 100644 --- a/manifests/plugins/ml2/mech_driver.pp +++ b/manifests/plugins/ml2/mech_driver.pp @@ -24,14 +24,14 @@ # to the PCI ID Repository. Default enables support for Intel and Mellanox SR-IOV capable NICs # # [*sriov_agent_required*] -# (required) SRIOV neutron agent is required for port binding +# (optional) SRIOV neutron agent is always required for port binding # define neutron::plugins::ml2::mech_driver ( $supported_pci_vendor_devs, - $sriov_agent_required, + $sriov_agent_required = true, ){ if ($name == 'sriovnicswitch') { - neutron_plugin_ml2 { + neutron_plugin_sriov { 'ml2_sriov/supported_pci_vendor_devs': value => join(any2array($supported_pci_vendor_devs), ','); 'ml2_sriov/agent_required': value => $sriov_agent_required; } diff --git a/spec/acceptance/basic_neutron_spec.rb b/spec/acceptance/basic_neutron_spec.rb index 45801fdec..036d3eaa5 100644 --- a/spec/acceptance/basic_neutron_spec.rb +++ b/spec/acceptance/basic_neutron_spec.rb @@ -120,8 +120,9 @@ describe 'basic neutron' do class { '::neutron::plugins::ml2': type_drivers => ['vxlan'], tenant_network_types => ['vxlan'], - mechanism_drivers => ['openvswitch'] + mechanism_drivers => ['openvswitch', 'sriovnicswitch'] } + class { '::neutron::agents::ml2::sriov': } EOS diff --git a/spec/acceptance/neutron_config_spec.rb b/spec/acceptance/neutron_config_spec.rb index 83df02982..b4afb7b0f 100644 --- a/spec/acceptance/neutron_config_spec.rb +++ b/spec/acceptance/neutron_config_spec.rb @@ -30,6 +30,8 @@ describe 'basic neutron_config resource' do File <||> -> Neutron_agent_ovs <||> File <||> -> Neutron_plugin_plumgrid <||> File <||> -> Neutron_plumlib_plumgrid <||> + File <||> -> Neutron_plugin_sriov <||> + File <||> -> Neutron_sriov_agent_config <||> $neutron_directories = ['/etc/neutron', '/etc/neutron/plugins', @@ -59,7 +61,9 @@ describe 'basic neutron_config resource' do '/etc/neutron/vpn_agent.ini', '/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', - '/etc/neutron/plugins/plumgrid/plumgrid.ini'] + '/etc/neutron/plugins/plumgrid/plumgrid.ini', + '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', + '/etc/neutron/plugins/ml2/sriov_agent.ini'] file { $neutron_directories : ensure => directory, @@ -457,13 +461,49 @@ describe 'basic neutron_config resource' do neutron_plumlib_plumgrid { 'DEFAULT/thisshouldexist2' : value => '', - ensure_absent_val => 'toto', - } + ensure_absent_val => 'toto', } neutron_plumlib_plumgrid { 'DEFAULT/thisshouldnotexist2' : value => 'toto', ensure_absent_val => 'toto', } + + neutron_plugin_sriov { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_sriov { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_sriov { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_sriov { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_sriov_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_sriov_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_sriov_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_sriov_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + EOS @@ -490,7 +530,9 @@ describe 'basic neutron_config resource' do '/etc/neutron/vpn_agent.ini', '/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', - '/etc/neutron/plugins/plumgrid/plumgrid.ini'] + '/etc/neutron/plugins/plumgrid/plumgrid.ini', + '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', + '/etc/neutron/plugins/ml2/sriov_agent.ini'] $neutron_files.each do |neutron_conf_file| describe file(neutron_conf_file) do diff --git a/spec/classes/neutron_agents_ml2_sriov_spec.rb b/spec/classes/neutron_agents_ml2_sriov_spec.rb index 979cb5b18..4711a09d2 100644 --- a/spec/classes/neutron_agents_ml2_sriov_spec.rb +++ b/spec/classes/neutron_agents_ml2_sriov_spec.rb @@ -13,6 +13,7 @@ describe 'neutron::agents::ml2::sriov' do :physical_device_mappings => [], :exclude_devices => [], :polling_interval => 2, + :supported_pci_vendor_devs => [], } end @@ -33,19 +34,21 @@ describe 'neutron::agents::ml2::sriov' do it { is_expected.to contain_class('neutron::params') } - it 'configures plugins/ml2/openvswitch_agent.ini' do - is_expected.to contain_neutron_plugin_ml2('sriov_nic/polling_interval').with_value(p[:polling_interval]) - is_expected.to contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(p[:exclude_devices].join(',')) - is_expected.to contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(p[:physical_device_mappings].join(',')) + it 'configures /etc/neutron/plugins/ml2/sriov_agent.ini' do + is_expected.to contain_neutron_sriov_agent_config('sriov_nic/polling_interval').with_value(p[:polling_interval]) + is_expected.to contain_neutron_sriov_agent_config('sriov_nic/exclude_devices').with_value(p[:exclude_devices].join(',')) + is_expected.to contain_neutron_sriov_agent_config('sriov_nic/physical_device_mappings').with_value(p[:physical_device_mappings].join(',')) end + + it 'installs neutron sriov-nic agent package' do is_expected.to contain_package('neutron-sriov-nic-agent').with( :name => platform_params[:sriov_nic_agent_package], :ensure => p[:package_ensure], :tag => ['openstack', 'neutron-package'], ) - is_expected.to contain_package('neutron-sriov-nic-agent').with_before(/Neutron_plugin_ml2\[.+\]/) + is_expected.to contain_package('neutron-sriov-nic-agent').with_before(/Neutron_sriov_agent_config\[.+\]/) end it 'configures neutron sriov agent service' do @@ -75,8 +78,8 @@ describe 'neutron::agents::ml2::sriov' do end it 'configures physical device mappings with exclusion' do - is_expected.to contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(['physnet1:eth2']) - is_expected.to contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(['physnet1:eth1']) + is_expected.to contain_neutron_sriov_agent_config('sriov_nic/exclude_devices').with_value(['physnet1:eth2']) + is_expected.to contain_neutron_sriov_agent_config('sriov_nic/physical_device_mappings').with_value(['physnet1:eth1']) end end end diff --git a/spec/classes/neutron_plugins_ml2_spec.rb b/spec/classes/neutron_plugins_ml2_spec.rb index 0f090f50d..9cdd08c23 100644 --- a/spec/classes/neutron_plugins_ml2_spec.rb +++ b/spec/classes/neutron_plugins_ml2_spec.rb @@ -216,8 +216,8 @@ describe 'neutron::plugins::ml2' do ) end it 'configures sriov mechanism driver with agent_enabled' do - is_expected.to contain_neutron_plugin_ml2('ml2_sriov/supported_pci_vendor_devs').with_value(['15b3:1004,8086:10ca']) - is_expected.to contain_neutron_plugin_ml2('ml2_sriov/agent_required').with_value('true') + is_expected.to contain_neutron_plugin_sriov('ml2_sriov/agent_required').with_value('true') + is_expected.to contain_neutron_plugin_sriov('ml2_sriov/supported_pci_vendor_devs').with_value(['15b3:1004,8086:10ca']) end end