From fda32480929edf299cf054b3db95f99f46101b9a Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Thu, 5 Apr 2018 12:10:47 +1000 Subject: [PATCH] Add bridge_mappings option to linuxbridge agent Change-Id: I40bb008d08a76bc72eb2d0d927faa304efca4796 --- manifests/agents/ml2/linuxbridge.pp | 16 ++++++++++++++++ ...xbridge-bridge-mappings-1c8e32e900701938.yaml | 5 +++++ .../neutron_agents_ml2_linuxbridge_spec.rb | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 releasenotes/notes/add-linuxbridge-bridge-mappings-1c8e32e900701938.yaml diff --git a/manifests/agents/ml2/linuxbridge.pp b/manifests/agents/ml2/linuxbridge.pp index 32a6ebc4d..d2f6e1b18 100644 --- a/manifests/agents/ml2/linuxbridge.pp +++ b/manifests/agents/ml2/linuxbridge.pp @@ -54,6 +54,10 @@ # tuples mapping physical network names to agent's node-specific physical # network interfaces. Defaults to empty list. # +# [*bridge_mappings*] +# (optional) List of : +# Defaults to empty list +# # [*firewall_driver*] # (optional) Firewall driver for realizing neutron security group function. # Defaults to 'iptables'. @@ -75,12 +79,14 @@ class neutron::agents::ml2::linuxbridge ( $polling_interval = $::os_service_default, $l2_population = $::os_service_default, $physical_interface_mappings = [], + $bridge_mappings = [], $firewall_driver = 'iptables', $purge_config = false, ) { validate_array($tunnel_types) validate_array($physical_interface_mappings) + validate_array($bridge_mappings) include ::neutron::deps include ::neutron::params @@ -119,6 +125,16 @@ class neutron::agents::ml2::linuxbridge ( } } + if size($bridge_mappings) > 0 { + neutron_agent_linuxbridge { + 'linux_bridge/bridge_mappings': value => join($bridge_mappings, ','); + } + } else { + neutron_agent_linuxbridge { + 'linux_bridge/bridge_mappings': ensure => absent; + } + } + neutron_agent_linuxbridge { 'agent/polling_interval': value => $polling_interval; 'linux_bridge/physical_interface_mappings': value => join($physical_interface_mappings, ','); diff --git a/releasenotes/notes/add-linuxbridge-bridge-mappings-1c8e32e900701938.yaml b/releasenotes/notes/add-linuxbridge-bridge-mappings-1c8e32e900701938.yaml new file mode 100644 index 000000000..e9a0a944d --- /dev/null +++ b/releasenotes/notes/add-linuxbridge-bridge-mappings-1c8e32e900701938.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added a new paramater 'neutron::agents::ml2::linuxbridge::bridge_mappings' for + specifying the bridge_mappings in the linuxbridge agent. diff --git a/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb b/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb index 998350a42..36dc5eeba 100644 --- a/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb +++ b/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb @@ -13,6 +13,7 @@ describe 'neutron::agents::ml2::linuxbridge' do :tunnel_types => [], :local_ip => false, :physical_interface_mappings => [], + :bridge_mappings => [], :firewall_driver => 'iptables', :purge_config => false,} end @@ -41,6 +42,7 @@ describe 'neutron::agents::ml2::linuxbridge' do it 'configures ml2_conf.ini' do is_expected.to contain_neutron_agent_linuxbridge('agent/polling_interval').with_value('') is_expected.to contain_neutron_agent_linuxbridge('linux_bridge/physical_interface_mappings').with_value(default_params[:physical_interface_mappings].join(',')) + is_expected.to contain_neutron_agent_linuxbridge('linux_bridge/bridge_mappings').with_ensure('absent') is_expected.to contain_neutron_agent_linuxbridge('securitygroup/firewall_driver').with_value(default_params[:firewall_driver]) is_expected.to contain_neutron_agent_linuxbridge('agent/tunnel_types').with_ensure('absent') end @@ -139,6 +141,18 @@ describe 'neutron::agents::ml2::linuxbridge' do end end + context 'when providing the bridge_mappings parameter' do + before do + params.merge!(:bridge_mappings => ['physnet0:br0', 'physnet1:br1']) + end + + it 'configures bridge mappings' do + is_expected.to contain_neutron_agent_linuxbridge('linux_bridge/bridge_mappings').with_value( + params[:bridge_mappings].join(',') + ) + end + end + context 'with firewall_driver parameter set to false' do before :each do params.merge!(:firewall_driver => false)