Fixes detecting security group mode based on OS version 41/55641/1
authorTim Rozet <tdrozet@gmail.com>
Tue, 20 Dec 2016 20:21:30 +0000 (15:21 -0500)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 19 Apr 2017 19:18:40 +0000 (15:18 -0400)
Issue with using the defined() function with variables.  Variables need
to be preceeded by '$' and in single quotes.  Also fixes spec tests
which were broken.

closes #122

Change-Id: I86fcb54c0cee59a180406871a44d26cf8fcc8c9e
Signed-off-by: Tim Rozet <tdrozet@gmail.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
manifests/config.pp
manifests/init.pp
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb

index 8208c293743be5ca73e49503457d4077e7105e13..ed6d679108ca2f8d01e952a503b2007b87358b5a 100644 (file)
@@ -82,13 +82,9 @@ class opendaylight::config {
   # Requires at least CentOS 7.3 for RHEL/CentOS systems
   if ('odl-netvirt-openstack' in $opendaylight::features) {
     if $opendaylight::security_group_mode == 'stateful' {
-      if defined('$opendaylight::stateful_unsupported') {
-        if $opendaylight::stateful_unsupported {
+      if defined('$opendaylight::stateful_unsupported') and $opendaylight::stateful_unsupported {
           warning("Stateful is unsupported in ${::operatingsystemrelease} setting to 'learn'")
           $sg_mode = 'learn'
-        } else {
-            $sg_mode = 'learn'
-        }
       } else {
         $sg_mode = 'stateful'
       }
index 7aaa015394c95e7065eecb4fed8e8cf40695f79b..87703941f8cffdb20e33b92f06a11d673e6b5695 100644 (file)
@@ -72,7 +72,7 @@ class opendaylight (
       if $::operatingsystemmajrelease != '7' {
         # RHEL/CentOS versions < 7 not supported as they lack systemd
         fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemmajrelease}")
-      } elsif defined('::operatingsystemrelease') {
+      } elsif defined('$::operatingsystemrelease') {
           if (versioncmp($::operatingsystemrelease, '7.3') < 0) {
             # Versions < 7.3 do not support stateful security groups
             $stateful_unsupported = true
index 3c21461ecdb126a5cb5921825e140d3464523a51..8cf4d843cf175e59a0e0bcfcec9e6f1ee1201be0 100644 (file)
@@ -730,7 +730,7 @@ describe 'opendaylight' do
 
       # Run test that specialize in checking security groups
       # Note that this function is defined in spec_helper
-      enable_sg_tests(security_group_mode: 'stateful', osrelease: '7.3')
+      enable_sg_tests('stateful', '7.3')
     end
 
     context 'using unsupported stateful' do
@@ -752,7 +752,7 @@ describe 'opendaylight' do
 
       # Run test that specialize in checking security groups
       # Note that this function is defined in spec_helper
-      enable_sg_tests(security_group_mode: 'stateful', osrelease: '7.3')
+      enable_sg_tests('stateful', '7.2.1511')
     end
 
     context 'using transparent with unsupported stateful' do
@@ -774,7 +774,7 @@ describe 'opendaylight' do
 
       # Run test that specialize in checking security groups
       # Note that this function is defined in spec_helper
-      enable_sg_tests(security_group_mode: 'transparent', osrelease: '7.2.1511')
+      enable_sg_tests('transparent', '7.2.1511')
     end
   end
 end
index 19437bc378f7b62940d15fc6bb78322687ecc720..51260a3b05a32b94011d29178df665fe0e229bd4 100644 (file)
@@ -411,15 +411,13 @@ def unsupported_os_tests(options = {})
   it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
 end
 
-# Shared tests that specialize in testing enabling L3 via ODL OVSDB
-def enable_sg_tests(options = {})
+# Shared tests that specialize in testing security group mode
+def enable_sg_tests(sg_mode='stateful', os_release)
   # Extract params
   # NB: This default value should be the same as one in opendaylight::params
   # TODO: Remove this possible source of bugs^^
-  sg_mode = options.fetch(:security_group_mode, 'stateful')
-  os_release = options.fetch(:osrelease)
 
-  if !os_release.include? '7.3' and ['stateful'].include? sg_mode
+  if os_release != '7.3' and sg_mode == 'stateful'
     # Confirm sg_mode becomes learn
     it {
       should contain_file('netvirt-aclservice-config.xml').with(