diff --git a/manifests/network/neutron_network.pp b/manifests/network/neutron_network.pp new file mode 100644 index 00000000..be140049 --- /dev/null +++ b/manifests/network/neutron_network.pp @@ -0,0 +1,33 @@ +# == define: manila::network::neutron_network +# +# Setup and configure the Neutron network plugin +# +# === Parameters +# +# [*neutron_physical_net_name*] +# (required) The name of the physical network to determine which net segment +# is used. +# +# [*network_plugin_ipv4_enabled*] +# (optional) Whether to support Ipv4 network resource. +# Defaults to $facts['os_service_default']. +# +# [*network_plugin_ipv6_enabled*] +# (optional) whether to support IPv6 network resource. +# Defaults to $facts['os_service_default']. +# +define manila::network::neutron_network ( + $neutron_physical_net_name, + $network_plugin_ipv4_enabled = $facts['os_service_default'], + $network_plugin_ipv6_enabled = $facts['os_service_default'], +) { + + $neutron_single_plugin_name = 'manila.network.neutron.neutron_network_plugin.NeutronNetworkPlugin' + + manila_config { + "${name}/network_api_class": value => $neutron_single_plugin_name; + "${name}/neutron_physical_net_name": value => $neutron_physical_net_name; + "${name}/network_plugin_ipv4_enabled": value => $network_plugin_ipv4_enabled; + "${name}/network_plugin_ipv6_enabled": value => $network_plugin_ipv6_enabled; + } +} diff --git a/manifests/network/neutron_single_network.pp b/manifests/network/neutron_single_network.pp index 2516f34e..9d6e093f 100644 --- a/manifests/network/neutron_single_network.pp +++ b/manifests/network/neutron_single_network.pp @@ -5,23 +5,21 @@ # === Parameters # # [*neutron_net_id*] -# (required) Default Neutron network that will be used for share server -# creation. This opt is used only with -# class 'NeutronSingleNetworkPlugin'. +# (required) Default Neutron network that will be used for share server +# creation. # # [*neutron_subnet_id*] -# (required) Default Neutron subnet that will be used for share server -# creation. Should be assigned to network defined in opt -# 'neutron_net_id'. This opt is used only with -# class 'NeutronSingleNetworkPlugin'. +# (required) Default Neutron subnet that will be used for share server +# creation. Should be assigned to network defined in opt +# 'neutron_net_id'. # # [*network_plugin_ipv4_enabled*] -# (optional) Whether to support Ipv4 network resource. -# Defaults to $facts['os_service_default']. +# (optional) Whether to support Ipv4 network resource. +# Defaults to $facts['os_service_default']. # # [*network_plugin_ipv6_enabled*] -# (optional) whether to support IPv6 network resource. -# Defaults to $facts['os_service_default']. +# (optional) whether to support IPv6 network resource. +# Defaults to $facts['os_service_default']. # define manila::network::neutron_single_network ( $neutron_net_id, diff --git a/releasenotes/notes/neutron-network-d3ebedd26c3877a4.yaml b/releasenotes/notes/neutron-network-d3ebedd26c3877a4.yaml new file mode 100644 index 00000000..5e63c774 --- /dev/null +++ b/releasenotes/notes/neutron-network-d3ebedd26c3877a4.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``manila::network::neutron_network`` defined resource type has been + added. It supports managing the options of neutron network plugin. diff --git a/spec/defines/manila_network_neutron_network_spec.rb b/spec/defines/manila_network_neutron_network_spec.rb new file mode 100644 index 00000000..31e73092 --- /dev/null +++ b/spec/defines/manila_network_neutron_network_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'manila::network::neutron_network' do + let(:title) do + 'neutronnet' + end + + let :params do + { + :neutron_physical_net_name => 'br-ex', + } + end + + shared_examples 'manila::network::neutron_network' do + context 'with required parameters' do + it 'configures neutron single network plugin' do + is_expected.to contain_manila_config("neutronnet/network_api_class").with_value( + 'manila.network.neutron.neutron_network_plugin.NeutronNetworkPlugin') + + is_expected.to contain_manila_config('neutronnet/neutron_physical_net_name')\ + .with_value('br-ex') + is_expected.to contain_manila_config('neutronnet/network_plugin_ipv4_enabled')\ + .with_value('') + is_expected.to contain_manila_config('neutronnet/network_plugin_ipv6_enabled')\ + .with_value('') + end + end + + context 'with custom parameters' do + before do + params.merge!({ + :network_plugin_ipv4_enabled => true, + :network_plugin_ipv6_enabled => false, + }) + end + it 'configures neutron single network plugin' do + is_expected.to contain_manila_config("neutronnet/network_api_class").with_value( + 'manila.network.neutron.neutron_network_plugin.NeutronNetworkPlugin') + + is_expected.to contain_manila_config('neutronnet/neutron_physical_net_name')\ + .with_value('br-ex') + is_expected.to contain_manila_config('neutronnet/network_plugin_ipv4_enabled')\ + .with_value(true) + is_expected.to contain_manila_config('neutronnet/network_plugin_ipv6_enabled')\ + .with_value(false) + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_behaves_like 'manila::network::neutron_network' + end + end +end diff --git a/spec/defines/manila_network_neutron_single_network_spec.rb b/spec/defines/manila_network_neutron_single_network_spec.rb index 83071fba..c54155af 100644 --- a/spec/defines/manila_network_neutron_single_network_spec.rb +++ b/spec/defines/manila_network_neutron_single_network_spec.rb @@ -1,7 +1,9 @@ require 'spec_helper' describe 'manila::network::neutron_single_network' do - let("title") {'neutronsingle'} + let(:title) do + 'neutronsingle' + end let :params do {