diff --git a/manifests/agents/ml2/ovs.pp b/manifests/agents/ml2/ovs.pp index 42f605922..fb15b52ab 100644 --- a/manifests/agents/ml2/ovs.pp +++ b/manifests/agents/ml2/ovs.pp @@ -208,6 +208,11 @@ # the resource provider. # Defaults to $::os_service_default # +# [*resource_provider_inventory_defaults*] +# (optional) Key:value pairs to specify defaults used while reporting packet +# rate inventories,. +# Defauls to empty hash +# # [*explicitly_egress_direct*] # (optional) When set to True, the accepted egress unicast traffic will not # use action NORMAL. The accepted egress packets will be taken care of in the @@ -271,6 +276,7 @@ class neutron::agents::ml2::ovs ( $resource_provider_bandwidths = [], $resource_provider_hypervisors = [], $resource_provider_default_hypervisor = $::os_service_default, + $resource_provider_inventory_defaults = {}, $explicitly_egress_direct = $::os_service_default, $network_log_rate_limit = $::os_service_default, $network_log_burst_limit = $::os_service_default, @@ -374,10 +380,21 @@ class neutron::agents::ml2::ovs ( $resource_provider_hypervisors_real = $::os_service_default } + if empty($resource_provider_inventory_defaults) { + $resource_provider_inventory_defaults_real = $::os_service_default + } else { + if ($resource_provider_inventory_defaults =~ Hash){ + $resource_provider_inventory_defaults_real = join(join_keys_to_values($resource_provider_inventory_defaults, ':'), ',') + } else { + $resource_provider_inventory_defaults_real = join(any2array($resource_provider_inventory_defaults), ',') + } + } + neutron_agent_ovs { 'ovs/resource_provider_bandwidths': value => $resource_provider_bandwidths_real; 'ovs/resource_provider_hypervisors': value => $resource_provider_hypervisors_real; 'ovs/resource_provider_default_hypervisor': value => $resource_provider_default_hypervisor; + 'ovs/resource_provider_inventory_defaults': value => $resource_provider_inventory_defaults_real; } neutron_agent_ovs { diff --git a/manifests/agents/ml2/sriov.pp b/manifests/agents/ml2/sriov.pp index 362886f08..b51739c23 100644 --- a/manifests/agents/ml2/sriov.pp +++ b/manifests/agents/ml2/sriov.pp @@ -92,6 +92,11 @@ # the resource provider. # Defaults to $::os_service_default # +# [*resource_provider_inventory_defaults*] +# (optional) Key:value pairs to specify defaults used while reporting packet +# rate inventories,. +# Defauls to empty hash +# class neutron::agents::ml2::sriov ( $package_ensure = 'present', $enabled = true, @@ -107,6 +112,7 @@ class neutron::agents::ml2::sriov ( $resource_provider_bandwidths = [], $resource_provider_hypervisors = [], $resource_provider_default_hypervisor = $::os_service_default, + $resource_provider_inventory_defaults = {}, ) { include neutron::deps @@ -165,10 +171,21 @@ class neutron::agents::ml2::sriov ( $resource_provider_hypervisors_real = $::os_service_default } + if empty($resource_provider_inventory_defaults) { + $resource_provider_inventory_defaults_real = $::os_service_default + } else { + if ($resource_provider_inventory_defaults =~ Hash){ + $resource_provider_inventory_defaults_real = join(join_keys_to_values($resource_provider_inventory_defaults, ':'), ',') + } else { + $resource_provider_inventory_defaults_real = join(any2array($resource_provider_inventory_defaults), ',') + } + } + neutron_sriov_agent_config { 'sriov_nic/resource_provider_bandwidths': value => $resource_provider_bandwidths_real; 'sriov_nic/resource_provider_hypervisors': value => $resource_provider_hypervisors_real; 'sriov_nic/resource_provider_default_hypervisor': value => $resource_provider_default_hypervisor; + 'sriov_nic/resource_provider_inventory_defaults': value => $resource_provider_inventory_defaults_real; } } diff --git a/releasenotes/notes/resource_provider_inventory_defaults-ede148387da9d8b6.yaml b/releasenotes/notes/resource_provider_inventory_defaults-ede148387da9d8b6.yaml new file mode 100644 index 000000000..4526bb25c --- /dev/null +++ b/releasenotes/notes/resource_provider_inventory_defaults-ede148387da9d8b6.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The new ``resource_provider_inventory_defaults`` parameter has been added + to the ``neutron::agent::ml2::ovs`` class and + the ``neutron::agent::ml2::sriov`` class. diff --git a/spec/classes/neutron_agents_ml2_ovs_spec.rb b/spec/classes/neutron_agents_ml2_ovs_spec.rb index 321987026..36d02fc3e 100644 --- a/spec/classes/neutron_agents_ml2_ovs_spec.rb +++ b/spec/classes/neutron_agents_ml2_ovs_spec.rb @@ -74,6 +74,8 @@ describe 'neutron::agents::ml2::ovs' do with_value('') should contain_neutron_agent_ovs('ovs/resource_provider_default_hypervisor').\ with_value('') + should contain_neutron_agent_ovs('ovs/resource_provider_inventory_defaults').\ + with_value('') should contain_neutron_agent_ovs('agent/explicitly_egress_direct').with_value('') should contain_neutron_agent_ovs('network_log/rate_limit').with_value('') should contain_neutron_agent_ovs('network_log/burst_limit').with_value('') @@ -338,6 +340,7 @@ describe 'neutron::agents::ml2::ovs' do :resource_provider_bandwidths => ['provider-a', 'provider-b'], :resource_provider_hypervisors => ['provider-a:compute-a', 'provider-b:compute-b'], :resource_provider_default_hypervisor => 'compute-c', + :resource_provider_inventory_defaults => ['allocation_ratio:1.0', 'min_unit:1', 'step_size:1'], ) end @@ -348,9 +351,27 @@ describe 'neutron::agents::ml2::ovs' do with_value('provider-a:compute-a,provider-b:compute-b') should contain_neutron_agent_ovs('ovs/resource_provider_default_hypervisor').\ with_value('compute-c') + should contain_neutron_agent_ovs('ovs/resource_provider_inventory_defaults').\ + with_value('allocation_ratio:1.0,min_unit:1,step_size:1') end end + context 'when parameters for resource providers are set by hash' do + before :each do + params.merge!( + :resource_provider_inventory_defaults => { + 'allocation_ratio' => '1.0', + 'min_unit' => '1', + 'step_size' => '1' + }, + ) + end + + it 'configures resource providers' do + should contain_neutron_agent_ovs('ovs/resource_provider_inventory_defaults').\ + with_value('allocation_ratio:1.0,min_unit:1,step_size:1') + end + end end shared_examples 'neutron::agents::ml2::ovs on Debian' do diff --git a/spec/classes/neutron_agents_ml2_sriov_spec.rb b/spec/classes/neutron_agents_ml2_sriov_spec.rb index 043d4ac5b..a24f72de3 100644 --- a/spec/classes/neutron_agents_ml2_sriov_spec.rb +++ b/spec/classes/neutron_agents_ml2_sriov_spec.rb @@ -75,6 +75,8 @@ describe 'neutron::agents::ml2::sriov' do with_value('') should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_default_hypervisor').\ with_value('') + should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_inventory_defaults').\ + with_value('') end context 'when number_of_vfs is empty' do @@ -146,7 +148,8 @@ describe 'neutron::agents::ml2::sriov' do params.merge!( :resource_provider_bandwidths => ['provider-a', 'provider-b'], :resource_provider_hypervisors => ['provider-a:compute-a', 'provider-b:compute-b'], - :resource_provider_default_hypervisor => 'compute-c' + :resource_provider_default_hypervisor => 'compute-c', + :resource_provider_inventory_defaults => ['allocation_ratio:1.0', 'min_unit:1', 'step_size:1'], ) end @@ -157,6 +160,25 @@ describe 'neutron::agents::ml2::sriov' do with_value('provider-a:compute-a,provider-b:compute-b') should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_default_hypervisor').\ with_value('compute-c') + should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_inventory_defaults').\ + with_value('allocation_ratio:1.0,min_unit:1,step_size:1') + end + end + + context 'when parameters for resource providers are set by hash' do + before :each do + params.merge!( + :resource_provider_inventory_defaults => { + 'allocation_ratio' => '1.0', + 'min_unit' => '1', + 'step_size' => '1' + }, + ) + end + + it 'configures resource providers' do + should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_inventory_defaults').\ + with_value('allocation_ratio:1.0,min_unit:1,step_size:1') end end end