Update enable_l3 param to also accept booleans 92/55592/1
authorDaniel Farrell <dfarrell@redhat.com>
Tue, 2 Feb 2016 20:29:23 +0000 (15:29 -0500)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 19 Apr 2017 19:18:40 +0000 (15:18 -0400)
The enable_l3 param used to simply pass the recieved value
to the template for output, so they had to be the string
'yes' or 'no', as expected by ODL. The template now has
logic for accepting true or 'yes' and writing 'yes' or
false or 'no' and writing 'no.

The rspec-puppet tests, Beaker tests and docs are also updated.

Relevant to #87

Change-Id: I3443f4d3ee6f5a28e4590002636d0333aee954be
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
README.markdown
manifests/init.pp
spec/acceptance/class_spec.rb
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb
templates/custom.properties.erb

index 65289d34a11d1f0b46872e1755de84043c947d31..423f687c9d84dc0c2fb754b518337dc74c1a89a2 100644 (file)
@@ -179,7 +179,7 @@ To enable the ODL OVSDB L3, use the `enable_l3` flag. It's disabled by default.
 
 ```puppet
 class { 'opendaylight':
-  enable_l3 => 'yes',
+  enable_l3 => true,
 }
 ```
 
@@ -287,9 +287,7 @@ Enable or disable ODL OVSDB L3 forwarding.
 
 Default: `'no'`
 
-Valid options: The strings 'yes' or 'no'.
-
-Boolean values are not currently supported, but that feature may be added.
+Valid options: The strings `'yes'` or `'no'` or boolean values `true` and `false`.
 
 The ODL OVSDB L3 config in `/opt/opendaylight/etc/custom.properties` is set to
 the value of the `enable_l3` param.
@@ -298,7 +296,7 @@ A manifest like
 
 ```puppet
 class { 'opendaylight':
-  enable_l3 => 'yes',
+  enable_l3 => true,
 }
 ```
 
index b8308d82cc95686c583b0acf120426e5a4da7f66..b875ed2d62ccd6f23cb34e19d5d7d80604a9e0b4 100644 (file)
@@ -16,7 +16,7 @@
 # [*unitfile_url*]
 #   OpenDaylight .service file to use for tarball installs. Defaults to one used by ODL RPM.
 # [*enable_l3*]
-#   Enable or disable ODL OVSDB ML2 L3 forwarding. Valid options are 'yes' and 'no'.
+#   Enable or disable ODL OVSDB ML2 L3 forwarding. Valid: true, false, 'yes' and 'no'.
 # [*log_levels*]
 #   Custom OpenDaylight logger verbosity configuration (TRACE, DEBUG, INFO, WARN, ERROR).
 #
index 7570176d3f3f1ac89be08816c915aec3664c1c83..3b04ad3367e3cfe1e9787eecc3b765bbe9d09770 100644 (file)
@@ -147,5 +147,21 @@ describe 'opendaylight class' do
       # Call specialized helper fn for ODL OVSDB L3 config validations
       enable_l3_validations(enable_l3: 'yes')
     end
+
+    context 'using false for enable_l3' do
+      # Call specialized helper fn to install OpenDaylight
+      install_odl(enable_l3: false)
+
+      # Call specialized helper fn for ODL OVSDB L3 config validations
+      enable_l3_validations(enable_l3: false)
+    end
+
+    context 'using true for enable_l3' do
+      # Call specialized helper fn to install OpenDaylight
+      install_odl(enable_l3: true)
+
+      # Call specialized helper fn for ODL OVSDB L3 config validations
+      enable_l3_validations(enable_l3: true)
+    end
   end
 end
index f6f76fc5b5836d1246df1164bd91fbff2e720404..21a4ab738c345debe579ccffe712b5c86a16c0ff 100644 (file)
@@ -496,6 +496,46 @@ describe 'opendaylight' do
       # Note that this function is defined in spec_helper
       enable_l3_tests(enable_l3: 'yes')
     end
+
+    context 'using false for enable_l3' do
+      let(:facts) {{
+        :osfamily => osfamily,
+        :operatingsystem => operatingsystem,
+        :operatingsystemmajrelease => operatingsystemmajrelease,
+      }}
+
+      let(:params) {{
+        :enable_l3 => false ,
+      }}
+
+      # Run shared tests applicable to all supported OSs
+      # Note that this function is defined in spec_helper
+      generic_tests
+
+      # Run test that specialize in checking ODL OVSDB L3 config
+      # Note that this function is defined in spec_helper
+      enable_l3_tests(enable_l3: false)
+    end
+
+    context 'using true for enable_l3' do
+      let(:facts) {{
+        :osfamily => osfamily,
+        :operatingsystem => operatingsystem,
+        :operatingsystemmajrelease => operatingsystemmajrelease,
+      }}
+
+      let(:params) {{
+        :enable_l3 => true,
+      }}
+
+      # Run shared tests applicable to all supported OSs
+      # Note that this function is defined in spec_helper
+      generic_tests
+
+      # Run test that specialize in checking ODL OVSDB L3 config
+      # Note that this function is defined in spec_helper
+      enable_l3_tests(enable_l3: true)
+    end
   end
 
   # All install method tests
