From: Jonathan Boyett Date: Thu, 12 May 2011 02:06:48 +0000 (-0700) Subject: use array_matching for values which accept arrays X-Git-Tag: v0.0.1~60 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=549286fa495e452d1caa3c309526501ee28175ac;p=puppet-modules%2Fpuppetlabs-firewall.git use array_matching for values which accept arrays --- diff --git a/lib/puppet/type/firewall.rb b/lib/puppet/type/firewall.rb index 321d993..693df71 100644 --- a/lib/puppet/type/firewall.rb +++ b/lib/puppet/type/firewall.rb @@ -18,6 +18,7 @@ # along with this program. If not, see . require 'puppet/util/firewall' +require 'puppet/property/ordered_list' Puppet::Type.newtype(:firewall) do include Puppet::Util::Firewall @@ -120,10 +121,10 @@ Puppet::Type.newtype(:firewall) do end end - newproperty(:dport) do + newproperty(:dport, :array_matching => :all) do desc "The value for the iptables --destination-port parameter. If an array is specified, values will be passed to multiport module." - + validate do |value| if value.is_a?(Array) && value.length > 15 self.fail "multiport module only accepts <= 15 ports" @@ -133,6 +134,17 @@ Puppet::Type.newtype(:firewall) do munge do |value| @resource.string_to_port(value) end + + def value_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + + def change_to_s(currentvalue, newvalue) + currentvalue = value_to_s(currentvalue) if currentvalue != :absent + newvalue = value_to_s(newvalue) + super(currentvalue, newvalue) + end end newproperty(:iniface) do