Merge "Fix the wrong section used to configure standalone network plugin" into stable/train

This commit is contained in:
Zuul 2022-03-30 11:10:01 +00:00 committed by Gerrit Code Review
commit 75e38bb890
2 changed files with 55 additions and 38 deletions

View File

@ -16,6 +16,7 @@
# It will be assigned to share-network and share drivers will be
# able to use this for network interfaces within provisioned
# share servers. Optional. Example: 1001
# Defaults to $::os_service_default
#
# [*standalone_network_plugin_allowed_ip_ranges*]
# (optional) Can be IP address, range of IP addresses or list of addresses
@ -24,12 +25,15 @@
# addresses from network can be used. Optional.
# Examples: 10.0.0.10 or 10.0.0.10-10.0.0.20 or
# 10.0.0.10-10.0.0.20,10.0.0.30-10.0.0.40,10.0.0.50
# Defaults to $::os_service_default
#
# [*network_plugin_ipv4_enabled*]
# (optional) Whether to support Ipv4 network resource
# Defaults to $::os_service_default
#
# [*network_plugin_ipv6_enabled*]
# (optional) whether to support IPv6 network resource
# Defaults to $::os_service_default
#
# DEPRECATED PARAMETERS
#
@ -41,12 +45,12 @@
define manila::network::standalone (
$standalone_network_plugin_gateway,
$standalone_network_plugin_mask,
$standalone_network_plugin_segmentation_id = undef,
$standalone_network_plugin_allowed_ip_ranges = undef,
$network_plugin_ipv4_enabled = $::os_service_default,
$network_plugin_ipv6_enabled = $::os_service_default,
$standalone_network_plugin_segmentation_id = $::os_service_default,
$standalone_network_plugin_allowed_ip_ranges = $::os_service_default,
$network_plugin_ipv4_enabled = $::os_service_default,
$network_plugin_ipv6_enabled = $::os_service_default,
# DEPRECATED PARAMETERS
$standalone_network_plugin_ip_version = undef,
$standalone_network_plugin_ip_version = undef,
) {
if $standalone_network_plugin_ip_version {
@ -56,13 +60,12 @@ define manila::network::standalone (
$standalone_plugin_name = 'manila.network.standalone_network_plugin.StandaloneNetworkPlugin'
manila_config {
"${name}/network_api_class": value => $standalone_plugin_name;
"${name}/standalone_network_plugin_gateway": value => $standalone_network_plugin_gateway;
"${name}/standalone_network_plugin_mask": value => $standalone_network_plugin_mask;
"${name}/standalone_network_plugin_segmentation_id": value => $standalone_network_plugin_segmentation_id;
"${name}/standalone_network_plugin_allowed_ip_ranges": value => $standalone_network_plugin_allowed_ip_ranges;
'DEFAULT/network_plugin_ipv4_enabled': value => $network_plugin_ipv4_enabled;
'DEFAULT/network_plugin_ipv6_enabled': value => $network_plugin_ipv6_enabled;
"${name}/network_api_class": value => $standalone_plugin_name;
"${name}/standalone_network_plugin_gateway": value => $standalone_network_plugin_gateway;
"${name}/standalone_network_plugin_mask": value => $standalone_network_plugin_mask;
"${name}/standalone_network_plugin_segmentation_id": value => $standalone_network_plugin_segmentation_id;
"${name}/standalone_network_plugin_allowed_ip_ranges": value => $standalone_network_plugin_allowed_ip_ranges;
"${name}/network_plugin_ipv4_enabled": value => $network_plugin_ipv4_enabled;
"${name}/network_plugin_ipv6_enabled": value => $network_plugin_ipv6_enabled;
}
}

View File

@ -5,38 +5,52 @@ describe 'manila::network::standalone' do
let :params do
{
:standalone_network_plugin_gateway => '192.168.1.1',
:standalone_network_plugin_mask => '255.255.255.0',
:standalone_network_plugin_segmentation_id => '1001',
:standalone_network_plugin_allowed_ip_ranges => '10.0.0.10-10.0.0.20',
:standalone_network_plugin_gateway => '192.168.1.1',
:standalone_network_plugin_mask => '255.255.255.0',
}
end
shared_examples_for 'standalone network plugin' do
it 'configures standalone network plugin' do
is_expected.to contain_manila_config("standalone/network_api_class").with_value(
'manila.network.standalone_network_plugin.StandaloneNetworkPlugin')
params.each_pair do |config,value|
is_expected.to contain_manila_config("standalone/#{config}").with_value( value )
end
end
end
shared_examples 'manila::network::standalone' do
context 'with default parameters' do
before do
params = {}
end
context 'with required parameters' do
it 'configures standalone network plugin' do
is_expected.to contain_manila_config("standalone/network_api_class").with_value(
'manila.network.standalone_network_plugin.StandaloneNetworkPlugin')
it_configures 'standalone network plugin'
is_expected.to contain_manila_config('standalone/standalone_network_plugin_gateway')\
.with_value('192.168.1.1')
is_expected.to contain_manila_config('standalone/standalone_network_plugin_mask')\
.with_value('255.255.255.0')
is_expected.to contain_manila_config('standalone/standalone_network_plugin_segmentation_id')\
.with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('standalone/standalone_network_plugin_allowed_ip_ranges')\
.with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('standalone/network_plugin_ipv4_enabled')\
.with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('standalone/network_plugin_ipv6_enabled')\
.with_value('<SERVICE DEFAULT>')
end
end
context 'with provided parameters' do
it_configures 'standalone network plugin'
context 'with custom parameters' do
before do
params.merge!({
:standalone_network_plugin_segmentation_id => '1001',
:standalone_network_plugin_allowed_ip_ranges => '10.0.0.10-10.0.0.20',
:network_plugin_ipv4_enabled => true,
:network_plugin_ipv6_enabled => false,
})
end
it 'configures standalone network plugin' do
is_expected.to contain_manila_config('standalone/standalone_network_plugin_segmentation_id')\
.with_value('1001')
is_expected.to contain_manila_config('standalone/standalone_network_plugin_allowed_ip_ranges')\
.with_value('10.0.0.10-10.0.0.20')
is_expected.to contain_manila_config('standalone/network_plugin_ipv4_enabled')\
.with_value(true)
is_expected.to contain_manila_config('standalone/network_plugin_ipv6_enabled')\
.with_value(false)
end
end
end