]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Update docs, remove feature, and rename property
authorHunter Haugen <hunter@puppetlabs.com>
Wed, 20 Aug 2014 23:39:59 +0000 (16:39 -0700)
committerHunter Haugen <hunter@puppetlabs.com>
Wed, 20 Aug 2014 23:39:59 +0000 (16:39 -0700)
README.markdown
lib/puppet/provider/firewall/iptables.rb
lib/puppet/type/firewall.rb

index 046c4c0a93533e0d39ec24c3b5b23442ff00a9c6..d76d7b98e85fc27935205951d22bdf676d7c3c57 100644 (file)
@@ -579,6 +579,14 @@ firewall { '101 blacklist strange traffic':
 
   Requires the `address_type` feature.
 
+* `stat_every`: Match one packet every nth packet. Requires `stat_mode => 'nth'`
+
+* `stat_mode`: Set the matching mode for statistic matching. Supported modes are `random` and `nth`.
+
+* `stat_packet`: Set the initial counter value for the nth mode. Must be between 0 and the value of `stat_every`. Defaults to 0. Requires `stat_mode => 'nth'`
+
+* `stat_probability`: Set the probability from 0 to 1 for a packet to be randomly matched. It works only with `stat_mode => 'random'`.
+
 * `state`: Matches a packet based on its state in the firewall stateful inspection table. Valid values are: 'INVALID', 'ESTABLISHED', 'NEW', 'RELATED'. Requires the `state_match` feature.
 
 * `table`: Table to use. Valid values are: 'nat', 'mangle', 'filter', 'raw', 'rawpost'. By default the setting is 'filter'. Requires the `iptables` feature.
index 1f0dd7bb4324cf218575ecee41b7a63e7e1cd246..baf029609bde75d29d6673656addfe544adde1ed 100644 (file)
@@ -29,10 +29,6 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
   has_feature :ipsec_dir
   has_feature :ipsec_policy
   has_feature :mask
-  has_feature :stat_mode
-  has_feature :stat_every
-  has_feature :stat_packet
-  has_feature :stat_prob
 
   optional_commands({
     :iptables => 'iptables',
index 538efcb66a6dfdfc14e55901ed46a69a43e16d89..9c813e50e0397a7aeb5a004eb04e0048802a9634 100644 (file)
@@ -54,10 +54,6 @@ Puppet::Type.newtype(:firewall) do
   feature :ipsec_policy, "Match IPsec policy"
   feature :ipsec_dir, "Match IPsec policy direction"
   feature :mask, "Ability to match recent rules based on the ipv4 mask"
-  feature :stat_mode, "Match packets based on staistic mode"
-  feature :stat_every, "Match one packet every nth time"
-  feature :stat_packet, "Set initial counter"
-  feature :stat_prob, "Match packets based on probability"
 
   # provider specific features
   feature :iptables, "The provider provides iptables features."
@@ -906,17 +902,17 @@ Puppet::Type.newtype(:firewall) do
     newvalues(:in, :out)
   end
 
-  newproperty(:stat_mode, :required_features => :stat_mode) do
+  newproperty(:stat_mode) do
     desc <<-EOS
-      Sets the statistic modoule mode
+      Set the matching mode for statistic matching. Supported modes are `random` and `nth`.
     EOS
 
     newvalues(:nth, :random)
   end
 
-  newproperty(:stat_every, :required_features => :stat_mode) do
+  newproperty(:stat_every) do
     desc <<-EOS
-      Match every nth packet (used with 'nth' mode)
+      Match one packet every nth packet. Requires `stat_mode => 'nth'`
     EOS
 
     validate do |value|
@@ -934,29 +930,29 @@ Puppet::Type.newtype(:firewall) do
     end
   end
 
-  newproperty(:stat_packet, :required_features => :stat_mode) do
+  newproperty(:stat_packet) do
     desc <<-EOS
-      Set initial counter (used with 'nth' mode)
+      Set the initial counter value for the nth mode. Must be between 0 and the value of `stat_every`. Defaults to 0. Requires `stat_mode => 'nth'`
     EOS
 
     newvalues(/^\d+$/)
   end
 
-  newproperty(:stat_prob, :required_features => :stat_mode) do
+  newproperty(:stat_probability) do
     desc <<-EOS
-      Set the probably for a packet to be matched (used with 'random' mode)
+      Set the probability from 0 to 1 for a packet to be randomly matched. It works only with `stat_mode => 'random'`.
     EOS
 
     validate do |value|
       unless value =~ /^([01])\.(\d+)$/
         raise ArgumentError, <<-EOS
-          stat_prob must be between 0.0 and 1.0
+          stat_probability must be between 0.0 and 1.0
         EOS
       end
 
       if $1.to_i == 1 && $2.to_i != 0
         raise ArgumentError, <<-EOS
-          start_prob must be between 0.0 and 1.0
+          start_probability must be between 0.0 and 1.0
         EOS
       end
     end
@@ -1143,7 +1139,7 @@ Puppet::Type.newtype(:firewall) do
       self.fail "Mask can only be set if recent is enabled."
     end
 
-    [:stat_packet, :stat_every, :stat_prob].each do |param|
+    [:stat_packet, :stat_every, :stat_probability].each do |param|
       if value(param) && ! value(:stat_mode)
         self.fail "Parameter '#{param.to_s}' requires 'stat_mode' to be set"
       end
@@ -1157,8 +1153,8 @@ Puppet::Type.newtype(:firewall) do
       self.fail "Parameter 'stat_every' requires 'stat_mode' to be set to 'nth'"
     end
 
-    if value(:stat_prob) && value(:stat_mode) != :random
-      self.fail "Parameter 'stat_prob' requires 'stat_mode' to be set to 'random'"
+    if value(:stat_probability) && value(:stat_mode) != :random
+      self.fail "Parameter 'stat_probability' requires 'stat_mode' to be set to 'random'"
     end
 
   end