]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
use array_matching for values which accept arrays
authorJonathan Boyett <jonathan@failingservers.com>
Thu, 12 May 2011 02:06:48 +0000 (19:06 -0700)
committerJonathan Boyett <jonathan@failingservers.com>
Thu, 12 May 2011 02:06:48 +0000 (19:06 -0700)
lib/puppet/type/firewall.rb

index 321d9933b1eea4672b013ebfd68b9d24179a8c17..693df71a92f59e00a554c645fd099db5be666cf0 100644 (file)
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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