-def run_sfatables(chain, hrn, origin_hrn, rspec, context_callback = None ):
- """
- Run the rspec through sfatables
- @param chain Name of rule chain
- @param hrn Object's hrn
- @param origin_hrn Original caller's hrn
- @param rspec Incoming rspec
- @param context_callback Callback used to generate the request context
+ def run_sfatables(chain, hrn, origin_hrn, rspec, context_callback = None ):
+ """
+ Run the rspec through sfatables
+ @param chain Name of rule chain
+ @param hrn Object's hrn
+ @param origin_hrn Original caller's hrn
+ @param rspec Incoming rspec
+ @param context_callback Callback used to generate the request context
+
+ @return rspec
+ """
+ if not context_callback:
+ context_callback = fetch_context
+
+ chain = chain.upper()
+ rules = SFATablesRules(chain)
+ print>>sys.stderr, " \r\n \r\n \t\t \t sfaTablesRuntime.py run_sfatables context_callback %s chain %s rules %s " %(context_callback,chain, rules )
+ if rules.sorted_rule_list:
+ contexts = rules.contexts
+ request_context = context_callback(hrn, origin_hrn, contexts)
+ rules.set_context(request_context)
+ newrspec = rules.apply(rspec)
+ else:
+ newrspec = rspec
+ return newrspec