From 094c2ae8de7623a32682a25d723121275fd39db5 Mon Sep 17 00:00:00 2001 From: Daneyon Hansen Date: Mon, 20 May 2013 17:50:13 -0700 Subject: [PATCH] only set network_vlan_ranges for vlan network types This commit updates the quantum module to ensure that vlan specific configuration is only applied when the tenant_network_type is vlan or flat. it also adds tests that were previously missing from quantum_plugins_ovs_spec.rb. Change-Id: I97cffff55ad6ff6cb683efc282e0db46d4687c1a --- manifests/plugins/ovs.pp | 12 ++-- spec/classes/quantum_plugins_ovs_spec.rb | 72 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/manifests/plugins/ovs.pp b/manifests/plugins/ovs.pp index 153980017..1329fe2f0 100644 --- a/manifests/plugins/ovs.pp +++ b/manifests/plugins/ovs.pp @@ -5,13 +5,10 @@ class quantum::plugins::ovs ( $package_ensure = 'present', - $sql_connection = 'sqlite:////var/lib/quantum/ovs.sqlite', $sql_max_retries = 10, $reconnect_interval = 2, - $tenant_network_type = 'vlan', - # NB: don't need tunnel ID range when using VLANs, # *but* you do need the network vlan range regardless of type, # because the list of networks there is still important @@ -54,7 +51,6 @@ class quantum::plugins::ovs ( 'DATABASE/sql_connection': value => $sql_connection; 'DATABASE/sql_max_retries': value => $sql_max_retries; 'DATABASE/reconnect_interval': value => $reconnect_interval; - 'OVS/network_vlan_ranges': value => $network_vlan_ranges; 'OVS/tenant_network_type': value => $tenant_network_type; } @@ -68,6 +64,14 @@ class quantum::plugins::ovs ( } } + if ($tenant_network_type == 'vlan') or ($tenant_network_type == 'flat') { + quantum_plugin_ovs { + 'OVS/network_vlan_ranges': value => $network_vlan_ranges; + } + } else { + quantum_plugin_ovs { 'OVS/network_vlan_ranges': ensure => absent } + } + if $::osfamily == 'Redhat' { file {'/etc/quantum/plugin.ini': ensure => link, diff --git a/spec/classes/quantum_plugins_ovs_spec.rb b/spec/classes/quantum_plugins_ovs_spec.rb index e999d4539..b43e380f1 100644 --- a/spec/classes/quantum_plugins_ovs_spec.rb +++ b/spec/classes/quantum_plugins_ovs_spec.rb @@ -6,13 +6,73 @@ describe 'quantum::plugins::ovs' do "class { 'quantum': rabbit_password => 'passw0rd' }" end + let :default_params do + { + :package_ensure => 'present', + :sql_connection => 'sqlite:////var/lib/quantum/ovs.sqlite', + :sql_max_retries => 10, + :reconnect_interval => 2, + :tenant_network_type => 'vlan', + :network_vlan_ranges => 'physnet1:1000:2000', + :tunnel_id_ranges => '1:1000' + } + end + + let :params do + {} + end + + shared_examples_for 'quantum ovs plugin' do + + let :p do + default_params.merge(params) + end + + it 'should perform default configuration of' do + should contain_quantum_plugin_ovs('OVS/network_vlan_ranges').\ + with_value(p[:network_vlan_ranges]) + should contain_quantum_plugin_ovs('DATABASE/sql_connection').with_value(p[:sql_connection]) + should contain_quantum_plugin_ovs('DATABASE/sql_max_retries').with_value(p[:sql_max_retries]) + should contain_quantum_plugin_ovs('DATABASE/reconnect_interval').with_value(p[:reconnect_interval]) + should contain_quantum_plugin_ovs('OVS/tenant_network_type').with_value(p[:tenant_network_type]) + should_not contain_quantum_plugin_ovs('OVS/tunnel_id_ranges') + should contain_quantum_plugin_ovs('OVS/network_vlan_ranges').with_value(p[:network_vlan_ranges]) + should contain_package('quantum-plugin-ovs').with( + :name => platform_params[:ovs_server_package], + :ensure => p[:package_ensure] + ) + end + + context 'with gre tunneling' do + let :params do + { :tenant_network_type => 'gre' } + end + + it 'should perform gre network configuration' do + should contain_quantum_plugin_ovs('OVS/network_vlan_ranges').with_ensure('absent') + should contain_quantum_plugin_ovs('OVS/tenant_network_type').with_value(p[:tenant_network_type]) + should contain_quantum_plugin_ovs('OVS/tunnel_id_ranges').with_value(p[:tunnel_id_ranges]) + end + end + context 'with a flat network' do + let :params do + { :tenant_network_type => 'flat' } + end + it { should contain_quantum_plugin_ovs('OVS/network_vlan_ranges').with_value(p[:network_vlan_ranges]) } + end + end context 'on Debian platforms' do let :facts do { :osfamily => 'Debian' } end + let :platform_params do + { :ovs_server_package => 'quantum-plugin-openvswitch' } + end + it { should contain_class('quantum::plugins::ovs') } + it_configures 'quantum ovs plugin' end context 'on RedHat platforms' do @@ -20,6 +80,18 @@ describe 'quantum::plugins::ovs' do { :osfamily => 'RedHat' } end + let :platform_params do + { :ovs_server_package => 'openstack-quantum-openvswitch' } + end + it { should contain_class('quantum::plugins::ovs') } + it 'should perform redhat specific configuration' do + should contain_file('/etc/quantum/plugin.ini').with( + :ensure => 'link', + :target => '/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini', + :require => 'Package[quantum-plugin-ovs]' + ) + end + it_configures 'quantum ovs plugin' end end