From 34b7c997d325abca72a98043052832ab6513ee14 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 15 Jun 2011 17:14:10 +0200 Subject: [PATCH] Firewall wasn't acknowledging new properties, only ones that were created at 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.md => README.markdown | 0 lib/puppet/provider/firewall.rb | 18 +++++++++++++++--- lib/puppet/provider/firewall/iptables.rb | 5 +++++ lib/puppet/type/firewall.rb | 20 +------------------- 4 files changed, 21 insertions(+), 22 deletions(-) rename README.md => README.markdown (100%) diff --git a/README.md b/README.markdown similarity index 100% rename from README.md rename to README.markdown diff --git a/lib/puppet/provider/firewall.rb b/lib/puppet/provider/firewall.rb index d946e6b..0c9e1ff 100644 --- a/lib/puppet/provider/firewall.rb +++ b/lib/puppet/provider/firewall.rb @@ -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 diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb index 9370012..7e87e14 100644 --- a/lib/puppet/provider/firewall/iptables.rb +++ b/lib/puppet/provider/firewall/iptables.rb @@ -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 diff --git a/lib/puppet/type/firewall.rb b/lib/puppet/type/firewall.rb index 2defbbc..c5487f3 100644 --- a/lib/puppet/type/firewall.rb +++ b/lib/puppet/type/firewall.rb @@ -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 . - +# Puppet Firewall type require 'puppet/util/firewall' require 'puppet/property/ordered_list' -- 2.45.2