Add support for the resource_provider_inventory_defaults parameters

This change introduces support of the following two parameters.

[ovs] resource_provider_inventory_defaults
[sriov_nic] resource_provider_inventory_defaults

Change-Id: I141405a16a85e262b0c3427558fc59a48a5a6190
This commit is contained in:
Takashi Kajinami 2022-02-04 15:07:30 +09:00
parent e7d5127531
commit a6cc96f098
5 changed files with 84 additions and 1 deletions

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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.

View File

@ -74,6 +74,8 @@ describe 'neutron::agents::ml2::ovs' do
with_value('<SERVICE DEFAULT>')
should contain_neutron_agent_ovs('ovs/resource_provider_default_hypervisor').\
with_value('<SERVICE DEFAULT>')
should contain_neutron_agent_ovs('ovs/resource_provider_inventory_defaults').\
with_value('<SERVICE DEFAULT>')
should contain_neutron_agent_ovs('agent/explicitly_egress_direct').with_value('<SERVICE DEFAULT>')
should contain_neutron_agent_ovs('network_log/rate_limit').with_value('<SERVICE DEFAULT>')
should contain_neutron_agent_ovs('network_log/burst_limit').with_value('<SERVICE DEFAULT>')
@ -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

View File

@ -75,6 +75,8 @@ describe 'neutron::agents::ml2::sriov' do
with_value('<SERVICE DEFAULT>')
should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_default_hypervisor').\
with_value('<SERVICE DEFAULT>')
should contain_neutron_sriov_agent_config('sriov_nic/resource_provider_inventory_defaults').\
with_value('<SERVICE DEFAULT>')
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