From c1b2cf360787a8171632eb0baa19b09d44983822 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Tue, 8 Sep 2015 15:29:47 -0500 Subject: [PATCH] Make vswitch optional for ovs agent configuration For some complex configurations it may not be ideal to try and leverage the vswitch::ovs class to manage the software and ovs bridges and ports. This change adds a flag to the ml2 ovs agent configuration to allow the vswitch configuration to be skipped as part of the agent installation and configuration. If new parameter manage_ovs is set to false, it will skip the inclusion of vswitch::ovs and attempts to configure the ovs bridges/ports based on the bridge_mappings paramters. This allows a user to manage the openvswitch installation and configuration elsewhere. Change-Id: Iee0edf08d9a96580bec2b80274102c1da1a70ed0 --- manifests/agents/ml2/ovs.pp | 25 ++++++++++++---- spec/classes/neutron_agents_ml2_ovs_spec.rb | 33 ++++++++++++++++++++- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/manifests/agents/ml2/ovs.pp b/manifests/agents/ml2/ovs.pp index 73550ac79..cc9a454e3 100644 --- a/manifests/agents/ml2/ovs.pp +++ b/manifests/agents/ml2/ovs.pp @@ -97,6 +97,14 @@ # flow tables resetting # Defaults to false # +# [*manage_vswitch*] +# (optional) This boolean is used to indicate if this class should manage the +# vswitch software installation and the ovs bridges/ports from the +# $bridge_mappings parameter. If manage_vswitch is set to true, then we will +# require the vswitch::ovs and configure the ovs bridges/ports using the +# mappings provided as part of the $bridge_mappings parameters. +# Defaults to true +# class neutron::agents::ml2::ovs ( $package_ensure = 'present', $enabled = true, @@ -115,10 +123,13 @@ class neutron::agents::ml2::ovs ( $firewall_driver = 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver', $enable_distributed_routing = false, $drop_flows_on_start = false, + $manage_vswitch = true, ) { include ::neutron::params - require vswitch::ovs + if $manage_vswitch { + require vswitch::ovs + } if $enable_tunneling and ! $local_ip { fail('Local ip for ovs agent must be set when tunneling is enabled') @@ -149,11 +160,13 @@ class neutron::agents::ml2::ovs ( neutron_agent_ovs { 'ovs/bridge_mappings': value => $br_map_str; } - neutron::plugins::ovs::bridge{ $bridge_mappings: - before => Service['neutron-ovs-agent-service'], - } - neutron::plugins::ovs::port{ $bridge_uplinks: - before => Service['neutron-ovs-agent-service'], + if ($manage_vswitch) { + neutron::plugins::ovs::bridge{ $bridge_mappings: + before => Service['neutron-ovs-agent-service'], + } + neutron::plugins::ovs::port{ $bridge_uplinks: + before => Service['neutron-ovs-agent-service'], + } } } diff --git a/spec/classes/neutron_agents_ml2_ovs_spec.rb b/spec/classes/neutron_agents_ml2_ovs_spec.rb index dc62d3cce..0f32a63a6 100644 --- a/spec/classes/neutron_agents_ml2_ovs_spec.rb +++ b/spec/classes/neutron_agents_ml2_ovs_spec.rb @@ -20,7 +20,8 @@ describe 'neutron::agents::ml2::ovs' do :arp_responder => false, :drop_flows_on_start => false, :enable_distributed_routing => false, - :firewall_driver => 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver' } + :firewall_driver => 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver', + :manage_vswitch => true } end let :default_facts do @@ -116,6 +117,10 @@ describe 'neutron::agents::ml2::ovs' do params.merge!(:bridge_uplinks => ['br-ex:eth2'],:bridge_mappings => ['default:br-ex']) end + it 'should require vswitch::ovs' do + is_expected.to contain_class('vswitch::ovs') + end + it 'configures bridge mappings' do is_expected.to contain_neutron_agent_ovs('ovs/bridge_mappings') end @@ -133,6 +138,32 @@ describe 'neutron::agents::ml2::ovs' do end end + context 'when supplying bridge mappings for provider networks with manage vswitch set to false' do + before :each do + params.merge!(:bridge_uplinks => ['br-ex:eth2'],:bridge_mappings => ['default:br-ex'], :manage_vswitch => false) + end + + it 'should not require vswitch::ovs' do + is_expected.not_to contain_class('vswitch::ovs') + end + + it 'configures bridge mappings' do + is_expected.to contain_neutron_agent_ovs('ovs/bridge_mappings') + end + + it 'should not configure bridge mappings' do + is_expected.not_to contain_neutron__plugins__ovs__bridge(params[:bridge_mappings].join(',')).with( + :before => 'Service[neutron-ovs-agent-service]' + ) + end + + it 'should not configure bridge uplinks' do + is_expected.not_to contain_neutron__plugins__ovs__port(params[:bridge_uplinks].join(',')).with( + :before => 'Service[neutron-ovs-agent-service]' + ) + end + end + context 'when enabling tunneling' do context 'without local ip address' do before :each do