]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Firewall wasn't acknowledging new properties, only ones that were created at
authorKen Barber <ken@bob.sh>
Wed, 15 Jun 2011 15:14:10 +0000 (17:14 +0200)
committerKen Barber <ken@bob.sh>
Wed, 15 Jun 2011 15:14:10 +0000 (17:14 +0200)
resource creation time. This patch fixes that by analyzing the resource_map
hash.

The proto property needs to be defaulted to 'all' when it doesn't exist as well
to stop the provider from trying to change it each time.

README.markdown [moved from README.md with 100% similarity]
lib/puppet/provider/firewall.rb
lib/puppet/provider/firewall/iptables.rb
lib/puppet/type/firewall.rb

similarity index 100%
rename from README.md
rename to README.markdown
index d946e6b19e6110f264ab99f443172e1a6432c4d3..0c9e1ff115734f967ea1da6135ba229ebfff1f8d 100644 (file)
@@ -35,13 +35,25 @@ class Puppet::Provider::Firewall < Puppet::Provider
   # Executed if method is missing. In this case we are going to catch 
   # unqualified property methods for dynamic property setting and getting.
   def method_missing(meth, *args, &block)
-    if @property_hash.keys.include?(meth) then
-      return @property_hash[meth.to_sym]
-    elsif @property_hash.keys.include?(meth.to_s.chomp("=").to_sym) then
+    dynamic_methods = @@resource_map.keys
+    dynamic_methods << :chain
+    dynamic_methods << :table
+
+    if dynamic_methods.include?(meth.to_sym) then
+      if @property_hash[meth.to_sym] then
+        return @property_hash[meth.to_sym]
+      else
+        return nil
+      end
+    elsif dynamic_methods.include?(meth.to_s.chomp("=").to_sym) then
+      debug("Args: #{args}")
       @property_hash[:needs_change] = true
       return true
     end
 
+    debug("Dynamic methods: #{dynamic_methods.join(' ')}")
+    debug("Method missing: #{meth}. Calling super.")
+
     super
   end
 end
index 9370012c0c7df77efe38ab3b86bde763cee967fd..7e87e1484c34bd7c7dcf13f41d68ea036b184f61 100644 (file)
@@ -113,6 +113,11 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
     hash[:provider] = self.name.to_s
     hash[:table] = table
     hash[:ensure] = :present
+
+    # Munge some vars here ...
+    # proto should equal 'all' if undefined
+    hash[:proto] = "all" if !hash.include?(:proto)
+
     hash
   end
 
index 2defbbcd0f211883c8c049cf4d4e9a45f7467512..c5487f3dea00c7b5c92be7fc94e8b93d96d11a25 100644 (file)
@@ -1,22 +1,4 @@
-# Puppet Firewall Module
-#
-# Copyright (C) 2011 Bob.sh Limited
-# Copyright (C) 2008 Camptocamp Association
-# Copyright (C) 2007 Dmitri Priimak
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
+# Puppet Firewall type
 require 'puppet/util/firewall'
 require 'puppet/property/ordered_list'