Permalink
Browse files

Move `create_rule()` to core library and rename it AFW

  • Loading branch information...
1 parent 9aaab36 commit fe6bc60f465face12e7711608d6da5d27a956a20 Julien Vehent committed Oct 2, 2012
Showing with 20 additions and 18 deletions.
  1. +18 −1 libraries/core.rb
  2. +0 −15 libraries/create_rule.rb
  3. +1 −1 metadata.json
  4. +1 −1 recipes/default.rb
View
@@ -1,4 +1,4 @@
-module AFWCore
+module AFW
# IP dummy regex, from `0.0.0.0` to `999.999.999.999`
IP_CIDR_VALID_REGEX = /\b(?:\d{1,3}\.){3}\d{1,3}\b(\/[0-3]?[0-9])?/
@@ -385,4 +385,21 @@ def build_rule_array(iptables_header, sources, destinations)
return iptables_array_destination
end
+
+
+ #
+ # Exported to other cookbooks ----
+ #
+ module_function
+ extend self
+ def create_rule(node, name, params)
+ node['afw']['rules'][name] = params
+ # Wrapper around `process_rule`
+ #
+ Chef::Log.info("AFW.create_rule(): processing '#{name}'")
+ if AFW.process_rule(node, name, params)
+ Chef::Log.info("AFW.create_rule(): finished processing '#{name}'")
+ end
+ return true
+ end
end
View
@@ -1,15 +0,0 @@
-module AFW
- extend AFWCore
- module_function
-
- def create_rule(node, name, params)
- node['afw']['rules'][name] = params
- # Wrapper around `process_rule`
- #
- Chef::Log.info("AFW.create_rule(): processing '#{name}'")
- if process_rule(node, name, params)
- Chef::Log.info("AFW.create_rule(): finished processing '#{name}'")
- end
- return true
- end
-end
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -20,7 +20,7 @@
node['afw']['tables']['nat']['chains'] = []
class Chef::Recipe
- include AFWCore
+ include AFW
end
node['afw']['rules'].each do |name,params|

0 comments on commit fe6bc60

Please sign in to comment.