From: Jonathan Boyett Date: Mon, 15 Aug 2011 18:18:14 +0000 (-0700) Subject: small refactor of value munging of existing rules X-Git-Tag: v0.0.1~13 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=05e4e76fd70963f43263f6c27ac8b67f0185672a;p=puppet-modules%2Fpuppetlabs-firewall.git small refactor of value munging of existing rules --- diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb index ebcee19..8318ac9 100644 --- a/lib/puppet/provider/firewall/iptables.rb +++ b/lib/puppet/provider/firewall/iptables.rb @@ -116,13 +116,11 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir keys << :chain keys.zip(values.scan(/"[^"]*"|\S+/).reverse) { |f, v| hash[f] = v.gsub(/"/, '') } - [:dport, :sport, :destination, :source, :state].each do |prop| - if hash[prop] =~ /,/ - hash[prop] = hash[prop].split(',') - else - hash[prop] = [hash[prop]] - end + + [:dport, :sport, :state].each do |prop| + hash[prop] = hash[prop].split(',') if ! hash[prop].nil? end + hash[:provider] = self.name.to_s hash[:table] = table hash[:ensure] = :present