index 0400778835ae01b136841c147295879867ff12bb..99fd958cadcad771bd657866b93d841edcbac90a 100644 (file)
@@ -195,16 +195,29 @@ def enable_l3_tests(options = {})
   # TODO: Remove this possible source of bugs^^
   enable_l3 = options.fetch(:enable_l3, 'no')
 
-  # Confirm ODL OVSDB L3 config
-  it {
-    should contain_file('custom.properties').with(
-      'ensure'      => 'file',
-      'path'        => '/opt/opendaylight/etc/custom.properties',
-      'owner'   => 'odl',
-      'group'   => 'odl',
-      'content'     => /ovsdb.l3.fwd.enabled=#{enable_l3}/
-    )
-  }
+  if [true, 'yes'].include? enable_l3
+    # Confirm ODL OVSDB L3 is enabled
+    it {
+      should contain_file('custom.properties').with(
+        'ensure'      => 'file',
+        'path'        => '/opt/opendaylight/etc/custom.properties',
+        'owner'   => 'odl',
+        'group'   => 'odl',
+        'content'     => /^ovsdb.l3.fwd.enabled=yes/
+      )
+    }
+  elsif [false, 'no'].include? enable_l3
+    # Confirm ODL OVSDB L3 is disabled
+    it {
+      should contain_file('custom.properties').with(
+        'ensure'      => 'file',
+        'path'        => '/opt/opendaylight/etc/custom.properties',
+        'owner'   => 'odl',
+        'group'   => 'odl',
+        'content'     => /^ovsdb.l3.fwd.enabled=no/
+      )
+    }
+  end
 end
 
 def tarball_install_tests(options = {})
index beb7364abacf959d813e01bde4291b65186373db..4e21c4d5722d0d4dac82dedb21d0340db71e990e 100644 (file)
@@ -282,11 +282,22 @@ def enable_l3_validations(options = {})
   # TODO: Remove this possible source of bugs^^
   enable_l3 = options.fetch(:enable_l3, 'no')
 
-  describe file('/opt/opendaylight/etc/custom.properties') do
-    it { should be_file }
-    it { should be_owned_by 'odl' }
-    it { should be_grouped_into 'odl' }
-    its(:content) { should match /ovsdb.l3.fwd.enabled=#{enable_l3}/ }
+  if [true, 'yes'].include? enable_l3
+    # Confirm ODL OVSDB L3 is enabled
+    describe file('/opt/opendaylight/etc/custom.properties') do
+      it { should be_file }
+      it { should be_owned_by 'odl' }
+      it { should be_grouped_into 'odl' }
+      its(:content) { should match /^ovsdb.l3.fwd.enabled=yes/ }
+    end
+  elsif [false, 'no'].include? enable_l3
+    # Confirm ODL OVSDB L3 is disabled
+    describe file('/opt/opendaylight/etc/custom.properties') do
+      it { should be_file }
+      it { should be_owned_by 'odl' }
+      it { should be_grouped_into 'odl' }
+      its(:content) { should match /^ovsdb.l3.fwd.enabled=no/ }
+    end
   end
 end
 
index 0dbd9e945c7b07051fb14e2a20ae34bdba7c84f0..1fe31dc69fe6f8d052a29d5e2d4063fa4048157d 100644 (file)
@@ -83,7 +83,13 @@ ovsdb.listenPort=6640
 
 # ovsdb can be configured with ml2 to perform l3 forwarding. The config below enables that functionality, which is
 # disabled by default.
-ovsdb.l3.fwd.enabled=<%= scope.lookupvar('opendaylight::enable_l3') %>
+<% if [true, 'yes'].include? scope.lookupvar('opendaylight::enable_l3') -%>
+ovsdb.l3.fwd.enabled=yes
+<% elsif [false, 'no'].include? scope.lookupvar('opendaylight::enable_l3') -%>
+ovsdb.l3.fwd.enabled=no
+<% else -%>
+  <%- fail("Unexpected enable_l3 value: #{scope.lookupvar('opendaylight::enable_l3')}") -%>
+<% end -%>
 
 # ovsdb can be configured with ml2 to perform l3 forwarding. When used in that scenario, the mac address of the default
 # gateway --on the external subnet-- is expected to be resolved from its inet address. The config below overrides that